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