Skip to content

Commit

Permalink
fix(connector): create connector with correct state (eclipse-tractusx…
Browse files Browse the repository at this point in the history
…#919)

Refs: eclipse-tractusx#918
Reviewed-By: Evelyn Gurschler <[email protected]>
  • Loading branch information
Phil91 authored and dhiren-singh-007 committed Aug 14, 2024
1 parent be8f1d7 commit dc0d112
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private async Task<Guid> CreateAndRegisterConnectorAsync(
connector.HostId = host;
connector.TypeId = type;
connector.DateLastChanged = DateTimeOffset.UtcNow;
connector.StatusId = _settings.ClearinghouseConnectDisabled ? ConnectorStatusId.ACTIVE : ConnectorStatusId.PENDING;
connector.StatusId = _settings.ClearinghouseConnectDisabled ? ConnectorStatusId.PENDING : ConnectorStatusId.ACTIVE;
if (technicalUserId != null)
{
connector.CompanyServiceAccountId = technicalUserId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public async Task CreateConnectorAsync_WithValidInput_ReturnsCreatedConnectorDat

// Assert
result.Should().NotBeEmpty();
_connectors.Should().HaveCount(1);
_connectors.Should().ContainSingle().Which.StatusId.Should().Be(clearingHouseDisabled ? ConnectorStatusId.PENDING : ConnectorStatusId.ACTIVE);
A.CallTo(() => _connectorsRepository.CreateConnectorAssignedSubscriptions(A<Guid>._, A<Guid>._)).MustNotHaveHappened();
A.CallTo(() => _sdFactoryBusinessLogic.RegisterConnectorAsync(A<Guid>._, A<string>._, A<string>._, A<CancellationToken>._)).MustHaveHappened(clearingHouseDisabled ? 0 : 1, Times.Exactly);
}
Expand Down Expand Up @@ -203,33 +203,6 @@ public async Task CreateConnectorAsync_WithClientIdNull_DoesntSaveData()
_connectors.Should().HaveCount(1);
}

[Fact]
public async Task CreateConnectorAsync_WithoutSelfDescriptionDocumentAndSdConnectionDisabled_CallsExpected()
{
// Arrange
var sut = new ConnectorsBusinessLogic(_portalRepositories, Options.Create(new ConnectorsSettings
{
MaxPageSize = 15,
ValidCertificationContentTypes = new[]
{
"application/x-pem-file",
"application/x-x509-ca-cert",
"application/pkix-cert"
},
ClearinghouseConnectDisabled = true
}), _sdFactoryBusinessLogic, _identityService, A.Fake<ILogger<ConnectorsBusinessLogic>>());

var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", null);
A.CallTo(() => _identity.CompanyId).Returns(CompanyIdWithoutSdDocument);

// Act
await sut.CreateConnectorAsync(connectorInput, CancellationToken.None);

// Assert
A.CallTo(() => _connectorsRepository.CreateConnector(A<string>._, A<string>._, A<string>._, A<Action<Connector>>._)).MustHaveHappenedOnceExactly();
A.CallTo(() => _sdFactoryBusinessLogic.RegisterConnectorAsync(A<Guid>._, A<string>._, A<string>._, A<CancellationToken>._)).MustNotHaveHappened();
}

[Fact]
public async Task CreateConnectorAsync_WithoutSelfDescriptionDocument_ThrowsUnexpectedException()
{
Expand Down Expand Up @@ -318,7 +291,8 @@ public async Task CreateManagedConnectorAsync_WithValidInput_ReturnsCreatedConne

// Assert
result.Should().NotBeEmpty();
_connectors.Should().HaveCount(1);
_connectors.Should().ContainSingle().Which.StatusId.Should().Be(clearingHouseDisabled ? ConnectorStatusId.PENDING : ConnectorStatusId.ACTIVE);

A.CallTo(() => _connectorsRepository.CreateConnectorAssignedSubscriptions(A<Guid>._, _validOfferSubscriptionId)).MustHaveHappenedOnceExactly();
A.CallTo(() => _sdFactoryBusinessLogic.RegisterConnectorAsync(A<Guid>._, A<string>._, A<string>._, A<CancellationToken>._)).MustHaveHappened(clearingHouseDisabled ? 0 : 1, Times.Exactly);
}
Expand Down

0 comments on commit dc0d112

Please sign in to comment.