-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,965 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,15 +5,17 @@ namespace PidpTests.Features.AccessRequests; | |
using Xunit; | ||
|
||
using Pidp.Features.AccessRequests; | ||
using Pidp.Infrastructure.Auth; | ||
using Pidp.Infrastructure.HttpClients.Keycloak; | ||
using Pidp.Infrastructure.HttpClients.Plr; | ||
using Pidp.Models; | ||
using PidpTests.TestingExtensions; | ||
|
||
public class SAEformsTests : InMemoryDbTest | ||
{ | ||
[Theory] | ||
[MemberData(nameof(SAEformsIdentifierTypeTestData))] | ||
public async void CreateSAEformsEnrolment_ValidProfileWithVaryingLicence_MatchesExcludedTypes(IdentifierType identifierType, bool expected) | ||
public async Task CreateSAEformsEnrolment_ValidProfileWithVaryingLicence_MatchesExcludedTypes(IdentifierType identifierType, bool expected) | ||
{ | ||
var party = this.TestDb.HasAParty(party => | ||
{ | ||
|
@@ -23,6 +25,10 @@ public async void CreateSAEformsEnrolment_ValidProfileWithVaryingLicence_Matches | |
party.Email = "[email protected]"; | ||
party.Phone = "5551234567"; | ||
party.Cpn = "Cpn"; | ||
party.Credentials = [ | ||
new Credential { UserId = Guid.NewGuid(), IdentityProvider = IdentityProviders.BCServicesCard}, | ||
new Credential { UserId = Guid.NewGuid(), IdentityProvider = IdentityProviders.BCProvider}, | ||
]; | ||
}); | ||
var client = A.Fake<IPlrClient>() | ||
.ReturningAStandingsDigest(true, identifierType); | ||
|
@@ -35,17 +41,26 @@ public async void CreateSAEformsEnrolment_ValidProfileWithVaryingLicence_Matches | |
Assert.Equal(expected, result.IsSuccess); | ||
if (expected) | ||
{ | ||
A.CallTo(() => keycloak.AssignAccessRoles(party.PrimaryUserId, MohKeycloakEnrolment.SAEforms)).MustHaveHappened(); | ||
foreach (var credential in party.Credentials) | ||
{ | ||
A.CallTo(() => keycloak.AssignAccessRoles(credential.UserId, MohKeycloakEnrolment.SAEforms)).MustHaveHappened(); | ||
} | ||
} | ||
else | ||
{ | ||
keycloak.AssertNoRolesAssigned(); | ||
} | ||
} | ||
|
||
public static IEnumerable<object[]> SAEformsIdentifierTypeTestData() | ||
public static TheoryData<IdentifierType, bool> SAEformsIdentifierTypeTestData() | ||
{ | ||
return TestData.AllIdentifierTypes | ||
.Select(identifierType => new object[] { identifierType, !SAEforms.ExcludedIdentifierTypes.Contains(identifierType) }); | ||
var testData = new TheoryData<IdentifierType, bool>(); | ||
|
||
foreach (var identifierType in TestData.AllIdentifierTypes) | ||
{ | ||
testData.Add(identifierType, !SAEforms.ExcludedIdentifierTypes.Contains(identifierType)); | ||
} | ||
|
||
return testData; | ||
} | ||
} |
Oops, something went wrong.