feat: import Chinese-localized Buzz source snapshot
Docker image / Build (linux/amd64) (push) Has been cancelled
Docker image / Build (linux/arm64) (push) Has been cancelled
Docker image / Merge release multi-arch manifest (push) Has been cancelled
Docker image / Merge debug multi-arch manifest (push) Has been cancelled
Docker image / Build public push gateway (linux/amd64) (push) Has been cancelled
Docker image / Build public push gateway (linux/arm64) (push) Has been cancelled
Docker image / Publish public push gateway image (push) Has been cancelled
Sprig image / Build (linux/amd64) (push) Has been cancelled
Sprig image / Build (linux/arm64) (push) Has been cancelled
Sprig image / Merge multi-arch manifest (push) Has been cancelled
Harbor Buzz Orchestra / Python tests and lint (push) Has been cancelled
CI / Detect Changed Paths (push) Has been cancelled
CI / Rust Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Desktop Core (push) Has been cancelled
CI / Desktop Smoke E2E (1) (push) Has been cancelled
CI / Desktop Smoke E2E (2) (push) Has been cancelled
CI / Desktop Smoke E2E (3) (push) Has been cancelled
CI / Desktop Smoke E2E (4) (push) Has been cancelled
CI / Desktop (push) Has been cancelled
CI / Desktop E2E Relay (push) Has been cancelled
CI / Desktop E2E Integration (1/2) (push) Has been cancelled
CI / Desktop E2E Integration (2/2) (push) Has been cancelled
CI / Desktop E2E Integration (push) Has been cancelled
CI / Backend Integration (relay e2e) (push) Has been cancelled
CI / Relay E2E (push) Has been cancelled
CI / Web (push) Has been cancelled
CI / Mobile (push) Has been cancelled
CI / Security (push) Has been cancelled
CI / Dead Token Reference Guard (push) Has been cancelled
CI / Server Cross-Compile (aarch64-unknown-linux-musl) (push) Has been cancelled
CI / Server Cross-Compile (x86_64-unknown-linux-musl) (push) Has been cancelled
CI / Windows Rust (x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Desktop Build (macOS) (push) Has been cancelled
helm chart / lint + unittest + render matrix (push) Has been cancelled
helm chart / install on kind (gated) (push) Has been cancelled
helm chart / publish chart to GHCR (push) Has been cancelled
Mesh Lifecycle / Relay-Driven Mesh Lifecycle Smoke (push) Has been cancelled
Sprig / Build (aarch64-unknown-linux-musl) (push) Has been cancelled
Sprig / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Sprig / Publish rolling release (push) Has been cancelled
Sprig / Publish tagged release (push) Has been cancelled

Signed-off-by: cls_宁波本机 <908705107@qq.com>
This commit is contained in:
2026-08-13 18:34:25 +08:00
parent 61c3fa1df9
commit 9dfa06ffee
3785 changed files with 1085458 additions and 2 deletions
@@ -0,0 +1,161 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:buzz/shared/relay/relay_validation.dart';
void main() {
group('validateInviteRelayUri', () {
test('accepts public secure relay origins', () {
for (final url in [
'wss://relay.example.com',
'wss://relay.example.com/',
'wss://relay.example.com:8443',
'wss://8.8.8.8',
'wss://[2001:4860:4860::8888]',
'wss://[2001:1::1]',
'wss://[2001:1::2]',
'wss://[2001:1::3]',
'wss://[2001:3::1]',
'wss://[2001:4:112::1]',
'wss://[2001:20::1]',
'wss://[2001:30::1]',
'wss://[2001:200::1]',
'wss://[2620:4f:8000::1]',
'wss://[3fff:1000::1]',
'wss://[2606:4700:4700::1111]',
]) {
expect(
() => validateInviteRelayUri(
Uri.parse(url),
allowInsecureLocalhost: false,
),
returnsNormally,
reason: url,
);
}
});
test('allows plaintext localhost only when explicitly enabled', () {
for (final url in ['ws://localhost:3000', 'ws://relay.localhost:3000']) {
expect(
() => validateInviteRelayUri(
Uri.parse(url),
allowInsecureLocalhost: true,
),
returnsNormally,
reason: url,
);
expect(
() => validateInviteRelayUri(
Uri.parse(url),
allowInsecureLocalhost: false,
),
throwsFormatException,
reason: url,
);
}
});
test('rejects plaintext public relays', () {
expect(
() => validateInviteRelayUri(
Uri.parse('ws://relay.example.com'),
allowInsecureLocalhost: false,
),
throwsFormatException,
);
});
test('rejects non-public IPv4 literals', () {
for (final host in [
'0.0.0.0',
'10.0.0.1',
'100.64.0.1',
'127.0.0.1',
'169.254.169.254',
'172.16.0.1',
'192.168.0.1',
'198.18.0.1',
'224.0.0.1',
]) {
expect(
() => validateInviteRelayUri(
Uri.parse('wss://$host'),
allowInsecureLocalhost: false,
),
throwsFormatException,
reason: host,
);
}
});
test('rejects non-public IPv6 literals and mapped IPv4', () {
for (final host in [
'[::]',
'[::1]',
'[::ffff:127.0.0.1]',
'[::ffff:169.254.169.254]',
'[::ffff:a9fe:a9fe]',
'[64:ff9b::a9fe:a9fe]',
'[100::1]',
'[100:0:0:1::1]',
'[2001::1]',
'[2001:1::4]',
'[2001:2::1]',
'[2001:4:111::1]',
'[2001:10::1]',
'[2001:40::1]',
'[2001:db8::1]',
'[2002:a9fe:a9fe::1]',
'[3fff::1]',
'[3fff:fff::1]',
'[5f00::1]',
'[fc00::1]',
'[fd00::1]',
'[fe80::1]',
'[fec0::1]',
'[ff02::1]',
]) {
expect(
() => validateInviteRelayUri(
Uri.parse('wss://$host'),
allowInsecureLocalhost: false,
),
throwsFormatException,
reason: host,
);
}
});
test('rejects legacy numeric IPv4 spellings', () {
for (final host in ['2130706433', '0x7f000001', '0177.0.0.1', '127.1']) {
expect(
() => validateInviteRelayUri(
Uri.parse('wss://$host'),
allowInsecureLocalhost: false,
),
throwsFormatException,
reason: host,
);
}
});
test('rejects non-origin URLs', () {
for (final url in [
'https://relay.example.com',
'wss://user@relay.example.com',
'wss://relay.example.com/path',
'wss://relay.example.com?query=x',
'wss://relay.example.com#fragment',
]) {
expect(
() => validateInviteRelayUri(
Uri.parse(url),
allowInsecureLocalhost: false,
),
throwsFormatException,
reason: url,
);
}
});
});
}