mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-21 13:10:45 +02:00
Merge pull request #5713 from Bond-009/websocketauth
Add tests for unauthenticated websocket access
This commit is contained in:
commit
7c9772ac81
32
tests/Jellyfin.Server.Integration.Tests/WebSocketTests.cs
Normal file
32
tests/Jellyfin.Server.Integration.Tests/WebSocketTests.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Jellyfin.Server.Integration.Tests
|
||||||
|
{
|
||||||
|
public sealed class WebSocketTests : IClassFixture<JellyfinApplicationFactory>
|
||||||
|
{
|
||||||
|
private readonly JellyfinApplicationFactory _factory;
|
||||||
|
|
||||||
|
public WebSocketTests(JellyfinApplicationFactory factory)
|
||||||
|
{
|
||||||
|
_factory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task WebSocket_Unauthenticated_ThrowsInvalidOperationException()
|
||||||
|
{
|
||||||
|
var server = _factory.Server;
|
||||||
|
var client = server.CreateWebSocketClient();
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<InvalidOperationException>(
|
||||||
|
() => client.ConnectAsync(
|
||||||
|
new UriBuilder(server.BaseAddress)
|
||||||
|
{
|
||||||
|
Scheme = "ws",
|
||||||
|
Path = "websocket"
|
||||||
|
}.Uri, CancellationToken.None));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue