Skip to content

Commit 51210f3

Browse files
committed
[red] require synchronized app 0.2.0 identity
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent 5453c58 commit 51210f3

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

‎app/test/integration/github_import_integration_test.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:flutter_test/flutter_test.dart';
1212
import 'package:http/http.dart' as http;
1313
import 'package:http/testing.dart';
1414

15+
import 'package:pyble/app/app_info.dart';
1516
import 'package:pyble/github_import/github_import.dart';
1617
import 'package:pyble/pble/pble.dart';
1718

@@ -136,7 +137,7 @@ void _expectUnauthenticatedApiRequest(
136137
expect(request.maxRedirects, 0);
137138
expect(request.headers['Accept'], 'application/vnd.github+json');
138139
expect(request.headers['X-GitHub-Api-Version'], '2026-03-10');
139-
expect(request.headers['User-Agent'], startsWith('PyBLE/'));
140+
expect(request.headers['User-Agent'], '$kAppName/$kAppVersion');
140141
final Set<String> headerNames = request.headers.keys
141142
.map((String name) => name.toLowerCase())
142143
.toSet();
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-License-Identifier: MIT
2+
// Part of PyBLE (https://pyble.dev) — see /LICENSE.
3+
//
4+
// BLD-3 [red] — one mechanically checked app identity spans package metadata,
5+
// PBLE/1 HELLO, and public GitHub requests (ADR-0044).
6+
7+
import 'dart:io';
8+
9+
import 'package:flutter_test/flutter_test.dart';
10+
11+
import 'package:pyble/app/app_info.dart';
12+
13+
import '../support/repo_paths.dart';
14+
15+
void main() {
16+
test('app 0.2.0 beta starts at globally monotonic build 5', () {
17+
final String pubspec = File(
18+
'${appPackageRoot().path}/pubspec.yaml',
19+
).readAsStringSync();
20+
final List<RegExpMatch> declarations = RegExp(
21+
r'^version:\s*((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))\+([1-9]\d*)\s*$',
22+
multiLine: true,
23+
).allMatches(pubspec).toList(growable: false);
24+
25+
expect(
26+
declarations,
27+
hasLength(1),
28+
reason: 'pubspec must declare one canonical SemVer+positiveBuild value',
29+
);
30+
final RegExpMatch declaration = declarations.single;
31+
32+
expect(declaration.group(1), '0.2.0');
33+
expect(declaration.group(2), '5');
34+
expect(
35+
kAppVersion,
36+
declaration.group(1),
37+
reason: 'PBLE/1 HELLO must match the package base version exactly',
38+
);
39+
});
40+
}

‎app/test/unit/github_repository_client_test.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'package:flutter_test/flutter_test.dart';
1414
import 'package:http/http.dart' as http;
1515
import 'package:http/testing.dart';
1616

17+
import 'package:pyble/app/app_info.dart';
1718
import 'package:pyble/github_import/github_import.dart';
1819

1920
const String _commitSha = '1111111111111111111111111111111111111111';
@@ -89,7 +90,7 @@ void _expectGitHubRequest(http.Request request) {
8990
expect(request.url.hasPort, isFalse);
9091
expect(request.headers['Accept'], 'application/vnd.github+json');
9192
expect(request.headers['X-GitHub-Api-Version'], '2026-03-10');
92-
expect(request.headers['User-Agent'], startsWith('PyBLE/'));
93+
expect(request.headers['User-Agent'], '$kAppName/$kAppVersion');
9394
expect(request.headers.containsKey('Authorization'), isFalse);
9495
expect(request.headers.containsKey('Cookie'), isFalse);
9596
}

0 commit comments

Comments
 (0)