Open ts3server:// links on both apps
A link connects with its nickname, passwords, channel (path or cid) and privilege key, the key used once on; addbookmark saves it as a bookmark. A link to a server we are on already goes to its channel instead. Android takes the links from browsers and other apps through an intent filter, and from chat. The desktop opens them from chat and descriptions, and its launcher entry claims the scheme when run from the jar; a second launch hands its link to the running instance over a Unix socket in the user's runtime directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package com.ts3client.session;
|
||||
|
||||
import com.ts3client.config.Bookmark;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
class ServerLinkTest {
|
||||
|
||||
@Test
|
||||
void readsEveryParameter() {
|
||||
ServerLink link = ServerLink.parse("ts3server://ts.example.com?port=9988&nickname=Bob%20B"
|
||||
+ "&password=s+cret&channel=Lobby/Games&channelpassword=pw&token=abc&addbookmark=Example");
|
||||
assertEquals("ts.example.com", link.address);
|
||||
assertEquals(9988, link.port);
|
||||
assertEquals("Bob B", link.nickname);
|
||||
assertEquals("s+cret", link.password);
|
||||
assertEquals("Lobby/Games", link.channel);
|
||||
assertEquals("pw", link.channelPassword);
|
||||
assertEquals("abc", link.token);
|
||||
assertEquals("Example", link.bookmarkLabel);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aBareHostTakesTheDefaults() {
|
||||
ServerLink link = ServerLink.parse("TS3SERVER://ts.example.com/");
|
||||
assertEquals("ts.example.com", link.address);
|
||||
assertEquals(9987, link.port);
|
||||
assertEquals("", link.channel);
|
||||
assertEquals("", link.token);
|
||||
}
|
||||
|
||||
@Test
|
||||
void readsThePortFromTheAuthority() {
|
||||
assertEquals(1234, ServerLink.parse("ts3server://1.2.3.4:1234").port);
|
||||
ServerLink v6 = ServerLink.parse("ts3server://[2001:db8::1]:5000?nickname=x");
|
||||
assertEquals("2001:db8::1", v6.address);
|
||||
assertEquals(5000, v6.port);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aChannelIdWinsOverThePath() {
|
||||
assertEquals("/42", ServerLink.parse("ts3server://h?channel=Old%20name&cid=42").channel);
|
||||
assertEquals("Lobby", ServerLink.parse("ts3server://h?cid=0&channel=Lobby").channel);
|
||||
}
|
||||
|
||||
@Test
|
||||
void namesNoServerWithoutAHost() {
|
||||
assertNull(ServerLink.parse("ts3server://?port=1"));
|
||||
assertNull(ServerLink.parse("https://example.com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void bookmarksUnderTheAskedName() {
|
||||
Bookmark b = ServerLink.parse("ts3server://h?addbookmark=Mine&cid=3&channelpassword=x").toBookmark();
|
||||
assertEquals("Mine", b.label);
|
||||
assertEquals("/3", b.channel);
|
||||
assertEquals("x", b.channelPassword);
|
||||
assertEquals("h", ServerLink.parse("ts3server://h").toBookmark().label);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user