aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline.Tests
diff options
context:
space:
mode:
Diffstat (limited to 'BackEnd/Timeline.Tests')
-rw-r--r--BackEnd/Timeline.Tests/IntegratedTests/SearchTest.cs6
-rw-r--r--BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs32
-rw-r--r--BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs18
-rw-r--r--BackEnd/Timeline.Tests/packages.lock.json6
4 files changed, 50 insertions, 12 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/SearchTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/SearchTest.cs
index 7782ed82..10a2f115 100644
--- a/BackEnd/Timeline.Tests/IntegratedTests/SearchTest.cs
+++ b/BackEnd/Timeline.Tests/IntegratedTests/SearchTest.cs
@@ -39,10 +39,10 @@ namespace Timeline.Tests.IntegratedTests
var client = await CreateClientAsAdministrator();
{
- await client.TestPostAsync("users", new HttpCreateUserRequest { Username = "hahaha", Password = "p" });
- await client.TestPostAsync("users", new HttpCreateUserRequest { Username = "bababa", Password = "p" });
+ await client.TestPostAsync("users", new HttpUserPostRequest { Username = "hahaha", Password = "p" });
+ await client.TestPostAsync("users", new HttpUserPostRequest { Username = "bababa", Password = "p" });
await client.TestPatchAsync("users/bababa", new HttpUserPatchRequest { Nickname = "hahaha" });
- await client.TestPostAsync("users", new HttpCreateUserRequest { Username = "gagaga", Password = "p" });
+ await client.TestPostAsync("users", new HttpUserPostRequest { Username = "gagaga", Password = "p" });
}
{
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
index b91de6c2..f00d9b13 100644
--- a/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
+++ b/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
@@ -14,6 +14,7 @@ using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Jpeg;
using System.Net;
+using System.Text.RegularExpressions;
namespace Timeline.Tests.IntegratedTests
{
@@ -36,6 +37,23 @@ namespace Timeline.Tests.IntegratedTests
};
}
+ private static HttpTimelinePostCreateRequest CreateMarkdownPostRequest(string text, DateTime? time = null, string? color = null)
+ {
+ return new HttpTimelinePostCreateRequest()
+ {
+ Time = time,
+ Color = color,
+ DataList = new List<HttpTimelinePostCreateRequestData>()
+ {
+ new HttpTimelinePostCreateRequestData()
+ {
+ ContentType = MimeTypes.TextMarkdown,
+ Data = Convert.ToBase64String(Encoding.UTF8.GetBytes(text))
+ }
+ }
+ };
+ }
+
private readonly ITestOutputHelper _outputHelper;
public TimelinePostTest(ITestOutputHelper outputHelper)
@@ -586,5 +604,19 @@ namespace Timeline.Tests.IntegratedTests
post2.Editable.Should().BeFalse();
}
}
+
+ [Theory]
+ [MemberData(nameof(TimelineNameGeneratorTestData))]
+ public async Task Post_Markdown_Url_Map(TimelineNameGenerator generator)
+ {
+ using var client = await CreateClientAsUser();
+ var post = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", CreateMarkdownPostRequest("[aaa](1) ![bbb](2)"));
+
+ var res = await client.GetAsync($"timelines/{generator(1)}/posts/{post.Id}/data");
+ var markdown = await res.Content.ReadAsStringAsync();
+
+ markdown.Should().MatchRegex(@$"\[aaa\]\(https?://.*/timelines/{generator(1)}/posts/{post.Id}/data/1\)");
+ markdown.Should().MatchRegex(@$"\[bbb\]\(https?://.*/timelines/{generator(1)}/posts/{post.Id}/data/2\)");
+ }
}
}
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs
index 664a0604..c728a280 100644
--- a/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs
+++ b/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs
@@ -214,7 +214,7 @@ namespace Timeline.Tests.IntegratedTests
{
using var client = await CreateClientAsAdministrator();
{
- var body = await client.TestPostAsync<HttpUser>(createUserUrl, new HttpCreateUserRequest
+ var body = await client.TestPostAsync<HttpUser>(createUserUrl, new HttpUserPostRequest
{
Username = "aaa",
Password = "bbb",
@@ -233,15 +233,15 @@ namespace Timeline.Tests.IntegratedTests
public static IEnumerable<object[]> Op_CreateUser_InvalidModel_Data()
{
- 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 = "" } };
+ yield return new[] { new HttpUserPostRequest { Username = "aaa" } };
+ yield return new[] { new HttpUserPostRequest { Password = "bbb" } };
+ yield return new[] { new HttpUserPostRequest { Username = "a!a", Password = "bbb" } };
+ yield return new[] { new HttpUserPostRequest { Username = "aaa", Password = "" } };
}
[Theory]
[MemberData(nameof(Op_CreateUser_InvalidModel_Data))]
- public async Task Op_CreateUser_InvalidModel(HttpCreateUserRequest body)
+ public async Task Op_CreateUser_InvalidModel(HttpUserPostRequest 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 HttpCreateUserRequest
+ await client.TestPostAssertErrorAsync(createUserUrl, new HttpUserPostRequest
{
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 HttpCreateUserRequest
+ await client.TestPostAssertUnauthorizedAsync(createUserUrl, new HttpUserPostRequest
{
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 HttpCreateUserRequest
+ await client.TestPostAssertForbiddenAsync(createUserUrl, new HttpUserPostRequest
{
Username = "aaa",
Password = "bbb",
diff --git a/BackEnd/Timeline.Tests/packages.lock.json b/BackEnd/Timeline.Tests/packages.lock.json
index 50b90c3c..bdcfaf35 100644
--- a/BackEnd/Timeline.Tests/packages.lock.json
+++ b/BackEnd/Timeline.Tests/packages.lock.json
@@ -127,6 +127,11 @@
"System.Xml.XmlDocument": "4.3.0"
}
},
+ "Markdig": {
+ "type": "Transitive",
+ "resolved": "0.23.0",
+ "contentHash": "jPPcnHGSDSedPvwZ6jiMJpvK3iJGA2djU6TFmEr6XK2BiYK1ier2lTHVwDt41XLxDbfGu5Dn42hKDzwqs049PA=="
+ },
"Microsoft.AspNetCore.Authorization": {
"type": "Transitive",
"resolved": "1.0.3",
@@ -1981,6 +1986,7 @@
"dependencies": {
"AutoMapper": "10.1.1",
"AutoMapper.Extensions.Microsoft.DependencyInjection": "8.1.0",
+ "Markdig": "0.23.0",
"Microsoft.AspNetCore.SpaServices.Extensions": "5.0.0",
"Microsoft.EntityFrameworkCore": "5.0.0",
"Microsoft.EntityFrameworkCore.Analyzers": "5.0.0",