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,51 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stadtbote/model/job.dart';
|
||||
|
||||
void main() {
|
||||
group('Job map_url', () {
|
||||
test('erhält die Server-URL einschließlich Query und Fragment', () {
|
||||
const mapUrl = 'https://vhs.example.invalid/map?job=21891302#courier';
|
||||
final payload = _jobPayload()..['map_url'] = mapUrl;
|
||||
|
||||
final job = Job.fromJson(payload);
|
||||
final serialized =
|
||||
jsonDecode(jsonEncode(job.toJson())) as Map<String, dynamic>;
|
||||
final restored = Job.fromJson(serialized);
|
||||
|
||||
expect(job.mapUrl, mapUrl);
|
||||
expect(serialized['map_url'], mapUrl);
|
||||
expect(restored.mapUrl, mapUrl);
|
||||
expect(restored.externalId, 21891302);
|
||||
});
|
||||
|
||||
test('liest ältere Aufträge ohne map_url weiterhin ein', () {
|
||||
final job = Job.fromJson(_jobPayload());
|
||||
final restored = Job.fromJson(job.toJson());
|
||||
|
||||
expect(job.mapUrl, isNull);
|
||||
expect(restored.mapUrl, isNull);
|
||||
expect(restored.externalId, 21891302);
|
||||
});
|
||||
|
||||
test('akzeptiert eine explizit fehlende map_url', () {
|
||||
final payload = _jobPayload()..['map_url'] = null;
|
||||
|
||||
expect(Job.fromJson(payload).mapUrl, isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Map<String, dynamic> _jobPayload() => {
|
||||
'id': 21891302,
|
||||
'ver': '0',
|
||||
'state': 0,
|
||||
'ordertime': 1791285073,
|
||||
'offs_warn': 0,
|
||||
'global': false,
|
||||
'vht_id': 2,
|
||||
'rem': '',
|
||||
'delayOrderTime': 0,
|
||||
'tours': <Map<String, dynamic>>[],
|
||||
};
|
||||
@@ -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