|
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
|
using AutoFixture;
|
|
using AutoFixture;
|
|
using AutoFixture.AutoMoq;
|
|
using AutoFixture.AutoMoq;
|
|
using Emby.Server.Implementations.QuickConnect;
|
|
using Emby.Server.Implementations.QuickConnect;
|
|
|
|
+using MediaBrowser.Common.Extensions;
|
|
using MediaBrowser.Controller.Authentication;
|
|
using MediaBrowser.Controller.Authentication;
|
|
using MediaBrowser.Controller.Configuration;
|
|
using MediaBrowser.Controller.Configuration;
|
|
using MediaBrowser.Controller.Net;
|
|
using MediaBrowser.Controller.Net;
|
|
@@ -51,6 +52,21 @@ namespace Jellyfin.Server.Implementations.Tests.QuickConnect
|
|
public void IsEnabled_QuickConnectUnavailable_False()
|
|
public void IsEnabled_QuickConnectUnavailable_False()
|
|
=> Assert.False(_quickConnectManager.IsEnabled);
|
|
=> Assert.False(_quickConnectManager.IsEnabled);
|
|
|
|
|
|
|
|
+ [Theory]
|
|
|
|
+ [InlineData("", "DeviceId", "Client", "1.0.0")]
|
|
|
|
+ [InlineData("Device", "", "Client", "1.0.0")]
|
|
|
|
+ [InlineData("Device", "DeviceId", "", "1.0.0")]
|
|
|
|
+ [InlineData("Device", "DeviceId", "Client", "")]
|
|
|
|
+ public void TryConnect_InvalidAuthorizationInfo_ThrowsArgumentException(string device, string deviceId, string client, string version)
|
|
|
|
+ => Assert.Throws<ArgumentException>(() => _quickConnectManager.TryConnect(
|
|
|
|
+ new AuthorizationInfo
|
|
|
|
+ {
|
|
|
|
+ Device = device,
|
|
|
|
+ DeviceId = deviceId,
|
|
|
|
+ Client = client,
|
|
|
|
+ Version = version
|
|
|
|
+ }));
|
|
|
|
+
|
|
[Fact]
|
|
[Fact]
|
|
public void TryConnect_QuickConnectUnavailable_ThrowsAuthenticationException()
|
|
public void TryConnect_QuickConnectUnavailable_ThrowsAuthenticationException()
|
|
=> Assert.Throws<AuthenticationException>(() => _quickConnectManager.TryConnect(_quickConnectAuthInfo));
|
|
=> Assert.Throws<AuthenticationException>(() => _quickConnectManager.TryConnect(_quickConnectAuthInfo));
|
|
@@ -63,6 +79,10 @@ namespace Jellyfin.Server.Implementations.Tests.QuickConnect
|
|
public void AuthorizeRequest_QuickConnectUnavailable_ThrowsAuthenticationException()
|
|
public void AuthorizeRequest_QuickConnectUnavailable_ThrowsAuthenticationException()
|
|
=> Assert.ThrowsAsync<AuthenticationException>(() => _quickConnectManager.AuthorizeRequest(Guid.Empty, string.Empty));
|
|
=> Assert.ThrowsAsync<AuthenticationException>(() => _quickConnectManager.AuthorizeRequest(Guid.Empty, string.Empty));
|
|
|
|
|
|
|
|
+ [Fact]
|
|
|
|
+ public void GetAuthorizedRequest_QuickConnectUnavailable_ThrowsAuthenticationException()
|
|
|
|
+ => Assert.Throws<AuthenticationException>(() => _quickConnectManager.GetAuthorizedRequest(string.Empty));
|
|
|
|
+
|
|
[Fact]
|
|
[Fact]
|
|
public void IsEnabled_QuickConnectAvailable_True()
|
|
public void IsEnabled_QuickConnectAvailable_True()
|
|
{
|
|
{
|
|
@@ -79,6 +99,20 @@ namespace Jellyfin.Server.Implementations.Tests.QuickConnect
|
|
Assert.Equal(res1, res2);
|
|
Assert.Equal(res1, res2);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [Fact]
|
|
|
|
+ public void CheckRequestStatus_UnknownSecret_ThrowsResourceNotFoundException()
|
|
|
|
+ {
|
|
|
|
+ _config.QuickConnectAvailable = true;
|
|
|
|
+ Assert.Throws<ResourceNotFoundException>(() => _quickConnectManager.CheckRequestStatus("Unknown secret"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [Fact]
|
|
|
|
+ public void GetAuthorizedRequest_UnknownSecret_ThrowsResourceNotFoundException()
|
|
|
|
+ {
|
|
|
|
+ _config.QuickConnectAvailable = true;
|
|
|
|
+ Assert.Throws<ResourceNotFoundException>(() => _quickConnectManager.GetAuthorizedRequest("Unknown secret"));
|
|
|
|
+ }
|
|
|
|
+
|
|
[Fact]
|
|
[Fact]
|
|
public async Task AuthorizeRequest_QuickConnectAvailable_Success()
|
|
public async Task AuthorizeRequest_QuickConnectAvailable_Success()
|
|
{
|
|
{
|