Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(connector): delete connector when sdFactory is disabled #1222

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ public async Task DeleteConnectorAsync(Guid connectorId, bool deleteServiceAccou
case ConnectorStatusId.PENDING:
await DeleteConnectorWithDocuments(connectorId, result.SelfDescriptionDocumentId.Value, result.ConnectorOfferSubscriptions, connectorsRepository);
break;
// Connector should be able to deleted if the ClearinghouseConnectDisabled bit is disabled and no SD document was part of connector.
case ConnectorStatusId.ACTIVE when _settings.ClearinghouseConnectDisabled:
Phil91 marked this conversation as resolved.
Show resolved Hide resolved
await DeleteConnectorWithoutDocuments(connectorId, result.ConnectorOfferSubscriptions, connectorsRepository);
break;
case ConnectorStatusId.ACTIVE when result.SelfDescriptionDocumentId != null && result.DocumentStatusId != null:
await DeleteConnector(connectorId, result.ConnectorOfferSubscriptions, result.SelfDescriptionDocumentId.Value, result.DocumentStatusId.Value, connectorsRepository);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,32 @@ public async Task DeleteConnectorAsync_WithPendingAndWithoutDocumentId_ExpectedC
A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly();
}

[Fact]
public async Task DeleteConnectorAsync_WithActiveAndWithoutDocumentId_ExpectedCalls()
{
// Arrange
var connectorId = Guid.NewGuid();
var options = A.Fake<IOptions<ConnectorsSettings>>();
var settings = new ConnectorsSettings { ClearinghouseConnectDisabled = true };
A.CallTo(() => options.Value).Returns(settings);
var sut = new ConnectorsBusinessLogic(_portalRepositories, options, _sdFactoryBusinessLogic, _identityService, _serviceAccountManagement, A.Fake<ILogger<ConnectorsBusinessLogic>>());
var connectorOfferSubscriptions = new[] {
new ConnectorOfferSubscription(_fixture.Create<Guid>(), OfferSubscriptionStatusId.PENDING),
new ConnectorOfferSubscription(_fixture.Create<Guid>(), OfferSubscriptionStatusId.PENDING),
};
A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(A<Guid>._, _identity.CompanyId, A<IEnumerable<ProcessStepTypeId>>._))
.Returns(new DeleteConnectorData(true, null, null, ConnectorStatusId.ACTIVE, connectorOfferSubscriptions, UserStatusId.ACTIVE, Guid.NewGuid(), _fixture.Create<DeleteServiceAccountData>()));

// Act
await sut.DeleteConnectorAsync(connectorId, true);

// Assert
A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId, A<IEnumerable<ProcessStepTypeId>>._)).MustHaveHappenedOnceExactly();
A.CallTo(() => _connectorsRepository.DeleteConnector(connectorId)).MustHaveHappenedOnceExactly();
A.CallTo(() => _connectorsRepository.DeleteConnectorAssignedSubscriptions(connectorId, A<IEnumerable<Guid>>.That.Matches(x => x.Count() == 2))).MustHaveHappenedOnceExactly();
A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly();
}

[Fact]
public async Task DeleteConnectorAsync_WithPendingAndDocumentId_ExpectedCalls()
{
Expand Down
Loading