コード例 #1
0
        public void TestGetToken_WithIssuer_Throws()
        {
            Claim[] claims = { new Claim(Constants.Claims.ISSUER, "issuer") };
            Scope[] scopes = { new Scope("group", "resource", "permission") };

            Assert.ThrowsAsync <ArgumentException>(async() => await TestAccessToken.GetToken(DEV_AUTH_URL, claims, scopes).SafeAsync());
        }
コード例 #2
0
        public async Task TestGetToken_WithTenantAndUserIdAndXsrf_IsValid()
        {
            string token = await TestAccessToken.GetToken(DEV_AUTH_URL, Guid.NewGuid().ToString(), "user", "xsrf").SafeAsync();

            using (var httpClient = new HttpClient()) {
                IAccessTokenValidator validator = AccessTokenValidatorFactory.CreateRemoteValidator(httpClient, new Uri(DEV_AUTH_URL));
                Assert.DoesNotThrowAsync(async() => await validator.ValidateAsync(token).SafeAsync());
            }
        }
コード例 #3
0
        public async Task TestGetToken_WithTenantID_IsValid()
        {
            string token = await TestAccessToken.GetToken(DEV_AUTH_URL, Guid.NewGuid().ToString()).ConfigureAwait(false);

            using (var httpClient = new HttpClient()) {
                IAccessTokenValidator validator = AccessTokenValidatorFactory.CreateRemoteValidator(httpClient, new Uri(DEV_AUTH_URL), new Uri(DEV_AUTH_JWK_URL));
                Assert.DoesNotThrowAsync(async() => await validator.ValidateAsync(token).ConfigureAwait(false));
            }
        }
コード例 #4
0
        public async Task TestGetToken_WithClaimAndScope_IsValid()
        {
            Claim[] claims = { new Claim(Constants.Claims.TENANT_ID, Guid.NewGuid().ToString()) };
            Scope[] scopes = { new Scope("group", "resource", "permission") };
            string  token  = await TestAccessToken.GetToken(DEV_AUTH_URL, claims, scopes).SafeAsync();

            using (var httpClient = new HttpClient()) {
                IAccessTokenValidator validator = AccessTokenValidatorFactory.CreateRemoteValidator(httpClient, new Uri(DEV_AUTH_URL));
                Assert.DoesNotThrowAsync(async() => await validator.ValidateAsync(token).SafeAsync());
            }
        }