diff options
Diffstat (limited to 'BackEnd/Timeline.Tests/IntegratedTests')
6 files changed, 128 insertions, 128 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/HttpClientTimelineExtensions.cs b/BackEnd/Timeline.Tests/IntegratedTests/HttpClientTimelineExtensions.cs index 8e48ccbf..ac60ce7c 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/HttpClientTimelineExtensions.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/HttpClientTimelineExtensions.cs @@ -6,11 +6,11 @@ namespace Timeline.Tests.IntegratedTests {
public static class HttpClientTimelineExtensions
{
- public static Task<TimelineInfo> GetTimelineAsync(this HttpClient client, string timelineName)
- => client.TestGetAsync<TimelineInfo>($"timelines/{timelineName}");
+ public static Task<HttpTimeline> GetTimelineAsync(this HttpClient client, string timelineName)
+ => client.TestGetAsync<HttpTimeline>($"timelines/{timelineName}");
- public static Task<TimelineInfo> PatchTimelineAsync(this HttpClient client, string timelineName, TimelinePatchRequest body)
- => client.TestPatchAsync<TimelineInfo>($"timelines/{timelineName}", body);
+ public static Task<HttpTimeline> PatchTimelineAsync(this HttpClient client, string timelineName, HttpTimelinePatchRequest body)
+ => client.TestPatchAsync<HttpTimeline>($"timelines/{timelineName}", body);
public static Task PutTimelineMemberAsync(this HttpClient client, string timelineName, string memberUsername)
=> client.TestPutAsync($"timelines/{timelineName}/members/{memberUsername}");
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/HttpClientUserExtensions.cs b/BackEnd/Timeline.Tests/IntegratedTests/HttpClientUserExtensions.cs index 81787eef..7ca62e38 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/HttpClientUserExtensions.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/HttpClientUserExtensions.cs @@ -6,7 +6,7 @@ namespace Timeline.Tests.IntegratedTests {
public static class HttpClientUserExtensions
{
- public static Task<UserInfo> GetUserAsync(this HttpClient client, string username)
- => client.TestGetAsync<UserInfo>($"users/{username}");
+ public static Task<HttpUser> GetUserAsync(this HttpClient client, string username)
+ => client.TestGetAsync<HttpUser>($"users/{username}");
}
}
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs b/BackEnd/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs index e426ac98..82aed24e 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs @@ -103,8 +103,8 @@ namespace Timeline.Tests.IntegratedTests public async Task<HttpClient> CreateClientWithCredential(string username, string password, bool setApiBase = true)
{
var client = await CreateDefaultClient(setApiBase);
- var res = await client.TestPostAsync<CreateTokenResponse>("token/create",
- new CreateTokenRequest { Username = username, Password = password });
+ var res = await client.TestPostAsync<HttpCreateTokenResponse>("token/create",
+ new HttpCreateTokenRequest { Username = username, Password = password });
var token = res.Token;
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
return client;
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/TimelineTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/TimelineTest.cs index 9845e1b1..12dd2b8d 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/TimelineTest.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/TimelineTest.cs @@ -19,20 +19,20 @@ namespace Timeline.Tests.IntegratedTests {
public static class TimelineHelper
{
- public static TimelinePostContentInfo TextPostContent(string text)
+ public static HttpTimelinePostContent TextPostContent(string text)
{
- return new TimelinePostContentInfo
+ return new HttpTimelinePostContent
{
Type = "text",
Text = text
};
}
- public static TimelinePostCreateRequest TextPostCreateRequest(string text, DateTime? time = null)
+ public static HttpTimelinePostCreateRequest TextPostCreateRequest(string text, DateTime? time = null)
{
- return new TimelinePostCreateRequest
+ return new HttpTimelinePostCreateRequest
{
- Content = new TimelinePostCreateRequestContent
+ Content = new HttpTimelinePostCreateRequestContent
{
Type = "text",
Text = text
@@ -72,7 +72,7 @@ namespace Timeline.Tests.IntegratedTests {
- var body = await client.TestGetAsync<TimelineInfo>("timelines/@user1");
+ var body = await client.TestGetAsync<HttpTimeline>("timelines/@user1");
body.Owner.Should().BeEquivalentTo(await client.GetUserAsync("user1"));
body.Visibility.Should().Be(TimelineVisibility.Register);
body.Description.Should().Be("");
@@ -84,7 +84,7 @@ namespace Timeline.Tests.IntegratedTests }
{
- var body = await client.TestGetAsync<TimelineInfo>("timelines/t1");
+ var body = await client.TestGetAsync<HttpTimeline>("timelines/t1");
body.Owner.Should().BeEquivalentTo(await client.GetUserAsync("user1"));
body.Visibility.Should().Be(TimelineVisibility.Register);
body.Description.Should().Be("");
@@ -101,7 +101,7 @@ namespace Timeline.Tests.IntegratedTests {
using var client = await CreateDefaultClient();
- var result = new List<TimelineInfo>
+ var result = new List<HttpTimeline>
{
await client.GetTimelineAsync("@user1")
};
@@ -112,7 +112,7 @@ namespace Timeline.Tests.IntegratedTests }
- var body = await client.TestGetAsync<List<TimelineInfo>>("timelines");
+ var body = await client.TestGetAsync<List<HttpTimeline>>("timelines");
body.Should().BeEquivalentTo(result);
}
@@ -127,14 +127,14 @@ namespace Timeline.Tests.IntegratedTests await client.TestGetAssertInvalidModelAsync("timelines?visibility=aaa");
}
- var testResultRelate = new List<TimelineInfo>();
- var testResultOwn = new List<TimelineInfo>();
- var testResultJoin = new List<TimelineInfo>();
- var testResultOwnPrivate = new List<TimelineInfo>();
- var testResultRelatePublic = new List<TimelineInfo>();
- var testResultRelateRegister = new List<TimelineInfo>();
- var testResultJoinPrivate = new List<TimelineInfo>();
- var testResultPublic = new List<TimelineInfo>();
+ var testResultRelate = new List<HttpTimeline>();
+ var testResultOwn = new List<HttpTimeline>();
+ var testResultJoin = new List<HttpTimeline>();
+ var testResultOwnPrivate = new List<HttpTimeline>();
+ var testResultRelatePublic = new List<HttpTimeline>();
+ var testResultRelateRegister = new List<HttpTimeline>();
+ var testResultJoinPrivate = new List<HttpTimeline>();
+ var testResultPublic = new List<HttpTimeline>();
{
using var client = await CreateClientAsUser();
@@ -185,8 +185,8 @@ namespace Timeline.Tests.IntegratedTests {
using var client = await CreateClientAs(3);
- await client.PatchTimelineAsync("@user3", new TimelinePatchRequest { Visibility = TimelineVisibility.Private });
- await client.PatchTimelineAsync("t3", new TimelinePatchRequest { Visibility = TimelineVisibility.Register });
+ await client.PatchTimelineAsync("@user3", new HttpTimelinePatchRequest { Visibility = TimelineVisibility.Private });
+ await client.PatchTimelineAsync("t3", new HttpTimelinePatchRequest { Visibility = TimelineVisibility.Register });
{
var timeline = await client.GetTimelineAsync("@user3");
@@ -206,9 +206,9 @@ namespace Timeline.Tests.IntegratedTests {
using var client = await CreateDefaultClient();
- async Task TestAgainst(string url, List<TimelineInfo> against)
+ async Task TestAgainst(string url, List<HttpTimeline> against)
{
- var body = await client.TestGetAsync<List<TimelineInfo>>(url);
+ var body = await client.TestGetAsync<List<HttpTimeline>>(url);
body.Should().BeEquivalentTo(against);
}
@@ -236,7 +236,7 @@ namespace Timeline.Tests.IntegratedTests await client.TestPostAssertInvalidModelAsync("timelines", new TimelineCreateRequest { Name = "!!!" });
{
- var body = await client.TestPostAsync<TimelineInfo>("timelines", new TimelineCreateRequest { Name = "aaa" });
+ var body = await client.TestPostAsync<HttpTimeline>("timelines", new TimelineCreateRequest { Name = "aaa" });
body.Should().BeEquivalentTo(await client.GetTimelineAsync("aaa"));
}
@@ -342,7 +342,7 @@ namespace Timeline.Tests.IntegratedTests var timelineName = generator(1);
- async Task AssertMembers(List<UserInfo> members)
+ async Task AssertMembers(List<HttpUser> members)
{
var body = await client.GetTimelineAsync(timelineName);
body.Members.Should().NotBeNull().And.BeEquivalentTo(members);
@@ -358,7 +358,7 @@ namespace Timeline.Tests.IntegratedTests await client.TestPutAssertErrorAsync($"timelines/{timelineName}/members/usernotexist", errorCode: ErrorCodes.TimelineController.MemberPut_NotExist);
await AssertEmptyMembers();
await client.PutTimelineMemberAsync(timelineName, "user2");
- await AssertMembers(new List<UserInfo> { await client.GetUserAsync("user2") });
+ await AssertMembers(new List<HttpUser> { await client.GetUserAsync("user2") });
await client.DeleteTimelineMemberAsync(timelineName, "user2", true);
await AssertEmptyMembers();
await client.DeleteTimelineMemberAsync(timelineName, "aaa", false);
@@ -462,7 +462,7 @@ namespace Timeline.Tests.IntegratedTests async Task<long> CreatePost(int userNumber)
{
using var client = await CreateClientAs(userNumber);
- var body = await client.TestPostAsync<TimelinePostInfo>($"timelines/{generator(1)}/posts", TimelineHelper.TextPostCreateRequest("aaa"));
+ var body = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", TimelineHelper.TextPostCreateRequest("aaa"));
return body.Id;
}
@@ -515,28 +515,28 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateClientAsUser();
{
- var body = await client.TestGetAsync<List<TimelinePostInfo>>($"timelines/{generator(1)}/posts");
+ var body = await client.TestGetAsync<List<HttpTimelinePost>>($"timelines/{generator(1)}/posts");
body.Should().BeEmpty();
}
const string mockContent = "aaa";
- TimelinePostInfo createRes;
+ HttpTimelinePost createRes;
{
- var body = await client.TestPostAsync<TimelinePostInfo>($"timelines/{generator(1)}/posts", TimelineHelper.TextPostCreateRequest(mockContent));
+ var body = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", TimelineHelper.TextPostCreateRequest(mockContent));
body.Content.Should().BeEquivalentTo(TimelineHelper.TextPostContent(mockContent));
body.Author.Should().BeEquivalentTo(await client.GetUserAsync("user1"));
body.Deleted.Should().BeFalse();
createRes = body;
}
{
- var body = await client.TestGetAsync<List<TimelinePostInfo>>($"timelines/{generator(1)}/posts");
+ var body = await client.TestGetAsync<List<HttpTimelinePost>>($"timelines/{generator(1)}/posts");
body.Should().BeEquivalentTo(createRes);
}
const string mockContent2 = "bbb";
var mockTime2 = DateTime.UtcNow.AddDays(-1);
- TimelinePostInfo createRes2;
+ HttpTimelinePost createRes2;
{
- var body = await client.TestPostAsync<TimelinePostInfo>($"timelines/{generator(1)}/posts", TimelineHelper.TextPostCreateRequest(mockContent2, mockTime2));
+ var body = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", TimelineHelper.TextPostCreateRequest(mockContent2, mockTime2));
body.Should().NotBeNull();
body.Content.Should().BeEquivalentTo(TimelineHelper.TextPostContent(mockContent2));
body.Author.Should().BeEquivalentTo(await client.GetUserAsync("user1"));
@@ -545,7 +545,7 @@ namespace Timeline.Tests.IntegratedTests createRes2 = body;
}
{
- var body = await client.TestGetAsync<List<TimelinePostInfo>>($"timelines/{generator(1)}/posts");
+ var body = await client.TestGetAsync<List<HttpTimelinePost>>($"timelines/{generator(1)}/posts");
body.Should().BeEquivalentTo(createRes, createRes2);
}
{
@@ -554,7 +554,7 @@ namespace Timeline.Tests.IntegratedTests await client.TestDeleteAsync($"timelines/{generator(1)}/posts/30000", false);
}
{
- var body = await client.TestGetAsync<List<TimelinePostInfo>>($"timelines/{generator(1)}/posts");
+ var body = await client.TestGetAsync<List<HttpTimelinePost>>($"timelines/{generator(1)}/posts");
body.Should().BeEquivalentTo(createRes2);
}
}
@@ -567,7 +567,7 @@ namespace Timeline.Tests.IntegratedTests async Task<long> CreatePost(DateTime time)
{
- var body = await client.TestPostAsync<TimelinePostInfo>($"timelines/{generator(1)}/posts", TimelineHelper.TextPostCreateRequest("aaa", time));
+ var body = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", TimelineHelper.TextPostCreateRequest("aaa", time));
return body.Id;
}
@@ -577,7 +577,7 @@ namespace Timeline.Tests.IntegratedTests var id2 = await CreatePost(now);
{
- var body = await client.TestGetAsync<List<TimelinePostInfo>>($"timelines/{generator(1)}/posts");
+ var body = await client.TestGetAsync<List<HttpTimelinePost>>($"timelines/{generator(1)}/posts");
body.Select(p => p.Id).Should().Equal(id1, id2, id0);
}
}
@@ -588,15 +588,15 @@ namespace Timeline.Tests.IntegratedTests {
using var client = await CreateClientAsUser();
var postUrl = $"timelines/{generator(1)}/posts";
- await client.TestPostAssertInvalidModelAsync(postUrl, new TimelinePostCreateRequest { Content = null! });
- await client.TestPostAssertInvalidModelAsync(postUrl, new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = null! } });
- await client.TestPostAssertInvalidModelAsync(postUrl, new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = "hahaha" } });
- await client.TestPostAssertInvalidModelAsync(postUrl, new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = "text", Text = null } });
- await client.TestPostAssertInvalidModelAsync(postUrl, new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = "image", Data = null } });
+ await client.TestPostAssertInvalidModelAsync(postUrl, new HttpTimelinePostCreateRequest { Content = null! });
+ await client.TestPostAssertInvalidModelAsync(postUrl, new HttpTimelinePostCreateRequest { Content = new HttpTimelinePostCreateRequestContent { Type = null! } });
+ await client.TestPostAssertInvalidModelAsync(postUrl, new HttpTimelinePostCreateRequest { Content = new HttpTimelinePostCreateRequestContent { Type = "hahaha" } });
+ await client.TestPostAssertInvalidModelAsync(postUrl, new HttpTimelinePostCreateRequest { Content = new HttpTimelinePostCreateRequestContent { Type = "text", Text = null } });
+ await client.TestPostAssertInvalidModelAsync(postUrl, new HttpTimelinePostCreateRequest { Content = new HttpTimelinePostCreateRequestContent { Type = "image", Data = null } });
// image not base64
- await client.TestPostAssertInvalidModelAsync(postUrl, new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = "image", Data = "!!!" } });
+ await client.TestPostAssertInvalidModelAsync(postUrl, new HttpTimelinePostCreateRequest { Content = new HttpTimelinePostCreateRequestContent { Type = "image", Data = "!!!" } });
// image base64 not image
- await client.TestPostAssertInvalidModelAsync(postUrl, new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = "image", Data = Convert.ToBase64String(new byte[] { 0x01, 0x02, 0x03 }) } });
+ await client.TestPostAssertInvalidModelAsync(postUrl, new HttpTimelinePostCreateRequest { Content = new HttpTimelinePostCreateRequestContent { Type = "image", Data = Convert.ToBase64String(new byte[] { 0x01, 0x02, 0x03 }) } });
}
[Theory]
@@ -608,7 +608,7 @@ namespace Timeline.Tests.IntegratedTests long postId;
string postImageUrl;
- void AssertPostContent(TimelinePostContentInfo content)
+ void AssertPostContent(HttpTimelinePostContent content)
{
content.Type.Should().Be(TimelinePostContentTypes.Image);
content.Url.Should().EndWith($"timelines/{generator(1)}/posts/{postId}/data");
@@ -618,10 +618,10 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateClientAsUser();
{
- var body = await client.TestPostAsync<TimelinePostInfo>($"timelines/{generator(1)}/posts",
- new TimelinePostCreateRequest
+ var body = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts",
+ new HttpTimelinePostCreateRequest
{
- Content = new TimelinePostCreateRequestContent
+ Content = new HttpTimelinePostCreateRequestContent
{
Type = TimelinePostContentTypes.Image,
Data = Convert.ToBase64String(imageData)
@@ -633,7 +633,7 @@ namespace Timeline.Tests.IntegratedTests }
{
- var body = await client.TestGetAsync<List<TimelinePostInfo>>($"timelines/{generator(1)}/posts");
+ var body = await client.TestGetAsync<List<HttpTimelinePost>>($"timelines/{generator(1)}/posts");
body.Should().HaveCount(1);
var post = body[0];
post.Id.Should().Be(postId);
@@ -655,7 +655,7 @@ namespace Timeline.Tests.IntegratedTests await client.TestDeleteAsync($"timelines/{generator(1)}/posts/{postId}", false);
{
- var body = await client.TestGetAsync<List<TimelinePostInfo>>($"timelines/{generator(1)}/posts");
+ var body = await client.TestGetAsync<List<HttpTimelinePost>>($"timelines/{generator(1)}/posts");
body.Should().BeEmpty();
}
@@ -677,7 +677,7 @@ namespace Timeline.Tests.IntegratedTests long postId;
{
- var body = await client.TestPostAsync<TimelinePostInfo>($"timelines/{generator(1)}/posts", TimelineHelper.TextPostCreateRequest("aaa"));
+ var body = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", TimelineHelper.TextPostCreateRequest("aaa"));
postId = body.Id;
}
@@ -726,12 +726,12 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateClientAsUser();
var postContentList = new List<string> { "a", "b", "c", "d" };
- var posts = new List<TimelinePostInfo>();
+ var posts = new List<HttpTimelinePost>();
foreach (var content in postContentList)
{
- var post = await client.TestPostAsync<TimelinePostInfo>($"timelines/{generator(1)}/posts",
- new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Text = content, Type = TimelinePostContentTypes.Text } });
+ var post = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts",
+ new HttpTimelinePostCreateRequest { Content = new HttpTimelinePostCreateRequestContent { Text = content, Type = TimelinePostContentTypes.Text } });
posts.Add(post);
await Task.Delay(1000);
}
@@ -739,7 +739,7 @@ namespace Timeline.Tests.IntegratedTests await client.TestDeleteAsync($"timelines/{generator(1)}/posts/{posts[2].Id}", true);
{
- var body = await client.TestGetAsync<List<TimelinePostInfo>>($"timelines/{generator(1)}/posts?modifiedSince={posts[1].LastUpdated.ToString("s", CultureInfo.InvariantCulture) }");
+ var body = await client.TestGetAsync<List<HttpTimelinePost>>($"timelines/{generator(1)}/posts?modifiedSince={posts[1].LastUpdated.ToString("s", CultureInfo.InvariantCulture) }");
body.Should().HaveCount(2)
.And.Subject.Select(p => p.Content!.Text).Should().Equal("b", "d");
}
@@ -752,12 +752,12 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateClientAsUser();
var postContentList = new List<string> { "a", "b", "c", "d" };
- var posts = new List<TimelinePostInfo>();
+ var posts = new List<HttpTimelinePost>();
foreach (var content in postContentList)
{
- var body = await client.TestPostAsync<TimelinePostInfo>($"timelines/{generator(1)}/posts",
- new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Text = content, Type = TimelinePostContentTypes.Text } });
+ var body = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts",
+ new HttpTimelinePostCreateRequest { Content = new HttpTimelinePostCreateRequestContent { Text = content, Type = TimelinePostContentTypes.Text } });
posts.Add(body);
}
@@ -767,7 +767,7 @@ namespace Timeline.Tests.IntegratedTests }
{
- posts = await client.TestGetAsync<List<TimelinePostInfo>>($"timelines/{generator(1)}/posts?includeDeleted=true");
+ posts = await client.TestGetAsync<List<HttpTimelinePost>>($"timelines/{generator(1)}/posts?includeDeleted=true");
posts.Should().HaveCount(4);
posts.Select(p => p.Deleted).Should().Equal(true, false, true, false);
posts.Select(p => p.Content == null).Should().Equal(true, false, true, false);
@@ -781,12 +781,12 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateClientAsUser();
var postContentList = new List<string> { "a", "b", "c", "d" };
- var posts = new List<TimelinePostInfo>();
+ var posts = new List<HttpTimelinePost>();
foreach (var (content, index) in postContentList.Select((v, i) => (v, i)))
{
- var post = await client.TestPostAsync<TimelinePostInfo>($"timelines/{generator(1)}/posts",
- new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Text = content, Type = TimelinePostContentTypes.Text } });
+ var post = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts",
+ new HttpTimelinePostCreateRequest { Content = new HttpTimelinePostCreateRequestContent { Text = content, Type = TimelinePostContentTypes.Text } });
posts.Add(post);
await Task.Delay(1000);
}
@@ -795,7 +795,7 @@ namespace Timeline.Tests.IntegratedTests {
- posts = await client.TestGetAsync<List<TimelinePostInfo>>($"timelines/{generator(1)}/posts?modifiedSince={posts[1].LastUpdated.ToString("s", CultureInfo.InvariantCulture)}&includeDeleted=true");
+ posts = await client.TestGetAsync<List<HttpTimelinePost>>($"timelines/{generator(1)}/posts?modifiedSince={posts[1].LastUpdated.ToString("s", CultureInfo.InvariantCulture)}&includeDeleted=true");
posts.Should().HaveCount(3);
posts.Select(p => p.Deleted).Should().Equal(false, true, false);
posts.Select(p => p.Content == null).Should().Equal(false, true, false);
@@ -809,7 +809,7 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateClientAsUser();
DateTime lastModifiedTime;
- TimelineInfo timeline;
+ HttpTimeline timeline;
string uniqueId;
{
@@ -830,7 +830,7 @@ namespace Timeline.Tests.IntegratedTests {
- var body = await client.TestGetAsync<TimelineInfo>($"timelines/{generator(1)}",
+ var body = await client.TestGetAsync<HttpTimeline>($"timelines/{generator(1)}",
headerSetup: (headers, _) =>
{
headers.IfModifiedSince = lastModifiedTime.AddSeconds(-1);
@@ -843,7 +843,7 @@ namespace Timeline.Tests.IntegratedTests }
{
- var body = await client.TestGetAsync<TimelineInfo>($"timelines/{generator(1)}?ifModifiedSince={lastModifiedTime.AddSeconds(-1).ToString("s", CultureInfo.InvariantCulture) }");
+ var body = await client.TestGetAsync<HttpTimeline>($"timelines/{generator(1)}?ifModifiedSince={lastModifiedTime.AddSeconds(-1).ToString("s", CultureInfo.InvariantCulture) }");
body.Should().BeEquivalentTo(timeline);
}
@@ -853,7 +853,7 @@ namespace Timeline.Tests.IntegratedTests {
var testUniqueId = (uniqueId[0] == 'a' ? "b" : "a") + uniqueId[1..];
- var body = await client.TestGetAsync<TimelineInfo>($"timelines/{generator(1)}?ifModifiedSince={lastModifiedTime.AddSeconds(1).ToString("s", CultureInfo.InvariantCulture) }&checkUniqueId={testUniqueId}");
+ var body = await client.TestGetAsync<HttpTimeline>($"timelines/{generator(1)}?ifModifiedSince={lastModifiedTime.AddSeconds(1).ToString("s", CultureInfo.InvariantCulture) }&checkUniqueId={testUniqueId}");
body.Should().BeEquivalentTo(timeline);
}
}
@@ -870,7 +870,7 @@ namespace Timeline.Tests.IntegratedTests }
{
- var body = await client.PatchTimelineAsync(generator(1), new TimelinePatchRequest { Title = "atitle" });
+ var body = await client.PatchTimelineAsync(generator(1), new HttpTimelinePatchRequest { Title = "atitle" });
body.Title.Should().Be("atitle");
}
@@ -885,26 +885,26 @@ namespace Timeline.Tests.IntegratedTests {
{
using var client = await CreateDefaultClient();
- await client.TestPostAssertUnauthorizedAsync("timelineop/changename", new TimelineChangeNameRequest { OldName = "t1", NewName = "tttttttt" });
+ await client.TestPostAssertUnauthorizedAsync("timelineop/changename", new HttpTimelineChangeNameRequest { OldName = "t1", NewName = "tttttttt" });
}
{
using var client = await CreateClientAs(2);
- await client.TestPostAssertForbiddenAsync("timelineop/changename", new TimelineChangeNameRequest { OldName = "t1", NewName = "tttttttt" });
+ await client.TestPostAssertForbiddenAsync("timelineop/changename", new HttpTimelineChangeNameRequest { OldName = "t1", NewName = "tttttttt" });
}
using (var client = await CreateClientAsUser())
{
- await client.TestPostAssertInvalidModelAsync("timelineop/changename", new TimelineChangeNameRequest { OldName = "!!!", NewName = "tttttttt" });
- await client.TestPostAssertInvalidModelAsync("timelineop/changename", new TimelineChangeNameRequest { OldName = "ttt", NewName = "!!!!" });
- await client.TestPostAssertErrorAsync("timelineop/changename", new TimelineChangeNameRequest { OldName = "ttttt", NewName = "tttttttt" }, errorCode: ErrorCodes.TimelineController.NotExist);
+ await client.TestPostAssertInvalidModelAsync("timelineop/changename", new HttpTimelineChangeNameRequest { OldName = "!!!", NewName = "tttttttt" });
+ await client.TestPostAssertInvalidModelAsync("timelineop/changename", new HttpTimelineChangeNameRequest { OldName = "ttt", NewName = "!!!!" });
+ await client.TestPostAssertErrorAsync("timelineop/changename", new HttpTimelineChangeNameRequest { OldName = "ttttt", NewName = "tttttttt" }, errorCode: ErrorCodes.TimelineController.NotExist);
- await client.TestPostAsync("timelineop/changename", new TimelineChangeNameRequest { OldName = "t1", NewName = "newt" });
+ await client.TestPostAsync("timelineop/changename", new HttpTimelineChangeNameRequest { OldName = "t1", NewName = "newt" });
await client.TestGetAsync("timelines/t1", expectedStatusCode: HttpStatusCode.NotFound);
{
- var body = await client.TestGetAsync<TimelineInfo>("timelines/newt");
+ var body = await client.TestGetAsync<HttpTimeline>("timelines/newt");
body.Name.Should().Be("newt");
}
}
@@ -920,9 +920,9 @@ namespace Timeline.Tests.IntegratedTests string etag;
{
- var body = await client.TestPostAsync<TimelinePostInfo>($"timelines/{generator(1)}/posts", new TimelinePostCreateRequest
+ var body = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", new HttpTimelinePostCreateRequest
{
- Content = new TimelinePostCreateRequestContent
+ Content = new HttpTimelinePostCreateRequestContent
{
Type = TimelinePostContentTypes.Image,
Data = Convert.ToBase64String(ImageHelper.CreatePngWithSize(100, 50))
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs index a5208618..fdf1af99 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs @@ -14,9 +14,9 @@ namespace Timeline.Tests.IntegratedTests private const string CreateTokenUrl = "token/create";
private const string VerifyTokenUrl = "token/verify";
- private static async Task<CreateTokenResponse> CreateUserTokenAsync(HttpClient client, string username, string password, int? expireOffset = null)
+ private static async Task<HttpCreateTokenResponse> CreateUserTokenAsync(HttpClient client, string username, string password, int? expireOffset = null)
{
- return await client.TestPostAsync<CreateTokenResponse>(CreateTokenUrl, new CreateTokenRequest { Username = username, Password = password, Expire = expireOffset });
+ return await client.TestPostAsync<HttpCreateTokenResponse>(CreateTokenUrl, new HttpCreateTokenRequest { Username = username, Password = password, Expire = expireOffset });
}
public static IEnumerable<object?[]> CreateToken_InvalidModel_Data()
@@ -32,7 +32,7 @@ namespace Timeline.Tests.IntegratedTests public async Task CreateToken_InvalidModel(string username, string password, int expire)
{
using var client = await CreateDefaultClient();
- await client.TestPostAssertInvalidModelAsync(CreateTokenUrl, new CreateTokenRequest
+ await client.TestPostAssertInvalidModelAsync(CreateTokenUrl, new HttpCreateTokenRequest
{
Username = username,
Password = password,
@@ -52,7 +52,7 @@ namespace Timeline.Tests.IntegratedTests {
using var client = await CreateDefaultClient();
await client.TestPostAssertErrorAsync(CreateTokenUrl,
- new CreateTokenRequest { Username = username, Password = password },
+ new HttpCreateTokenRequest { Username = username, Password = password },
errorCode: ErrorCodes.TokenController.Create_BadCredential);
}
@@ -60,8 +60,8 @@ namespace Timeline.Tests.IntegratedTests public async Task CreateToken_Success()
{
using var client = await CreateDefaultClient();
- var body = await client.TestPostAsync<CreateTokenResponse>(CreateTokenUrl,
- new CreateTokenRequest { Username = "user1", Password = "user1pw" });
+ var body = await client.TestPostAsync<HttpCreateTokenResponse>(CreateTokenUrl,
+ new HttpCreateTokenRequest { Username = "user1", Password = "user1pw" });
body.Token.Should().NotBeNullOrWhiteSpace();
body.User.Should().BeEquivalentTo(await client.GetUserAsync("user1"));
}
@@ -70,7 +70,7 @@ namespace Timeline.Tests.IntegratedTests public async Task VerifyToken_InvalidModel()
{
using var client = await CreateDefaultClient();
- await client.TestPostAssertInvalidModelAsync(VerifyTokenUrl, new VerifyTokenRequest { Token = null! });
+ await client.TestPostAssertInvalidModelAsync(VerifyTokenUrl, new HttpVerifyTokenRequest { Token = null! });
}
[Fact]
@@ -78,7 +78,7 @@ namespace Timeline.Tests.IntegratedTests {
using var client = await CreateDefaultClient();
await client.TestPostAssertErrorAsync(VerifyTokenUrl,
- new VerifyTokenRequest { Token = "bad token hahaha" },
+ new HttpVerifyTokenRequest { Token = "bad token hahaha" },
errorCode: ErrorCodes.TokenController.Verify_BadFormat);
}
@@ -97,7 +97,7 @@ namespace Timeline.Tests.IntegratedTests }
await client.TestPostAssertErrorAsync(VerifyTokenUrl,
- new VerifyTokenRequest { Token = token },
+ new HttpVerifyTokenRequest { Token = token },
errorCode: ErrorCodes.TokenController.Verify_OldVersion);
}
@@ -114,7 +114,7 @@ namespace Timeline.Tests.IntegratedTests }
await client.TestPostAssertErrorAsync(VerifyTokenUrl,
- new VerifyTokenRequest { Token = token },
+ new HttpVerifyTokenRequest { Token = token },
errorCode: ErrorCodes.TokenController.Verify_UserNotExist);
}
@@ -141,8 +141,8 @@ namespace Timeline.Tests.IntegratedTests {
using var client = await CreateDefaultClient();
var createTokenResult = await CreateUserTokenAsync(client, "user1", "user1pw");
- var body = await client.TestPostAsync<VerifyTokenResponse>(VerifyTokenUrl,
- new VerifyTokenRequest { Token = createTokenResult.Token });
+ var body = await client.TestPostAsync<HttpVerifyTokenResponse>(VerifyTokenUrl,
+ new HttpVerifyTokenRequest { Token = createTokenResult.Token });
body.User.Should().BeEquivalentTo(await client.GetUserAsync("user1"));
}
}
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs index e0ebf635..56dbf92a 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs @@ -12,7 +12,7 @@ namespace Timeline.Tests.IntegratedTests public async Task UserListShouldHaveUniqueId()
{
using var client = await CreateDefaultClient();
- foreach (var user in await client.TestGetAsync<List<UserInfo>>("users"))
+ foreach (var user in await client.TestGetAsync<List<HttpUser>>("users"))
{
user.UniqueId.Should().NotBeNullOrWhiteSpace();
}
@@ -22,14 +22,14 @@ namespace Timeline.Tests.IntegratedTests public async Task GetList()
{
using var client = await CreateDefaultClient();
- await client.TestGetAsync<List<UserInfo>>("users");
+ await client.TestGetAsync<List<HttpUser>>("users");
}
[Fact]
public async Task Get()
{
using var client = await CreateDefaultClient();
- var user = await client.TestGetAsync<UserInfo>($"users/admin");
+ var user = await client.TestGetAsync<HttpUser>($"users/admin");
user.Username.Should().Be("admin");
user.Nickname.Should().Be("administrator");
user.UniqueId.Should().NotBeNullOrEmpty();
@@ -55,8 +55,8 @@ namespace Timeline.Tests.IntegratedTests {
using var client = await CreateClientAsUser();
{
- var body = await client.TestPatchAsync<UserInfo>("users/user1",
- new UserPatchRequest { Nickname = "aaa" });
+ var body = await client.TestPatchAsync<HttpUser>("users/user1",
+ new HttpUserPatchRequest { Nickname = "aaa" });
body.Nickname.Should().Be("aaa");
}
@@ -73,8 +73,8 @@ namespace Timeline.Tests.IntegratedTests using var userClient = await CreateClientAsUser();
{
- var body = await client.TestPatchAsync<UserInfo>("users/user1",
- new UserPatchRequest
+ var body = await client.TestPatchAsync<HttpUser>("users/user1",
+ new HttpUserPatchRequest
{
Username = "newuser",
Password = "newpw",
@@ -91,7 +91,7 @@ namespace Timeline.Tests.IntegratedTests {
var token = userClient.DefaultRequestHeaders.Authorization!.Parameter!;
// Token should expire.
- await userClient.TestPostAssertErrorAsync("token/verify", new VerifyTokenRequest() { Token = token });
+ await userClient.TestPostAssertErrorAsync("token/verify", new HttpVerifyTokenRequest() { Token = token });
}
{
@@ -104,26 +104,26 @@ namespace Timeline.Tests.IntegratedTests public async Task Patch_NotExist()
{
using var client = await CreateClientAsAdministrator();
- await client.TestPatchAssertNotFoundAsync("users/usernotexist", new UserPatchRequest { }, errorCode: ErrorCodes.UserCommon.NotExist);
+ await client.TestPatchAssertNotFoundAsync("users/usernotexist", new HttpUserPatchRequest { }, errorCode: ErrorCodes.UserCommon.NotExist);
}
[Fact]
public async Task Patch_InvalidModel()
{
using var client = await CreateClientAsAdministrator();
- await client.TestPatchAssertInvalidModelAsync("users/aaa!a", new UserPatchRequest { });
+ await client.TestPatchAssertInvalidModelAsync("users/aaa!a", new HttpUserPatchRequest { });
}
public static IEnumerable<object[]> Patch_InvalidModel_Body_Data()
{
- yield return new[] { new UserPatchRequest { Username = "aaa!a" } };
- yield return new[] { new UserPatchRequest { Password = "" } };
- yield return new[] { new UserPatchRequest { Nickname = new string('a', 50) } };
+ yield return new[] { new HttpUserPatchRequest { Username = "aaa!a" } };
+ yield return new[] { new HttpUserPatchRequest { Password = "" } };
+ yield return new[] { new HttpUserPatchRequest { Nickname = new string('a', 50) } };
}
[Theory]
[MemberData(nameof(Patch_InvalidModel_Body_Data))]
- public async Task Patch_InvalidModel_Body(UserPatchRequest body)
+ public async Task Patch_InvalidModel_Body(HttpUserPatchRequest body)
{
using var client = await CreateClientAsAdministrator();
await client.TestPatchAssertInvalidModelAsync("users/user1", body);
@@ -133,35 +133,35 @@ namespace Timeline.Tests.IntegratedTests public async Task Patch_UsernameConflict()
{
using var client = await CreateClientAsAdministrator();
- await client.TestPatchAssertErrorAsync("users/user1", new UserPatchRequest { Username = "admin" }, errorCode: ErrorCodes.UserController.UsernameConflict);
+ await client.TestPatchAssertErrorAsync("users/user1", new HttpUserPatchRequest { Username = "admin" }, errorCode: ErrorCodes.UserController.UsernameConflict);
}
[Fact]
public async Task Patch_NoAuth_Unauthorized()
{
using var client = await CreateDefaultClient();
- await client.TestPatchAssertUnauthorizedAsync("users/user1", new UserPatchRequest { Nickname = "aaa" });
+ await client.TestPatchAssertUnauthorizedAsync("users/user1", new HttpUserPatchRequest { Nickname = "aaa" });
}
[Fact]
public async Task Patch_User_Forbid()
{
using var client = await CreateClientAsUser();
- await client.TestPatchAssertForbiddenAsync("users/admin", new UserPatchRequest { Nickname = "aaa" });
+ await client.TestPatchAssertForbiddenAsync("users/admin", new HttpUserPatchRequest { Nickname = "aaa" });
}
[Fact]
public async Task Patch_Username_Forbid()
{
using var client = await CreateClientAsUser();
- await client.TestPatchAssertForbiddenAsync("users/user1", new UserPatchRequest { Username = "aaa" });
+ await client.TestPatchAssertForbiddenAsync("users/user1", new HttpUserPatchRequest { Username = "aaa" });
}
[Fact]
public async Task Patch_Password_Forbid()
{
using var client = await CreateClientAsUser();
- await client.TestPatchAssertForbiddenAsync("users/user1", new UserPatchRequest { Password = "aaa" });
+ await client.TestPatchAssertForbiddenAsync("users/user1", new HttpUserPatchRequest { Password = "aaa" });
}
[Fact]
@@ -214,7 +214,7 @@ namespace Timeline.Tests.IntegratedTests {
using var client = await CreateClientAsAdministrator();
{
- var body = await client.TestPostAsync<UserInfo>(createUserUrl, new CreateUserRequest
+ var body = await client.TestPostAsync<HttpUser>(createUserUrl, new HttpCreateUserRequest
{
Username = "aaa",
Password = "bbb",
@@ -233,15 +233,15 @@ namespace Timeline.Tests.IntegratedTests public static IEnumerable<object[]> Op_CreateUser_InvalidModel_Data()
{
- yield return new[] { new CreateUserRequest { Username = "aaa" } };
- yield return new[] { new CreateUserRequest { Password = "bbb" } };
- yield return new[] { new CreateUserRequest { Username = "a!a", Password = "bbb" } };
- yield return new[] { new CreateUserRequest { Username = "aaa", Password = "" } };
+ yield return new[] { new HttpCreateUserRequest { Username = "aaa" } };
+ yield return new[] { new HttpCreateUserRequest { Password = "bbb" } };
+ yield return new[] { new HttpCreateUserRequest { Username = "a!a", Password = "bbb" } };
+ yield return new[] { new HttpCreateUserRequest { Username = "aaa", Password = "" } };
}
[Theory]
[MemberData(nameof(Op_CreateUser_InvalidModel_Data))]
- public async Task Op_CreateUser_InvalidModel(CreateUserRequest body)
+ public async Task Op_CreateUser_InvalidModel(HttpCreateUserRequest body)
{
using var client = await CreateClientAsAdministrator();
await client.TestPostAssertInvalidModelAsync(createUserUrl, body);
@@ -251,7 +251,7 @@ namespace Timeline.Tests.IntegratedTests public async Task Op_CreateUser_UsernameConflict()
{
using var client = await CreateClientAsAdministrator();
- await client.TestPostAssertErrorAsync(createUserUrl, new CreateUserRequest
+ await client.TestPostAssertErrorAsync(createUserUrl, new HttpCreateUserRequest
{
Username = "user1",
Password = "bbb",
@@ -262,7 +262,7 @@ namespace Timeline.Tests.IntegratedTests public async Task Op_CreateUser_NoAuth_Unauthorized()
{
using var client = await CreateDefaultClient();
- await client.TestPostAssertUnauthorizedAsync(createUserUrl, new CreateUserRequest
+ await client.TestPostAssertUnauthorizedAsync(createUserUrl, new HttpCreateUserRequest
{
Username = "aaa",
Password = "bbb",
@@ -273,7 +273,7 @@ namespace Timeline.Tests.IntegratedTests public async Task Op_CreateUser_User_Forbid()
{
using var client = await CreateClientAsUser();
- await client.TestPostAssertForbiddenAsync(createUserUrl, new CreateUserRequest
+ await client.TestPostAssertForbiddenAsync(createUserUrl, new HttpCreateUserRequest
{
Username = "aaa",
Password = "bbb",
@@ -286,8 +286,8 @@ namespace Timeline.Tests.IntegratedTests public async Task Op_ChangePassword()
{
using var client = await CreateClientAsUser();
- await client.TestPostAsync(changePasswordUrl, new ChangePasswordRequest { OldPassword = "user1pw", NewPassword = "newpw" });
- await client.TestPatchAssertUnauthorizedAsync("users/user1", new UserPatchRequest { });
+ await client.TestPostAsync(changePasswordUrl, new HttpChangePasswordRequest { OldPassword = "user1pw", NewPassword = "newpw" });
+ await client.TestPatchAssertUnauthorizedAsync("users/user1", new HttpUserPatchRequest { });
(await CreateClientWithCredential("user1", "newpw")).Dispose();
}
@@ -303,21 +303,21 @@ namespace Timeline.Tests.IntegratedTests {
using var client = await CreateClientAsUser();
await client.TestPostAssertInvalidModelAsync(changePasswordUrl,
- new ChangePasswordRequest { OldPassword = oldPassword, NewPassword = newPassword });
+ new HttpChangePasswordRequest { OldPassword = oldPassword, NewPassword = newPassword });
}
[Fact]
public async Task Op_ChangePassword_BadOldPassword()
{
using var client = await CreateClientAsUser();
- await client.TestPostAssertErrorAsync(changePasswordUrl, new ChangePasswordRequest { OldPassword = "???", NewPassword = "???" }, errorCode: ErrorCodes.UserController.ChangePassword_BadOldPassword);
+ await client.TestPostAssertErrorAsync(changePasswordUrl, new HttpChangePasswordRequest { OldPassword = "???", NewPassword = "???" }, errorCode: ErrorCodes.UserController.ChangePassword_BadOldPassword);
}
[Fact]
public async Task Op_ChangePassword_NoAuth_Unauthorized()
{
using var client = await CreateDefaultClient();
- await client.TestPostAssertUnauthorizedAsync(changePasswordUrl, new ChangePasswordRequest { OldPassword = "???", NewPassword = "???" });
+ await client.TestPostAssertUnauthorizedAsync(changePasswordUrl, new HttpChangePasswordRequest { OldPassword = "???", NewPassword = "???" });
}
}
}
|