Merge branch 'master' into fix-resharper-warnings
# Conflicts: # Emby.Server.Implementations/Net/SocketFactory.cs # RSSDP/SsdpCommunicationsServer.cs # RSSDP/SsdpDeviceLocator.cs # RSSDP/SsdpDevicePublisher.cs
This commit is contained in:
@@ -15,8 +15,8 @@ namespace Jellyfin.Server.Integration.Tests
|
||||
{
|
||||
public static class AuthHelper
|
||||
{
|
||||
public const string AuthHeaderName = "X-Emby-Authorization";
|
||||
public const string DummyAuthHeader = "MediaBrowser Client=\"Jellyfin.Server Integration Tests\", DeviceId=\"69420\", Device=\"Apple II\", Version=\"10.8.0\"";
|
||||
public const string AuthHeaderName = "Authorization";
|
||||
public const string DummyAuthHeader = "MediaBrowser Client=\"Jellyfin.Server%20Integration%20Tests\", DeviceId=\"69420\", Device=\"Apple%20II\", Version=\"10.8.0\"";
|
||||
|
||||
public static async Task<string> CompleteStartupAsync(HttpClient client)
|
||||
{
|
||||
@@ -27,16 +27,19 @@ namespace Jellyfin.Server.Integration.Tests
|
||||
using var completeResponse = await client.PostAsync("/Startup/Complete", new ByteArrayContent(Array.Empty<byte>()));
|
||||
Assert.Equal(HttpStatusCode.NoContent, completeResponse.StatusCode);
|
||||
|
||||
using var content = JsonContent.Create(
|
||||
using var httpRequest = new HttpRequestMessage(HttpMethod.Post, "/Users/AuthenticateByName");
|
||||
httpRequest.Headers.TryAddWithoutValidation(AuthHeaderName, DummyAuthHeader);
|
||||
httpRequest.Content = JsonContent.Create(
|
||||
new AuthenticateUserByName()
|
||||
{
|
||||
Username = user!.Name,
|
||||
Pw = user.Password,
|
||||
},
|
||||
options: jsonOptions);
|
||||
content.Headers.Add("X-Emby-Authorization", DummyAuthHeader);
|
||||
|
||||
using var authResponse = await client.PostAsync("/Users/AuthenticateByName", content);
|
||||
using var authResponse = await client.SendAsync(httpRequest);
|
||||
authResponse.EnsureSuccessStatusCode();
|
||||
|
||||
var auth = await JsonSerializer.DeserializeAsync<AuthenticationResultDto>(
|
||||
await authResponse.Content.ReadAsStreamAsync(),
|
||||
jsonOptions);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Server.Integration.Tests.Controllers;
|
||||
|
||||
public class PersonsControllerTests : IClassFixture<JellyfinApplicationFactory>
|
||||
{
|
||||
private readonly JellyfinApplicationFactory _factory;
|
||||
private static string? _accessToken;
|
||||
|
||||
public PersonsControllerTests(JellyfinApplicationFactory factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetPerson_DoesntExist_NotFound()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||
|
||||
using var response = await client.GetAsync($"Persons/DoesntExist");
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user