aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest.cs')
-rw-r--r--BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest.cs105
1 files changed, 101 insertions, 4 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest.cs b/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest.cs
index fcf69364..903175c3 100644
--- a/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest.cs
+++ b/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest.cs
@@ -23,14 +23,13 @@ namespace Timeline.Tests.IntegratedTests2
{
Name = "hello"
}, expectedStatusCode: HttpStatusCode.Created);
-
}
[Fact]
- public async Task CreateAndGet()
+ public async Task CreateGetList()
{
using var client = CreateClientAsUser();
- var a = await client.TestJsonSendAsync<TimelineBookmark>(HttpMethod.Post, "users/user/bookmarks", new HttpTimelineBookmarkCreateRequest
+ var a = await client.TestJsonSendAsync<TimelineBookmark>(HttpMethod.Post, "v2/users/user/bookmarks", new HttpTimelineBookmarkCreateRequest
{
TimelineOwner = "user",
TimelineName = "hello"
@@ -40,10 +39,108 @@ namespace Timeline.Tests.IntegratedTests2
a.TimelineName.Should().Be("hello");
a.Position.Should().Be(1);
- var b = await client.TestJsonSendAsync<TimelineBookmark>(HttpMethod.Get, "users/user/bookmarks/1");
+ var b = await client.TestJsonSendAsync<TimelineBookmark>(HttpMethod.Get, "v2/users/user/bookmarks/1");
b.TimelineName.Should().Be("hello");
b.TimelineOwner.Should().Be("user");
b.Position.Should().Be(1);
+
+ var c = await client.TestJsonSendAsync<Page<TimelineBookmark>>(HttpMethod.Get, "v2/users/user/bookmarks");
+ c.TotalCount.Should().Be(1);
+ c.Items.Should().ContainSingle();
+ c.Items[0].TimelineOwner.Should().Be("user");
+ c.Items[0].TimelineName.Should().Be("hello");
+ c.Items[0].Position.Should().Be(1);
+ }
+
+ [Fact]
+ public async Task ListGetNotExist()
+ {
+ using var client = CreateClientAsUser();
+
+ await client.TestJsonSendAsync(HttpMethod.Get, "v2/users/notexist/bookmarks", expectedStatusCode: HttpStatusCode.NotFound);
+ await client.TestJsonSendAsync(HttpMethod.Get, "v2/users/notexist/bookmarks/1", expectedStatusCode: HttpStatusCode.NotFound);
+ }
+
+ [Fact]
+ public async Task CreateUserNotExist()
+ {
+ using var client = CreateClientAsUser();
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/notexist/bookmarks", new HttpTimelineBookmarkCreateRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello"
+ }, expectedStatusCode: HttpStatusCode.NotFound);
+ }
+
+ [Fact]
+ public async Task CreateTimelineNotExist()
+ {
+ using var client = CreateClientAsUser();
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks", new HttpTimelineBookmarkCreateRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "notexist"
+ }, expectedStatusCode: HttpStatusCode.UnprocessableEntity);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks", new HttpTimelineBookmarkCreateRequest
+ {
+ TimelineOwner = "notexist",
+ TimelineName = "notexist"
+ }, expectedStatusCode: HttpStatusCode.UnprocessableEntity);
+ }
+
+ [Fact]
+ public async Task CreateAlreadyExist()
+ {
+ using var client = CreateClientAsUser();
+
+ await client.TestJsonSendAsync<TimelineBookmark>(HttpMethod.Post, "v2/users/user/bookmarks", new HttpTimelineBookmarkCreateRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello"
+ }, expectedStatusCode: HttpStatusCode.Created);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks", new HttpTimelineBookmarkCreateRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello"
+ }, expectedStatusCode: HttpStatusCode.UnprocessableEntity);
+ }
+
+ [Fact]
+ public async Task AnonymousCreateUnauthorized()
+ {
+ using var client = CreateDefaultClient();
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks", new HttpTimelineBookmarkCreateRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello"
+ }, expectedStatusCode: HttpStatusCode.Unauthorized);
+ }
+
+ [Fact]
+ public async Task OtherCreateForbid()
+ {
+ using var client = CreateClientAsUser();
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/admin/bookmarks", new HttpTimelineBookmarkCreateRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello"
+ }, expectedStatusCode: HttpStatusCode.Forbidden);
+ }
+
+ [Fact]
+ public async Task AdminCanCreate()
+ {
+ using var client = CreateClientAsAdmin();
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks", new HttpTimelineBookmarkCreateRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello"
+ });
}
}
}