aboutsummaryrefslogtreecommitdiff
path: root/BackEnd
diff options
context:
space:
mode:
Diffstat (limited to 'BackEnd')
-rw-r--r--BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs80
-rw-r--r--BackEnd/Timeline/Services/Api/TimelineBookmarkService1.cs2
2 files changed, 78 insertions, 4 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs b/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs
index fbf7e2c8..169bc4e6 100644
--- a/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs
+++ b/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs
@@ -2,6 +2,8 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
+using FluentAssertions;
+using Timeline.Models;
using Timeline.Models.Http;
using Xunit;
using Xunit.Abstractions;
@@ -58,7 +60,30 @@ namespace Timeline.Tests.IntegratedTests2
}
[Fact]
- public async Task DeleteNotExist()
+ public async Task MoveTest()
+ {
+ using var client = CreateClientAsUser();
+ var a = await client.TestJsonSendAsync<TimelineBookmark>(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ Position = 2
+ });
+ a.Position.Should().Be(2);
+
+ var b = await client.TestJsonSendAsync<TimelineBookmark>(HttpMethod.Get, "v2/users/user/bookmarks/2");
+ b.TimelineOwner.Should().Be("user");
+ b.TimelineName.Should().Be("hello");
+
+ await client.TestJsonSendAsync<TimelineBookmark>(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ }, expectedStatusCode: HttpStatusCode.UnprocessableEntity);
+ }
+
+ [Fact]
+ public async Task DeleteMoveNotExist()
{
using var client = CreateClientAsUser();
@@ -73,10 +98,25 @@ namespace Timeline.Tests.IntegratedTests2
TimelineOwner = "user",
TimelineName = "notexist"
}, expectedStatusCode: HttpStatusCode.UnprocessableEntity);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "notexist",
+ TimelineName = "hello",
+ Position = 2
+
+ }, expectedStatusCode: HttpStatusCode.UnprocessableEntity);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "notexist",
+ Position = 2
+ }, expectedStatusCode: HttpStatusCode.UnprocessableEntity);
}
[Fact]
- public async Task DeleteNotLogin()
+ public async Task DeleteMoveNotLogin()
{
using var client = CreateDefaultClient();
await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/delete", new HttpTimelinebookmarkDeleteRequest
@@ -84,10 +124,17 @@ namespace Timeline.Tests.IntegratedTests2
TimelineOwner = "user",
TimelineName = "hello"
}, expectedStatusCode: HttpStatusCode.Unauthorized);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ Position = 2
+ }, expectedStatusCode: HttpStatusCode.Unauthorized);
}
[Fact]
- public async Task DeleteForbid()
+ public async Task DeleteMoveForbid()
{
await CreateUserAsync("user2", "user2pw");
using var client = CreateClientWithToken(await CreateTokenWithCredentialAsync("user2", "user2pw"));
@@ -96,6 +143,13 @@ namespace Timeline.Tests.IntegratedTests2
TimelineOwner = "user",
TimelineName = "hello"
}, expectedStatusCode: HttpStatusCode.Forbidden);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ Position = 2
+ }, expectedStatusCode: HttpStatusCode.Forbidden);
}
[Fact]
@@ -114,6 +168,26 @@ namespace Timeline.Tests.IntegratedTests2
TimelineName = "hello"
}, expectedStatusCode: HttpStatusCode.NotFound);
}
+
+ [Fact]
+ public async Task MoveAdmin()
+ {
+ using var client = CreateClientAsAdmin();
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ Position = 2
+ }, expectedStatusCode: HttpStatusCode.OK);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/notexist/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ Position = 2
+ }, expectedStatusCode: HttpStatusCode.NotFound);
+
+ }
}
}
diff --git a/BackEnd/Timeline/Services/Api/TimelineBookmarkService1.cs b/BackEnd/Timeline/Services/Api/TimelineBookmarkService1.cs
index 4b52d61c..648ea9ff 100644
--- a/BackEnd/Timeline/Services/Api/TimelineBookmarkService1.cs
+++ b/BackEnd/Timeline/Services/Api/TimelineBookmarkService1.cs
@@ -205,7 +205,7 @@ namespace Timeline.Services.Api
await transaction.CommitAsync();
}
- return new TimelineBookmark(user.Username, timeline.Name is null ? "self" : timeline.Name, (int)entity.Rank);
+ return new TimelineBookmark(user.Username, timeline.Name is null ? "self" : timeline.Name, position);
}
public async Task SetBookmarkVisibilityAsync(long userId, TimelineVisibility visibility)