diff options
author | crupest <crupest@outlook.com> | 2022-03-23 21:30:14 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-03-23 21:30:31 +0800 |
commit | da9139b7bab95f6e5ba5f4bb2d99011c2d6db03a (patch) | |
tree | 051fd4ca4bc511db7e04b019a33fddaab2d0cc6b /BackEnd/Timeline.Tests/IntegratedTests | |
parent | 3d6c9fd916e18c99b3a5497b8313672680571b5e (diff) | |
download | timeline-da9139b7bab95f6e5ba5f4bb2d99011c2d6db03a.tar.gz timeline-da9139b7bab95f6e5ba5f4bb2d99011c2d6db03a.tar.bz2 timeline-da9139b7bab95f6e5ba5f4bb2d99011c2d6db03a.zip |
…
Diffstat (limited to 'BackEnd/Timeline.Tests/IntegratedTests')
-rw-r--r-- | BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs | 42 |
1 files changed, 2 insertions, 40 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs index 68681b61..555ab4da 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs @@ -1,10 +1,8 @@ using FluentAssertions;
-using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Timeline.Models.Http;
-using Timeline.Services.User;
using Xunit;
using Xunit.Abstractions;
@@ -80,48 +78,12 @@ namespace Timeline.Tests.IntegratedTests }
[Fact]
- public async Task VerifyToken_BadFormat()
+ public async Task VerifyToken_Invalid()
{
using var client = await CreateDefaultClient();
await client.TestPostAssertErrorAsync(VerifyTokenUrl,
new HttpVerifyTokenRequest { Token = "bad token hahaha" },
- errorCode: ErrorCodes.TokenController.VerifyBadFormat);
- }
-
- [Fact]
- public async Task VerifyToken_OldVersion()
- {
- using var client = await CreateDefaultClient();
- var token = (await CreateUserTokenAsync(client, "user1", "user1pw")).Token;
-
- using (var scope = TestApp.Host.Services.CreateScope()) // UserService is scoped.
- {
- // create a user for test
- var userService = scope.ServiceProvider.GetRequiredService<IUserService>();
- var id = await userService.GetUserIdByUsernameAsync("user1");
- await userService.ModifyUserAsync(id, new ModifyUserParams { Password = "user1pw" });
- }
-
- await client.TestPostAssertErrorAsync(VerifyTokenUrl,
- new HttpVerifyTokenRequest { Token = token },
- errorCode: ErrorCodes.TokenController.VerifyOldVersion);
- }
-
- [Fact]
- public async Task VerifyToken_UserNotExist()
- {
- using var client = await CreateDefaultClient();
- var token = (await CreateUserTokenAsync(client, "user1", "user1pw")).Token;
-
- using (var scope = TestApp.Host.Services.CreateScope()) // UserDeleteService is scoped.
- {
- var userService = scope.ServiceProvider.GetRequiredService<IUserDeleteService>();
- await userService.DeleteUserAsync("user1");
- }
-
- await client.TestPostAssertErrorAsync(VerifyTokenUrl,
- new HttpVerifyTokenRequest { Token = token },
- errorCode: ErrorCodes.TokenController.VerifyUserNotExist);
+ errorCode: ErrorCodes.TokenController.VerifyInvalid);
}
//[Fact]
|