33 lines
836 B
Dart
33 lines
836 B
Dart
import 'package:dsh_workbench/config.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
test('接受 HTTPS 站点及端口、路径', () {
|
|
for (final url in [
|
|
'https://panel.example.com',
|
|
'https://host:8443/panel/',
|
|
]) {
|
|
expect(isValidSiteUrl(url), isTrue);
|
|
}
|
|
});
|
|
test('拒绝无效站点地址', () {
|
|
for (final url in [
|
|
'',
|
|
'http://host',
|
|
'host',
|
|
'https://',
|
|
'https://user:pass@host',
|
|
'https://host?q=1',
|
|
'https://host/#x',
|
|
'https://host:99999',
|
|
'https://ho st',
|
|
'https://host\n',
|
|
]) {
|
|
expect(isValidSiteUrl(url), isFalse, reason: url);
|
|
}
|
|
});
|
|
test('构建注入的地址有效(普通单测允许未配置)', () {
|
|
if (kSiteUrl.isNotEmpty) expect(isValidSiteUrl(kSiteUrl), isTrue);
|
|
});
|
|
}
|