diff options
| author | Bond_009 <bond.009@outlook.com> | 2021-04-06 22:46:54 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2021-04-06 22:46:54 +0200 |
| commit | fbd9141ecdb6ecd8c8b887c33b0b04370f7002e3 (patch) | |
| tree | 0e7d52255be6b1cc2ef2b307406549ea3086724a | |
| parent | 221d9373e857d008ac9c1426e856ae3da1200701 (diff) | |
Add tests for unauthenticated websocket access
| -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)); + } + } +} |
