map_url-Kartenintegration zurückgenommen und Version auf 358 angehoben
This commit is contained in:
1 parent
d585da11b5
commit
684e8a57fc
18 files changed
+24
-560
No files matched your search
@@ -1,82 +0,0 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stadtbote/tools/vhs_map_access.dart';
|
||||
|
||||
void main() {
|
||||
group('VHS-Kartenlink', () {
|
||||
test('erlaubt HTTPS inklusive Kartenparameter und Fragment', () {
|
||||
final access = VhsMapAccess(
|
||||
Uri.parse('https://vhs.example/map?job=42#courier'),
|
||||
);
|
||||
expect(access.isValid, isTrue);
|
||||
});
|
||||
|
||||
test('weist unsichere und unvollständige Links zurück', () {
|
||||
for (final url in [
|
||||
'http://vhs.example/map',
|
||||
'/map?job=42',
|
||||
'//vhs.example/map',
|
||||
'javascript:alert(1)',
|
||||
'https:///map',
|
||||
'https://user:password@vhs.example/map',
|
||||
'https://vhs.example:0/map',
|
||||
'https://vhs.example:65536/map',
|
||||
]) {
|
||||
expect(VhsMapAccess(Uri.parse(url)).isValid, isFalse, reason: url);
|
||||
}
|
||||
});
|
||||
|
||||
test('erlaubt Navigation nur innerhalb derselben HTTPS-Origin', () {
|
||||
final access = VhsMapAccess(Uri.parse('https://vhs.example/map?job=42'));
|
||||
expect(
|
||||
access.allowsNavigation(Uri.parse('https://vhs.example:443/other')),
|
||||
isTrue,
|
||||
);
|
||||
for (final url in [
|
||||
'http://vhs.example/map',
|
||||
'https://other.example/map',
|
||||
'https://vhs.example.other.example/map',
|
||||
'https://vhs.example:8443/map',
|
||||
'https://user@vhs.example/map',
|
||||
'file:///map',
|
||||
]) {
|
||||
expect(access.allowsNavigation(Uri.parse(url)), isFalse, reason: url);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
group('VHS-Anmeldung', () {
|
||||
test('sendet Zugangsdaten nur an den exakten Kartenhost', () {
|
||||
final access = VhsMapAccess(Uri.parse('https://vhs.example/map'));
|
||||
expect(access.allowsAuthentication('VHS.EXAMPLE'), isTrue);
|
||||
for (final host in [
|
||||
'other.example',
|
||||
'vhs.example.other.example',
|
||||
'sub.vhs.example',
|
||||
'',
|
||||
]) {
|
||||
expect(access.allowsAuthentication(host), isFalse, reason: host);
|
||||
}
|
||||
expect(
|
||||
VhsMapAccess(
|
||||
Uri.parse('http://vhs.example'),
|
||||
).allowsAuthentication('vhs.example'),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('begrenzt wiederholte Authentifizierungsanfragen', () {
|
||||
final access = VhsMapAccess(Uri.parse('https://vhs.example/map'));
|
||||
expect(access.tryAuthentication('other.example'), isFalse);
|
||||
for (
|
||||
var attempt = 0;
|
||||
attempt < VhsMapAccess.maxAuthenticationAttempts;
|
||||
attempt++
|
||||
) {
|
||||
expect(access.tryAuthentication('vhs.example'), isTrue);
|
||||
}
|
||||
expect(access.tryAuthentication('vhs.example'), isFalse);
|
||||
expect(access.tryAuthentication('vhs.example'), isFalse);
|
||||
expect(VhsMapAccess(access.uri).tryAuthentication('vhs.example'), isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user