You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-09 08:42:50 +03:00
Add hostname sanity tests
In the event someone changes how the hostname parsing works.
This commit is contained in:
@@ -143,4 +143,89 @@ describe('matrix-to', function () {
|
|||||||
expect(pickedServers[1]).toBe("second");
|
expect(pickedServers[1]).toBe("second");
|
||||||
expect(pickedServers[2]).toBe("third");
|
expect(pickedServers[2]).toBe("third");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should work with IPv4 hostnames', function () {
|
||||||
|
peg.get().getRoom = () => {
|
||||||
|
return {
|
||||||
|
getJoinedMembers: () => [
|
||||||
|
{
|
||||||
|
userId: "@alice:127.0.0.1",
|
||||||
|
powerLevel: 100,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const pickedServers = pickServerCandidates("!somewhere:example.org");
|
||||||
|
expect(pickedServers).toExist();
|
||||||
|
expect(pickedServers.length).toBe(1);
|
||||||
|
expect(pickedServers[0]).toBe("127.0.0.1");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should work with IPv6 hostnames', function () {
|
||||||
|
peg.get().getRoom = () => {
|
||||||
|
return {
|
||||||
|
getJoinedMembers: () => [
|
||||||
|
{
|
||||||
|
userId: "@alice:[::1]",
|
||||||
|
powerLevel: 100,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const pickedServers = pickServerCandidates("!somewhere:example.org");
|
||||||
|
expect(pickedServers).toExist();
|
||||||
|
expect(pickedServers.length).toBe(1);
|
||||||
|
expect(pickedServers[0]).toBe("[::1]");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should work with IPv4 hostnames with ports', function () {
|
||||||
|
peg.get().getRoom = () => {
|
||||||
|
return {
|
||||||
|
getJoinedMembers: () => [
|
||||||
|
{
|
||||||
|
userId: "@alice:127.0.0.1:8448",
|
||||||
|
powerLevel: 100,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const pickedServers = pickServerCandidates("!somewhere:example.org");
|
||||||
|
expect(pickedServers).toExist();
|
||||||
|
expect(pickedServers.length).toBe(1);
|
||||||
|
expect(pickedServers[0]).toBe("127.0.0.1:8448");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should work with IPv6 hostnames with ports', function () {
|
||||||
|
peg.get().getRoom = () => {
|
||||||
|
return {
|
||||||
|
getJoinedMembers: () => [
|
||||||
|
{
|
||||||
|
userId: "@alice:[::1]:8448",
|
||||||
|
powerLevel: 100,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const pickedServers = pickServerCandidates("!somewhere:example.org");
|
||||||
|
expect(pickedServers).toExist();
|
||||||
|
expect(pickedServers.length).toBe(1);
|
||||||
|
expect(pickedServers[0]).toBe("[::1]:8448");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should work with hostnames with ports', function () {
|
||||||
|
peg.get().getRoom = () => {
|
||||||
|
return {
|
||||||
|
getJoinedMembers: () => [
|
||||||
|
{
|
||||||
|
userId: "@alice:example.org:8448",
|
||||||
|
powerLevel: 100,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const pickedServers = pickServerCandidates("!somewhere:example.org");
|
||||||
|
expect(pickedServers).toExist();
|
||||||
|
expect(pickedServers.length).toBe(1);
|
||||||
|
expect(pickedServers[0]).toBe("example.org:8448");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user