mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
Implement refresh token flow and refactor session handling
Added refresh token endpoint and controller, introduced IUserSessionRefresher and UserSessionRefresher for token renewal, and updated session handling to return both access and refresh tokens. Refactored AuthController, tests, and related interfaces to support new token flow. Fixed JwtAccessOption property typo, updated configuration, and extended UserSessionsRepository to support lookup by refresh token.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using AutoFixture;
|
||||
using Govor.API.Controllers;
|
||||
using Govor.API.Controllers.Authentication;
|
||||
using Govor.Application.Exceptions.AuthService;
|
||||
using Govor.Application.Exceptions.InvitesService;
|
||||
using Govor.Application.Interfaces.Authentication;
|
||||
@@ -50,7 +50,7 @@ public class AuthControllerTests
|
||||
// Arrange
|
||||
var request = _fixture.Create<RegistrationRequest>();
|
||||
var invitation = _fixture.Create<Invitation>();
|
||||
var token = _fixture.Create<string>();
|
||||
var token = _fixture.Create<RefreshResult>();
|
||||
|
||||
var user = _fixture.Build<User>()
|
||||
.With(x => x.Username).Create();
|
||||
@@ -70,8 +70,11 @@ public class AuthControllerTests
|
||||
// Assert
|
||||
Assert.That(result, Is.InstanceOf<OkObjectResult>());
|
||||
var okResult = result as OkObjectResult;
|
||||
dynamic value = okResult.Value;
|
||||
Assert.That((string)value.GetType().GetProperty("token").GetValue(value, null), Is.EqualTo(token));
|
||||
|
||||
var response = okResult?.Value as RefreshResult;
|
||||
Assert.That(response, Is.Not.Null);
|
||||
Assert.That(response.accessToken, Is.EqualTo(token.accessToken));
|
||||
Assert.That(response.refreshToken, Is.EqualTo(token.refreshToken));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -149,7 +152,7 @@ public class AuthControllerTests
|
||||
{
|
||||
// Arrange
|
||||
var loginRequest = _fixture.Create<LoginRequest>();
|
||||
var token = _fixture.Create<string>();
|
||||
var token = _fixture.Create<RefreshResult>();
|
||||
|
||||
var user = _fixture.Build<User>()
|
||||
.With(x => x.Username).Create();
|
||||
@@ -164,8 +167,11 @@ public class AuthControllerTests
|
||||
// Assert
|
||||
Assert.That(result, Is.InstanceOf<OkObjectResult>());
|
||||
var okResult = result as OkObjectResult;
|
||||
dynamic value = okResult.Value;
|
||||
Assert.That((string)value.GetType().GetProperty("token").GetValue(value, null), Is.EqualTo(token));
|
||||
|
||||
var response = okResult?.Value as RefreshResult;
|
||||
Assert.That(response, Is.Not.Null);
|
||||
Assert.That(response.accessToken, Is.EqualTo(token.accessToken));
|
||||
Assert.That(response.refreshToken, Is.EqualTo(token.refreshToken));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user