public async Task Validating_ID_site_token_fails()
        {
            var fakeDataStore = GetFakeDataStore();
            var fakeApplication = await fakeDataStore.GetResourceAsync<IApplication>("https://api.stormpath.com/v1/applications/foobarApplication");

            var request = OauthRequests.NewJwtAuthenticationRequest()
                .SetJwt(IDSiteAccessToken)
                .Build();

            IJwtAuthenticator authenticator = new DefaultJwtAuthenticator(fakeApplication, fakeDataStore);
            authenticator.WithLocalValidation();

            await Should.ThrowAsync<MismatchedClaimException>(authenticator.AuthenticateAsync(request));
        }
        public async Task Validating_ID_site_token_fails()
        {
            var fakeDataStore   = GetFakeDataStore();
            var fakeApplication = await fakeDataStore.GetResourceAsync <IApplication>("https://api.stormpath.com/v1/applications/foobarApplication");

            var request = OauthRequests.NewJwtAuthenticationRequest()
                          .SetJwt(IDSiteAccessToken)
                          .Build();

            IJwtAuthenticator authenticator = new DefaultJwtAuthenticator(fakeApplication, fakeDataStore);

            authenticator.WithLocalValidation();

            await Should.ThrowAsync <MismatchedClaimException>(authenticator.AuthenticateAsync(request));
        }
        public async Task Validating_token_with_specified_issuer()
        {
            var fakeDataStore   = GetFakeDataStore();
            var fakeApplication = await fakeDataStore.GetResourceAsync <IApplication>("https://api.stormpath.com/v1/applications/foobarApplication");

            var request = OauthRequests.NewJwtAuthenticationRequest()
                          .SetJwt(IDSiteAccessToken)
                          .Build();

            IJwtAuthenticator authenticator = new DefaultJwtAuthenticator(fakeApplication, fakeDataStore);

            authenticator.WithLocalValidation(new JwtLocalValidationOptions()
            {
                Issuer = "https://awesome-tenant.id.stormpath.io"
            });

            // Should not throw
            var result = await authenticator.AuthenticateAsync(request);

            result.Jwt.ShouldBe(IDSiteAccessToken);
        }
        public async Task Validating_token_with_specified_issuer()
        {
            var fakeDataStore = GetFakeDataStore();
            var fakeApplication = await fakeDataStore.GetResourceAsync<IApplication>("https://api.stormpath.com/v1/applications/foobarApplication");

            var request = OauthRequests.NewJwtAuthenticationRequest()
                .SetJwt(IDSiteAccessToken)
                .Build();

            IJwtAuthenticator authenticator = new DefaultJwtAuthenticator(fakeApplication, fakeDataStore);
            authenticator.WithLocalValidation(new JwtLocalValidationOptions()
            {
                Issuer = "https://awesome-tenant.id.stormpath.io"
            });

            // Should not throw
            var result = await authenticator.AuthenticateAsync(request);

            result.Jwt.ShouldBe(IDSiteAccessToken);
        }