Major architecture update: stable identity, component validation, media indexing, and protocol docs
This commit is contained in:
1 parent
ce7c97d13a
commit
01c110bbe1
16 files changed
+2718
-468
No files matched your search
+19
-47
@@ -2,34 +2,6 @@ import 'package:chat_server/src/handlers/auth_handlers.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('parseUserId', () {
|
||||
test('parses valid userId', () {
|
||||
final parsed = parseUserId('alice@example.com');
|
||||
expect(parsed, isNotNull);
|
||||
expect(parsed!.username, 'alice');
|
||||
expect(parsed.host, 'example.com');
|
||||
});
|
||||
|
||||
test('returns null for invalid userId', () {
|
||||
expect(parseUserId('alice'), isNull);
|
||||
expect(parseUserId('alice@'), isNull);
|
||||
expect(parseUserId('@example.com'), isNull);
|
||||
expect(parseUserId('alice@example.com@x'), isNull);
|
||||
});
|
||||
});
|
||||
|
||||
group('defaultSchemeForHost', () {
|
||||
test('returns http for localhost-style hosts', () {
|
||||
expect(defaultSchemeForHost('localhost:9870'), 'http');
|
||||
expect(defaultSchemeForHost('127.0.0.1:9870'), 'http');
|
||||
expect(defaultSchemeForHost('[::1]:9870'), 'http');
|
||||
});
|
||||
|
||||
test('returns https for non-local hosts', () {
|
||||
expect(defaultSchemeForHost('chat.example.com'), 'https');
|
||||
});
|
||||
});
|
||||
|
||||
group('normalizeHomeServer', () {
|
||||
test('normalizes host without scheme', () {
|
||||
expect(
|
||||
@@ -59,30 +31,30 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('homeServerMatchesUserIdHost', () {
|
||||
test('matches host and explicit port', () {
|
||||
group('defaultSchemeForHost', () {
|
||||
test('returns http for localhost-style hosts', () {
|
||||
expect(defaultSchemeForHost('localhost:9870'), 'http');
|
||||
expect(defaultSchemeForHost('127.0.0.1:9870'), 'http');
|
||||
expect(defaultSchemeForHost('[::1]:9870'), 'http');
|
||||
});
|
||||
|
||||
test('returns https for non-local hosts', () {
|
||||
expect(defaultSchemeForHost('chat.example.com'), 'https');
|
||||
});
|
||||
});
|
||||
|
||||
group('toUserHandle', () {
|
||||
test('uses URL host and port', () {
|
||||
expect(
|
||||
homeServerMatchesUserIdHost(
|
||||
'https://chat.example.com:8443', 'chat.example.com:8443'),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
homeServerMatchesUserIdHost(
|
||||
'https://chat.example.com:8443', 'chat.example.com'),
|
||||
isFalse,
|
||||
toUserHandle('alice', 'https://chat.example.com:8443'),
|
||||
'@alice@chat.example.com:8443',
|
||||
);
|
||||
});
|
||||
|
||||
test('matches default ports when omitted', () {
|
||||
test('falls back to raw home server string', () {
|
||||
expect(
|
||||
homeServerMatchesUserIdHost(
|
||||
'https://chat.example.com', 'chat.example.com:443'),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
homeServerMatchesUserIdHost(
|
||||
'http://chat.example.com', 'chat.example.com:80'),
|
||||
isTrue,
|
||||
toUserHandle('alice', 'chat.example.com'),
|
||||
'@alice@chat.example.com',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user