diff options
| author | Bond-009 <bond.009@outlook.com> | 2021-04-13 18:29:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-13 18:29:29 +0200 |
| commit | 7c9772ac81f18d53d7d05e3edbd6bf9dd03d40a0 (patch) | |
| tree | fc714ed2136e0dcf262646b33310da18f90d062d /tests/Jellyfin.Server.Integration.Tests/WebSocketTests.cs | |
| parent | ba2a1c020997042a19261ade250d131f6d4a4ac8 (diff) | |
| parent | fbd9141ecdb6ecd8c8b887c33b0b04370f7002e3 (diff) | |
Merge pull request #5713 from Bond-009/websocketauth
Add tests for unauthenticated websocket access
Diffstat (limited to 'tests/Jellyfin.Server.Integration.Tests/WebSocketTests.cs')
| -rw-r--r-- | tests/Jellyfin.Server.Integration.Tests/WebSocketTests.cs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/Jellyfin.Server.Integration.Tests/WebSocketTests.cs b/tests/Jellyfin.Server.Integration.Tests/WebSocketTests.cs new file mode 100644 index 000000000..ffdc04eba --- /dev/null +++ b/tests/Jellyfin.Server.Integration.Tests/WebSocketTests.cs @@ -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)); + } + } +} |
