mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-04-27 12:02:51 -04:00
fix: preserve Jellyfin remote control sessions
Forward session control requests transparently and avoid synthetic websocket or capability state overriding proxied client sockets.
This commit is contained in:
@@ -372,6 +372,69 @@ public class JellyfinProxyServiceTests
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendAsync_WithNoBody_PreservesEmptyRequestBody()
|
||||
{
|
||||
// Arrange
|
||||
HttpRequestMessage? captured = null;
|
||||
_mockHandler.Protected()
|
||||
.Setup<Task<HttpResponseMessage>>("SendAsync",
|
||||
ItExpr.IsAny<HttpRequestMessage>(),
|
||||
ItExpr.IsAny<CancellationToken>())
|
||||
.Callback<HttpRequestMessage, CancellationToken>((req, _) => captured = req)
|
||||
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NoContent));
|
||||
|
||||
var headers = new HeaderDictionary
|
||||
{
|
||||
["X-Emby-Authorization"] = "MediaBrowser Token=\"abc\""
|
||||
};
|
||||
|
||||
// Act
|
||||
var (_, statusCode) = await _service.SendAsync(
|
||||
HttpMethod.Post,
|
||||
"Sessions/session-123/Playing/Pause?controllingUserId=user-123",
|
||||
null,
|
||||
headers);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(204, statusCode);
|
||||
Assert.NotNull(captured);
|
||||
Assert.Equal(HttpMethod.Post, captured!.Method);
|
||||
Assert.Null(captured.Content);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendAsync_WithCustomContentType_PreservesOriginalType()
|
||||
{
|
||||
// Arrange
|
||||
HttpRequestMessage? captured = null;
|
||||
_mockHandler.Protected()
|
||||
.Setup<Task<HttpResponseMessage>>("SendAsync",
|
||||
ItExpr.IsAny<HttpRequestMessage>(),
|
||||
ItExpr.IsAny<CancellationToken>())
|
||||
.Callback<HttpRequestMessage, CancellationToken>((req, _) => captured = req)
|
||||
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NoContent));
|
||||
|
||||
var headers = new HeaderDictionary
|
||||
{
|
||||
["X-Emby-Authorization"] = "MediaBrowser Token=\"abc\""
|
||||
};
|
||||
|
||||
// Act
|
||||
await _service.SendAsync(
|
||||
HttpMethod.Put,
|
||||
"Sessions/session-123/Command/DisplayMessage",
|
||||
"{\"Text\":\"hello\"}",
|
||||
headers,
|
||||
"application/json; charset=utf-8");
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(captured);
|
||||
Assert.Equal(HttpMethod.Put, captured!.Method);
|
||||
Assert.NotNull(captured.Content);
|
||||
Assert.Equal("application/json; charset=utf-8", captured.Content!.Headers.ContentType!.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetPassthroughResponseAsync_WithAcceptEncoding_ForwardsCompressionHeaders()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user