public void AuthorizationCodePersists() { var subClaim = new Claim("sub", "*****@*****.**"); var emailClaim = new Claim("email", "*****@*****.**"); var code = new AuthorizationCode { Client = new Client { ClientId = "cid" }, RequestedScopes = new List <Scope> { new Scope { Description = "this is description", Enabled = true, Name = "sname", DisplayName = "This is Name!" } }, Subject = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim> { subClaim, emailClaim })) }; var clients = new List <Client> { new Client { ClientId = "cid", ClientName = "cname", Enabled = true, SlidingRefreshTokenLifetime = 100, AccessTokenType = AccessTokenType.Jwt, Flow = Flows.Implicit } }; var clientStore = new InMemoryClientStore(clients); var scopes = new List <Scope> { new Scope { Description = "sdescription", Name = "sname", Enabled = true, Emphasize = false, IncludeAllClaimsForUser = true, Required = false, Type = ScopeType.Identity } }; var scopeStore = new InMemoryScopeStore(scopes); var store = new RedisAuthorizationCodeStore(clientStore, scopeStore, RedisServer); store.StoreAsync("key1", code).Wait(); var result = store.GetAsync("key1").Result; Assert.Equal(code.SubjectId, result.SubjectId); Assert.Equal(code.ClientId, result.ClientId); }
public void AuthorizationCodePersists() { var subClaim = new Claim("sub", "*****@*****.**"); var emailClaim = new Claim("email", "*****@*****.**"); var code = new AuthorizationCode { Client = new Client { ClientId = "cid" }, RequestedScopes = new List<Scope> { new Scope { Description = "this is description", Enabled = true, Name = "sname", DisplayName = "This is Name!" } }, Subject = new ClaimsPrincipal(new ClaimsIdentity(new List<Claim> { subClaim,emailClaim})) }; var clients = new List<Client> { new Client { ClientId = "cid", ClientName = "cname", Enabled = true, SlidingRefreshTokenLifetime = 100, AccessTokenType = AccessTokenType.Jwt, Flow = Flows.Implicit } }; var clientStore = new InMemoryClientStore(clients); var scopes = new List<Scope> { new Scope { Description = "sdescription", Name = "sname", Enabled = true, Emphasize = false, IncludeAllClaimsForUser = true, Required = false, Type = ScopeType.Identity } }; var scopeStore = new InMemoryScopeStore(scopes); var store = new RedisAuthorizationCodeStore(clientStore,scopeStore, RedisServer); store.StoreAsync("key1", code).Wait(); var result = store.GetAsync("key1").Result; Assert.Equal(code.SubjectId, result.SubjectId); Assert.Equal(code.ClientId, result.ClientId); }