diff options
author | crupest <crupest@outlook.com> | 2021-05-15 16:01:21 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-05-15 16:01:21 +0800 |
commit | 49b0cb7b465561447b8d4693ba988b13e0e1b57a (patch) | |
tree | 4c533d940af0b2691619a960f439f5f33129a9ff /BackEnd/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs | |
parent | 741230818e8c8093f7ead04c7df1c21a17cceae4 (diff) | |
download | timeline-49b0cb7b465561447b8d4693ba988b13e0e1b57a.tar.gz timeline-49b0cb7b465561447b8d4693ba988b13e0e1b57a.tar.bz2 timeline-49b0cb7b465561447b8d4693ba988b13e0e1b57a.zip |
feat: Timeline post change notification with signalr.
Diffstat (limited to 'BackEnd/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs')
-rw-r--r-- | BackEnd/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs b/BackEnd/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs index 588f2f93..259ebfa1 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs @@ -105,6 +105,14 @@ namespace Timeline.Tests.IntegratedTests return Task.FromResult(client);
}
+ public async Task<string> CreateTokenWithCredentialAsync(string username, string password)
+ {
+ var client = await CreateDefaultClient();
+ var res = await client.TestPostAsync<HttpCreateTokenResponse>("token/create",
+ new HttpCreateTokenRequest { Username = username, Password = password });
+ return res.Token;
+ }
+
public async Task<HttpClient> CreateClientWithCredential(string username, string password, bool setApiBase = true)
{
var client = await CreateDefaultClient(setApiBase);
@@ -115,6 +123,14 @@ namespace Timeline.Tests.IntegratedTests return client;
}
+ public Task<string> CreateTokenAsync(int userNumber)
+ {
+ if (userNumber == 0)
+ return CreateTokenWithCredentialAsync("admin", "adminpw");
+ else
+ return CreateTokenWithCredentialAsync($"user{userNumber}", $"user{userNumber}pw");
+ }
+
public Task<HttpClient> CreateClientAs(int userNumber, bool setApiBase = true)
{
if (userNumber < 0)
|