public void CleanDb() { if (_clientResourceClaimVm != null) { ClientSvc.DeleteClaim(_clientResourceClaimVm.Id); } if (_clientResourceAccessVm != null) { ClientSvc.DeleteResourceAccess(_clientResourceAccessVm.Id); } if (_clientKeyVm != null) { ClientSvc.DeleteClientKey(_clientKeyVm.Id); } if (_clientVm != null) { ClientSvc.DeleteClient(_clientVm.Id); } if (_resClaim != null) { ResManagerSvc.DeleteClaim(_resClaim.Id); } if (_resVm != null) { ResManagerSvc.DeleteManager(_resVm.Id); } }
public void DataAccessAlreadyExist() { var dbRes = ClientSvc.CreateResourceAccess(_clientVm.Id, ResourceVm.Id, 0, ClientResourceAccessStatus.Pending); _clientResourceAccessVm = dbRes.Resource; Assert.AreEqual(dbRes.Message, ResourceManagerMessages.Error.RESOURCE_ALREADY_EXISTS); }
public void ClaimAlreadyExists() { var dbRes = ClientSvc.AddClaim(_clientResourceAccessVm.Id, ResourceClaimVm.Id, ClientResourceClaimsAccess.Allow); _clientResourceClaimVm = dbRes.Claim; Assert.AreEqual(dbRes.Message, ResourceManagerMessages.Error.CLAIM_ADD_ALREADY_EXISTS); }
public void CreateClient() { var res = ClientSvc.CreateClient(0, clientName, ClientKeyStatus.Pending); _clientVm = res.Client; _clientKeyVm = res.Key; Assert.IsTrue(res.IsSuccess); }
public void InvalidClientKeyCreate() { var res = ClientSvc.CreateKey(0, ClientKeyStatus.Open); if (res.IsSuccess) { ClientSvc.DeleteClientKey(res.key.Id); } Assert.AreEqual(res.Message, ResourceManagerMessages.Error.CLIENT_NOT_FOUND); }
public void UpdateClaimAccess() { if (_clientResourceClaimVm == null) { Assert.Fail("FindById: Test Failed to create a new resource claim ."); } var dbRes = ClientSvc.UpdateClaimAccess(_clientResourceClaimVm.Id, ClientResourceClaimsAccess.Allow); Assert.IsTrue(dbRes.IsSuccess); }
public void UpdateKeyStatus() { if (_clientKeyVm == null) { Assert.Fail("FindById: Test Failed to create a new client key."); } var dbRes = ClientSvc.UpdateKeyStatus(_clientKeyVm.Id, ClientKeyStatus.Open); Assert.IsTrue(dbRes.IsSuccess); }
public void FindResourceAccessClaim() { if (_clientResourceClaimVm == null) { Assert.Fail("FindById: Test Failed to create a new client resource claim."); } var dbView = ClientSvc.GetClientResourceClaims(_clientResourceClaimVm.Id); Assert.IsNotNull(dbView); }
private void FindResourceAccess() { if (_clientResourceAccessVm == null) { Assert.Fail("FindById: Test Failed to create a new client resource access."); } var dbView = ClientSvc.GetClientResourceAccess(_clientResourceAccessVm.Id); Assert.IsNotNull(dbView); }
private void FindKeyByAPIKey() { if (_clientKeyVm == null) { Assert.Fail("FindById: Test Failed to create a new client key."); } var dbView = ClientSvc.GetClientKeyByAPIKey(_clientKeyVm.APIKey); Assert.IsNotNull(dbView); }
private void FindById() { if (_clientVm == null) { Assert.Fail("FindById: Test Failed to create a new client."); } var dbView = ClientSvc.Get(_clientVm.Id); Assert.IsNotNull(dbView); }
public void CreateResourceAccessClaim() { if (_clientResourceAccessVm == null) { Assert.Fail("FindById: Test Failed to create a new client resource access."); } var dbRes = ClientSvc.AddClaim(_clientResourceAccessVm.Id, ResourceClaimVm.Id, ClientResourceClaimsAccess.Allow); _clientResourceClaimVm = dbRes.Claim; Assert.IsTrue(dbRes.IsSuccess); }
public void CreateResourceAccess() { if (_clientVm == null) { Assert.Fail("FindById: Test Failed to create a new client."); } var dbRes = ClientSvc.CreateResourceAccess(_clientVm.Id, ResourceVm.Id, 0, ClientResourceAccessStatus.Pending); _clientResourceAccessVm = dbRes.Resource; Assert.IsTrue(dbRes.IsSuccess); }
public void CreateKey() { if (_clientVm == null) { Assert.Fail("FindById: Test Failed to create a new client."); } var res = ClientSvc.CreateKey(_clientVm.Id, ClientKeyStatus.Open); if (res.IsSuccess) { ClientSvc.DeleteClientKey(res.key.Id); } Assert.IsTrue(res.IsSuccess); }
public async Task <Client> FindClientByIdAsync(string clientId) { var dto = await ClientSvc.FindClientByIdAsync(clientId); if (dto == null) { return(null); } var scopes = dto.APIResources.Select(e => e.Name).ToList(); scopes.Add(IdentityServerConstants.StandardScopes.OpenId); scopes.Add(IdentityServerConstants.StandardScopes.Profile); return(new Client { ClientId = dto.Client.Id,//API账号、客户端Id AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, ClientSecrets = { new Secret(dto.Client.Secret.Sha256()) //秘钥 }, AllowedScopes = scopes //这个账号支持访问哪些应用 }); }
public void ExistingClient() { var res = ClientSvc.CreateClient(0, clientName, ClientKeyStatus.Pending); Assert.AreEqual(res.Message, ResourceManagerMessages.Error.CLIENT_ADD_ALREADY_EXISTS); }