public async Task RedirectBearerBrowserRequestWithoutGroup()
        {
            // Arrange
            var client = new TestHttpClient(_fixture);

            using (var cleanup = new AutoCleanup(_fixture.Client))
            {
                var email   = $"its-{_fixture.TestKey}@testmail.stormpath.com";
                var account = await _fixture.TestApplication.CreateAccountAsync(
                    nameof(RedirectBearerBrowserRequestWithoutGroup),
                    nameof(GroupsRequirementShould),
                    email,
                    "Changeme123!!");

                cleanup.MarkForDeletion(account);

                var accessToken = await _fixture.GetAccessToken(account, "Changeme123!!");

                var request = new HttpRequestMessage(HttpMethod.Get, "/requireGroup");
                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/html"));
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

                // Act
                var response = await client.SendAsync(request);

                // Assert
                response.StatusCode.Should().Be(HttpStatusCode.Redirect);
            }
        }
Exemplo n.º 2
0
        public async Task GetUserAuthenticatedByHeader()
        {
            // Arrange
            var client = new TestHttpClient(_fixture);

            using (var cleanup = new AutoCleanup(_fixture.Client))
            {
                var email   = $"its-{_fixture.TestKey}@testmail.stormpath.com";
                var account = await _fixture.TestApplication.CreateAccountAsync(
                    nameof(GetUserAuthenticatedByHeader),
                    nameof(GetUserShould),
                    email,
                    "Changeme123!!");

                cleanup.MarkForDeletion(account);

                var accessToken = await _fixture.GetAccessToken(account, "Changeme123!!");

                var request = new HttpRequestMessage(HttpMethod.Get, "/user");
                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

                // Act
                var response = await client.SendAsync(request);

                // Assert
                response.StatusCode.Should().Be(HttpStatusCode.OK);

                (await response.Content.ReadAsStringAsync()).Should().Be(account.Href);
            }
        }