diff options
Diffstat (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudIntegratedTest.cs')
-rw-r--r-- | docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudIntegratedTest.cs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudIntegratedTest.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudIntegratedTest.cs index 179048d..bd07c70 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudIntegratedTest.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudIntegratedTest.cs @@ -20,6 +20,7 @@ public class CrudIntegratedTest : IAsyncLifetime builder.Services.AddCrud<TestEntity>(); builder.WebHost.UseTestServer(); _app = builder.Build(); + _app.UseCrudCore(); _app.MapCrud<TestEntity>("/test", "test-perm"); } @@ -139,4 +140,61 @@ public class CrudIntegratedTest : IAsyncLifetime Assert.Empty(body); } } + + [Fact] + public async Task UnauthorizedTest() + { + { + using var response = await _httpClient.GetAsync("/test"); + Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); + } + + { + using var response = await _httpClient.GetAsync("/test/test"); + Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); + } + + { + using var response = await _httpClient.PostAsJsonAsync("/test", new TestEntity + { + Name = "test", + Age = 22 + }); + Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); + } + + { + using var response = await _httpClient.PatchAsJsonAsync("/test/test", new TestEntity + { + Name = "test-2", + Age = 23, + Height = 188.0f + }); + Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); + } + + { + using var response = await _httpClient.DeleteAsync("/test/test"); + Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); + } + } + + [Fact] + public async Task NotFoundTest() + { + { + using var response = await _authorizedHttpClient.GetAsync("/test/test"); + Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); + } + + { + using var response = await _authorizedHttpClient.PatchAsJsonAsync("/test/test", new TestEntity + { + Name = "test-2", + Age = 23, + Height = 188.0f + }); + Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); + } + } } |