Skip to content

Commit

Permalink
fix: code scanner and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tfjanjua committed Oct 28, 2024
1 parent 28a0502 commit 508af80
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/externalsystems/Bpdm.Library/BpdmService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ public async Task<bool> SetCxMembership(string businessPartnerNumber, Cancellati
{
using var httpClient = await _tokenService.GetAuthorizedClient<BpdmService>(_settings, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);

// Same User (which we have for BPDM service) can be used to call Business Partner Pool
// But BaseAddress of Business Partner Pool is different as its deployed on another server.
httpClient.BaseAddress = new Uri(_settings.BusinessPartnerPoolBaseAddress);

var requestData = new BpdmCxMembership(
new BpdmCxMembershipDto[]{
new(businessPartnerNumber, true)
Expand Down
3 changes: 3 additions & 0 deletions src/externalsystems/Bpdm.Library/BpdmServiceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ public class BpdmServiceSettings : KeyVaultAuthSettings
public bool UseDimWallet { get; set; }

public bool StartSharingStateAsReady { get; set; }

[Required(AllowEmptyStrings = false)]
public string BusinessPartnerPoolBaseAddress { get; set; } = null!;
}
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ await provisioningManager.DeleteClientRolesFromCentralUserAsync(iamUserId, roleN
return new IApplicationChecklistService.WorkerChecklistProcessStepExecutionResult(
ProcessStepStatusId.DONE,
null,
Enumerable.Repeat(_settings.UseDimWallet ? ProcessStepTypeId.FINISH_APPLICATION_ACTIVATION : ProcessStepTypeId.SET_MEMBERSHIP, 1),
Enumerable.Repeat(_settings.UseDimWallet ? ProcessStepTypeId.SET_CX_MEMBERSHIP_IN_BPDM : ProcessStepTypeId.SET_MEMBERSHIP, 1),
null,
true,
null);
Expand Down Expand Up @@ -306,7 +306,7 @@ await provisioningManager.DeleteClientRolesFromCentralUserAsync(iamUserId, roleN
throw new ConflictException("BusinessPartnerNumber must be set");
}

var resultMessage = await bpdmService.SetCxMembership(businessPartnerNumber, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
await bpdmService.SetCxMembership(businessPartnerNumber, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
return new IApplicationChecklistService.WorkerChecklistProcessStepExecutionResult(
ProcessStepStatusId.DONE,
null,
Expand Down
5 changes: 3 additions & 2 deletions tests/externalsystems/Bpdm.Library/BpdmServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public BpdmServiceTests()
Scope = "test",
Username = "user@name",
BaseAddress = "https://base.address.com",
BusinessPartnerPoolBaseAddress = "https://business.partner.pool.base.address.com",
ClientId = "CatenaX",
ClientSecret = "pass@Secret",
GrantType = "cred",
Expand Down Expand Up @@ -673,7 +674,7 @@ public async Task SetCxMembership_WithValidData_DoesNotThrowException()
var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.OK);
using var httpClient = new HttpClient(httpMessageHandlerMock)
{
BaseAddress = new Uri("https://base.address.com")
BaseAddress = new Uri("https://business.partner.pool.base.address.com")
};
A.CallTo(() => _tokenService.GetAuthorizedClient<BpdmService>(_options.Value, A<CancellationToken>._))
.Returns(httpClient);
Expand All @@ -694,7 +695,7 @@ public async Task SetCxMembership_WithInvalidData_ThrowsServiceException()
var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.BadRequest);
using var httpClient = new HttpClient(httpMessageHandlerMock)
{
BaseAddress = new Uri("https://base.address.com")
BaseAddress = new Uri("https://business.partner.pool.base.address.com")
};
A.CallTo(() => _tokenService.GetAuthorizedClient<BpdmService>(_options.Value, A<CancellationToken>._)).Returns(httpClient);
var sut = new BpdmService(_tokenService, _options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ public async Task SetTheme_WithValid_ReturnsExpected(bool useDimWallet)

//Assert
var expectedProcessStepTypeId =
useDimWallet ? ProcessStepTypeId.FINISH_APPLICATION_ACTIVATION : ProcessStepTypeId.SET_MEMBERSHIP;
useDimWallet ? ProcessStepTypeId.SET_CX_MEMBERSHIP_IN_BPDM : ProcessStepTypeId.SET_MEMBERSHIP;
A.CallTo(() => _provisioningManager.UpdateSharedRealmTheme("idp1", _settings.LoginTheme)).MustHaveHappenedOnceExactly();
result.StepStatusId.Should().Be(ProcessStepStatusId.DONE);
result.ScheduleStepTypeIds.Should().ContainSingle()
Expand Down

0 comments on commit 508af80

Please sign in to comment.