-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,6 +383,41 @@ public async Task RestoreLeaderboard_OK() | |
res.DeletedAt.Should().BeNull(); | ||
} | ||
|
||
[Test] | ||
public async Task RestoreLeaderboard_Unauthenticated() | ||
{ | ||
Func<Task<LeaderboardViewModel>> act = async () => await _apiClient.Put<LeaderboardViewModel>($"/leaderboard/100/restore", new() | ||
{ | ||
Jwt = "" | ||
}); | ||
|
||
await act.Should().ThrowAsync<RequestFailureException>().Where(e => e.Response.StatusCode == HttpStatusCode.Unauthorized); | ||
} | ||
|
||
[Test] | ||
public async Task RestoreLeaderboard_Unauthorized() | ||
{ | ||
IUserService userService = _factory.Services.CreateScope().ServiceProvider.GetRequiredService<IUserService>(); | ||
|
||
RegisterRequest registerRequest = new() | ||
{ | ||
Email = "[email protected]", | ||
Password = "Passw0rd", | ||
Username = "unauthorized" | ||
}; | ||
|
||
await userService.CreateUser(registerRequest); | ||
|
||
string jwt = (await _apiClient.LoginUser(registerRequest.Email, registerRequest.Password)).Token; | ||
|
||
Func<Task<LeaderboardViewModel>> act = async () => await _apiClient.Put<LeaderboardViewModel>($"/leaderboard/100/restore", new() | ||
{ | ||
Jwt = jwt, | ||
}); | ||
|
||
await act.Should().ThrowAsync<RequestFailureException>().Where(e => e.Response.StatusCode == HttpStatusCode.Forbidden); | ||
} | ||
|
||
[Test] | ||
public async Task RestoreLeaderboard_NotFound() | ||
{ | ||
|