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()); }
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()); } }
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)); } }
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()); } }