diff options
author | crupest <crupest@outlook.com> | 2020-01-31 00:10:23 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-01-31 00:10:23 +0800 |
commit | 038e8dcf461d4d4ebd51c8fdf7680497869f691c (patch) | |
tree | dfd6ca1258d61ed91e59be620a39159919d07a3f /Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs | |
parent | 5aaa4f95e6bdd46e6740c1ecbbd46bdf415eedd2 (diff) | |
download | timeline-038e8dcf461d4d4ebd51c8fdf7680497869f691c.tar.gz timeline-038e8dcf461d4d4ebd51c8fdf7680497869f691c.tar.bz2 timeline-038e8dcf461d4d4ebd51c8fdf7680497869f691c.zip |
...
Diffstat (limited to 'Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs')
-rw-r--r-- | Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs b/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs index d787d87d..dacfea62 100644 --- a/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs +++ b/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs @@ -30,6 +30,74 @@ namespace Timeline.Tests.IntegratedTests body.Visibility.Should().Be(TimelineVisibility.Register); body.Description.Should().Be(""); body.Members.Should().NotBeNull().And.BeEmpty(); + }
+
+ [Fact] + public async Task InvalidModel_BadUsername() + { + using var client = await CreateClientAsAdministrator(); + {
+ var res = await client.GetAsync("users/user!!!/timeline"); + res.Should().BeInvalidModel();
+ }
+ {
+ var res = await client.PatchAsJsonAsync("users/user!!!/timeline", new TimelinePatchRequest { }); + res.Should().BeInvalidModel();
+ }
+ {
+ var res = await client.PutAsync("users/user!!!/timeline/members/user1", null); + res.Should().BeInvalidModel();
+ }
+ {
+ var res = await client.DeleteAsync("users/user!!!/timeline/members/user1"); + res.Should().BeInvalidModel();
+ }
+ {
+ var res = await client.GetAsync("users/user!!!/timeline/posts"); + res.Should().BeInvalidModel();
+ }
+ {
+ var res = await client.PostAsJsonAsync("users/user!!!/timeline/posts", new TimelinePostCreateRequest { Content = "aaa" }); + res.Should().BeInvalidModel();
+ } + {
+ var res = await client.DeleteAsync("users/user!!!/timeline/posts/123");
+ res.Should().BeInvalidModel();
+ } + }
+
+ [Fact] + public async Task NotFound() + { + using var client = await CreateClientAsAdministrator(); + {
+ var res = await client.GetAsync("users/usernotexist/timeline"); + res.Should().HaveStatusCode(404).And.HaveCommonBody(ErrorCodes.UserCommon.NotExist);
+ }
+ {
+ var res = await client.PatchAsJsonAsync("users/usernotexist/timeline", new TimelinePatchRequest { }); + res.Should().HaveStatusCode(404).And.HaveCommonBody(ErrorCodes.UserCommon.NotExist);
+ }
+ {
+ var res = await client.PutAsync("users/usernotexist/timeline/members/user1", null); + res.Should().HaveStatusCode(404).And.HaveCommonBody(ErrorCodes.UserCommon.NotExist);
+ }
+ {
+ var res = await client.DeleteAsync("users/usernotexist/timeline/members/user1"); + res.Should().HaveStatusCode(404).And.HaveCommonBody(ErrorCodes.UserCommon.NotExist);
+ }
+ {
+ var res = await client.GetAsync("users/usernotexist/timeline/posts"); + res.Should().HaveStatusCode(404).And.HaveCommonBody(ErrorCodes.UserCommon.NotExist);
+ }
+ {
+ var res = await client.PostAsJsonAsync("users/usernotexist/timeline/posts", new TimelinePostCreateRequest { Content = "aaa" }); + res.Should().HaveStatusCode(404).And.HaveCommonBody(ErrorCodes.UserCommon.NotExist);
+ } + {
+ var res = await client.DeleteAsync("users/usernotexist/timeline/posts/123");
+ res.Should().HaveStatusCode(404).And.HaveCommonBody(ErrorCodes.UserCommon.NotExist);
+ } } [Fact] @@ -162,10 +230,11 @@ namespace Timeline.Tests.IntegratedTests { const string userUrl = "users/user1/timeline/posts"; const string adminUrl = "users/admin/timeline/posts"; - { + {
+
using var client = await CreateClientAsUser(); - var res = await client.PatchAsync("users/user1/timeline", - new StringContent(@"{""visibility"":""abcdefg""}", System.Text.Encoding.UTF8, System.Net.Mime.MediaTypeNames.Application.Json)); + using var content = new StringContent(@"{""visibility"":""abcdefg""}", System.Text.Encoding.UTF8, System.Net.Mime.MediaTypeNames.Application.Json); + var res = await client.PatchAsync("users/user1/timeline", content); res.Should().BeInvalidModel(); } { // default visibility is registered |