diff options
author | crupest <crupest@outlook.com> | 2022-04-16 19:52:50 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-04-16 19:52:50 +0800 |
commit | 8c797c5b4f822ee815357fc358d6b8de38b86dd9 (patch) | |
tree | 99ba523264beeb56f92f9f58d86d03678c2cc369 /BackEnd/Timeline.Tests/IntegratedTests2/UserTest2.cs | |
parent | 7715ddd0d70efc32bf3d04d2b2c356c333328344 (diff) | |
download | timeline-8c797c5b4f822ee815357fc358d6b8de38b86dd9.tar.gz timeline-8c797c5b4f822ee815357fc358d6b8de38b86dd9.tar.bz2 timeline-8c797c5b4f822ee815357fc358d6b8de38b86dd9.zip |
...
Diffstat (limited to 'BackEnd/Timeline.Tests/IntegratedTests2/UserTest2.cs')
-rw-r--r-- | BackEnd/Timeline.Tests/IntegratedTests2/UserTest2.cs | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests2/UserTest2.cs b/BackEnd/Timeline.Tests/IntegratedTests2/UserTest2.cs new file mode 100644 index 00000000..12573a0c --- /dev/null +++ b/BackEnd/Timeline.Tests/IntegratedTests2/UserTest2.cs @@ -0,0 +1,88 @@ +using System; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using FluentAssertions; +using Timeline.Models.Http; +using Xunit; +using Xunit.Abstractions; + +namespace Timeline.Tests.IntegratedTests2 +{ + public class UserTest2 : IntegratedTestBase + { + public UserTest2(ITestOutputHelper testOutput) : base(testOutput) + { + } + + [Fact] + public async Task UserPatchTest() + { + var a = await UserClient.TestJsonSendAsync<HttpUser>(HttpMethod.Patch, "v2/users/user", new HttpUserPatchRequest + { + Nickname = "nick" + }); + a.Nickname.Should().Be("nick"); + } + + [Fact] + public async Task UserPatchUnauthorize() + { + await DefaultClient.TestJsonSendAsync(HttpMethod.Patch, "v2/users/user", new HttpUserPatchRequest + { + Nickname = "nick" + }, expectedStatusCode: HttpStatusCode.Unauthorized); + } + + [Fact] + public async Task UserPatchForbid() + { + await UserClient.TestJsonSendAsync(HttpMethod.Patch, "v2/users/user", new HttpUserPatchRequest + { + Username = "hello" + }, expectedStatusCode: HttpStatusCode.Forbidden); + + await UserClient.TestJsonSendAsync(HttpMethod.Patch, "v2/users/user", new HttpUserPatchRequest + { + Password = "hello" + }, expectedStatusCode: HttpStatusCode.Forbidden); + + await UserClient.TestJsonSendAsync(HttpMethod.Patch, "v2/users/admin", new HttpUserPatchRequest + { + Nickname = "nick" + }, expectedStatusCode: HttpStatusCode.Forbidden); + } + + [Fact] + public async Task AdminPatchTest() + { + var a = await AdminClient.TestJsonSendAsync<HttpUser>(HttpMethod.Patch, "v2/users/user", new HttpUserPatchRequest + { + Username = "hello", + Password = "hellopw", + Nickname = "nick" + }); + a.Username.Should().Be("hello"); + a.Nickname.Should().Be("nick"); + } + + [Fact] + public async Task DeleteTest() + { + await AdminClient.TestSendAsync(HttpMethod.Delete, "v2/users/user"); + } + + [Fact] + public async Task DeleteUnauthorized() + { + await DefaultClient.TestSendAsync(HttpMethod.Delete, "v2/users/user", expectedStatusCode: HttpStatusCode.Unauthorized); + } + + [Fact] + public async Task DeleteForbid() + { + await UserClient.TestSendAsync(HttpMethod.Delete, "v2/users/user", expectedStatusCode: HttpStatusCode.Forbidden); + } + } +} + |