Exemplo n.º 1
0
        public async Task WithoutAuthentication_Returns401Unauthorized()
        {
            using var client = await _fixture.BuildClient();

            _fixture.Unauthorize(client);

            var result = await client.GetAsync(Routes.v1.Editions.Index);

            Assert.Equal(System.Net.HttpStatusCode.Unauthorized, result.StatusCode);
            var problemDetails = System.Text.Json.JsonSerializer.Deserialize <ProblemDetails>(await result.Content.ReadAsStringAsync());

            Assert.Equal("Unauthorized", problemDetails.Title);
        }
Exemplo n.º 2
0
        public async Task AsAnonymousUser_ForExistingEdition_Returns401Unauthorized()
        {
            using var client = await _fixture.BuildClient();

            _fixture.Unauthorize(client);

            var result = await client.GetAsync(Routes.v1.Editions.DetailsFor(1));

            Assert.Equal(System.Net.HttpStatusCode.Unauthorized, result.StatusCode);
            var problemDetails = System.Text.Json.JsonSerializer.Deserialize <ProblemDetails>(await result.Content.ReadAsStringAsync());

            Assert.Equal("https://httpstatuses.com/401", problemDetails.Type);
        }
Exemplo n.º 3
0
        public async Task AsAnonymousUser_FailsWith401Unauthorized()
        {
            using var client = await _fixture.BuildClient();

            _fixture.Unauthorize(client);

            var result = await client.PostAsJsonAsync(Routes.v1.Editions.Create, new CreateUseCase.Command()
            {
                Name      = "test",
                StartDate = DateTime.Today,
                EndDate   = DateTime.Today.AddDays(7)
            });

            Assert.Equal(System.Net.HttpStatusCode.Unauthorized, result.StatusCode);
            var problemDetails = System.Text.Json.JsonSerializer.Deserialize <ProblemDetails>(await result.Content.ReadAsStringAsync());

            Assert.Equal("Unauthorized", problemDetails.Title);
        }