public RbacServiceTests() { _identityProvider = GetIdentityProvider("aad", "test", "https://microsoft.onmicrosoft.com/common/"); _controlPlaneDataStore = Substitute.For <IControlPlaneDataStore>(); _controlPlaneDataStore.GetIdentityProviderAsync(_identityProvider.Name, Arg.Any <CancellationToken>()).Returns(_identityProvider); _controlPlaneDataStore.UpsertIdentityProviderAsync(_identityProvider, Arg.Any <string>(), Arg.Any <CancellationToken>()).Returns(new UpsertResponse <IdentityProvider>(_identityProvider, UpsertOutcome.Updated, "testEtag")); _rbacService = new RbacService(_controlPlaneDataStore); }
public async void GivenAName_WhenGettingIdentityProvider_ThenIdentityProviderReturned(string name, string audience, string authority) { var identityProvider = GetIdentityProvider(name, audience, authority); _controlPlaneDataStore.GetIdentityProviderAsync(identityProvider.Name, Arg.Any <CancellationToken>()).Returns(identityProvider); var retIdentityProvider = await _rbacService.GetIdentityProviderAsync(identityProvider.Name, CancellationToken.None); VerifyIdentityProvider(name, audience, authority, "1.0", identityProvider); }
public RbacServiceTests() { _identityProvider = new IdentityProvider("aad", "https://login.microsoftonline.com/common", new List <string> { "test" }, "1"); _controlPlaneDataStore = Substitute.For <IControlPlaneDataStore>(); _controlPlaneDataStore.GetIdentityProviderAsync(_identityProvider.Name, Arg.Any <CancellationToken>()).Returns(_identityProvider); _controlPlaneDataStore.UpsertIdentityProviderAsync(_identityProvider, Arg.Any <CancellationToken>()).Returns(_identityProvider); _rbacService = new RbacService(_controlPlaneDataStore); }
public RbacServiceTests() { _identityProvider = GetIdentityProvider("aad", "test", "https://microsoft.onmicrosoft.com/common/"); _controlPlaneDataStore = Substitute.For <IControlPlaneDataStore>(); _controlPlaneDataStore.GetIdentityProviderAsync(_identityProvider.Name, Arg.Any <CancellationToken>()).Returns(_identityProvider); _controlPlaneDataStore.UpsertIdentityProviderAsync(_identityProvider, Arg.Any <string>(), Arg.Any <CancellationToken>()).Returns(new UpsertResponse <IdentityProvider>(_identityProvider, UpsertOutcome.Updated, "testEtag")); IList <ResourcePermission> resourcePermissions = new List <ResourcePermission>(); _role = GetRole("clinician", resourcePermissions); _controlPlaneDataStore.GetRoleAsync(_role.Name, Arg.Any <CancellationToken>()).Returns(_role); _controlPlaneDataStore.UpsertRoleAsync(_role, Arg.Any <string>(), Arg.Any <CancellationToken>()).Returns(new UpsertResponse <Role>(_role, UpsertOutcome.Updated, "testEtag")); _controlPlaneDataStore.DeleteRoleAsync(_role.Name, Arg.Any <string>(), Arg.Any <CancellationToken>()); _rbacService = new RbacService(_controlPlaneDataStore); }
public async Task <IdentityProvider> GetIdentityProviderAsync(string name, CancellationToken cancellationToken) { EnsureArg.IsNotNullOrWhiteSpace(name, nameof(name)); return(await _controlPlaneDataStore.GetIdentityProviderAsync(name, cancellationToken)); }