1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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);
}
}
}
|