fail quick connect closed on an unreachable valkey and restore the idempotent exchange
This commit is contained in:
+16
-4
@@ -154,14 +154,26 @@ namespace Jellyfin.Server.Implementations.Tests.QuickConnect
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAuthorizedRequest_SecondExchange_ThrowsResourceNotFoundException()
|
||||
public async Task GetAuthorizedRequest_SecondExchange_ReturnsTheSameResult()
|
||||
{
|
||||
_config.QuickConnectAvailable = true;
|
||||
var res = await _quickConnectManager.TryConnect(_quickConnectAuthInfo);
|
||||
await _quickConnectManager.AuthorizeRequest(Guid.Empty, res.Code);
|
||||
|
||||
Assert.NotNull(await _quickConnectManager.GetAuthorizedRequest(res.Secret));
|
||||
await Assert.ThrowsAsync<ResourceNotFoundException>(() => _quickConnectManager.GetAuthorizedRequest(res.Secret));
|
||||
var first = await _quickConnectManager.GetAuthorizedRequest(res.Secret);
|
||||
var second = await _quickConnectManager.GetAuthorizedRequest(res.Secret);
|
||||
|
||||
Assert.Same(first, second);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AuthorizeRequest_OfAnAuthorizedRequest_ThrowsConflictException()
|
||||
{
|
||||
_config.QuickConnectAvailable = true;
|
||||
var res = await _quickConnectManager.TryConnect(_quickConnectAuthInfo);
|
||||
await _quickConnectManager.AuthorizeRequest(Guid.Empty, res.Code);
|
||||
|
||||
await Assert.ThrowsAsync<ConflictException>(() => _quickConnectManager.AuthorizeRequest(Guid.Empty, res.Code));
|
||||
}
|
||||
|
||||
private async Task<bool> AuthorizeAsync(string code)
|
||||
@@ -170,7 +182,7 @@ namespace Jellyfin.Server.Implementations.Tests.QuickConnect
|
||||
{
|
||||
return await _quickConnectManager.AuthorizeRequest(Guid.Empty, code).ConfigureAwait(false);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
catch (ConflictException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user