Unverified Commit 93b358f9 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

fix cast error in codesign sub-command (#86890)

parent 03de6166
...@@ -316,10 +316,16 @@ class CodesignCommand extends Command<void> { ...@@ -316,10 +316,16 @@ class CodesignCommand extends Command<void> {
'Test failed because unexpected binaries found in the cache.'); 'Test failed because unexpected binaries found in the cache.');
} }
final String? desiredRevision = argResults![kRevision] as String?;
if (desiredRevision == null) {
stdio.printStatus( stdio.printStatus(
'Verified that binaries for commit ${argResults![kRevision] as String} are codesigned and have ' 'Verified that binaries are codesigned and have expected entitlements.');
} else {
stdio.printStatus(
'Verified that binaries for commit $desiredRevision are codesigned and have '
'expected entitlements.'); 'expected entitlements.');
} }
}
List<String>? _allBinaryPaths; List<String>? _allBinaryPaths;
......
...@@ -81,6 +81,90 @@ void main() { ...@@ -81,6 +81,90 @@ void main() {
); );
}); });
test('does not fail if --revision flag not provided', () async {
final List<FakeCommand> codesignCheckCommands = <FakeCommand>[];
for (final String bin in binariesWithEntitlements) {
codesignCheckCommands.add(
FakeCommand(
command: <String>['codesign', '-vvv', bin],
),
);
codesignCheckCommands.add(
FakeCommand(
command: <String>['codesign', '--display', '--entitlements', ':-', bin],
stdout: expectedEntitlements.join('\n'),
),
);
}
for (final String bin in binariesWithoutEntitlements) {
codesignCheckCommands.add(
FakeCommand(
command: <String>['codesign', '-vvv', bin],
),
);
}
createRunner(commands: <FakeCommand>[
const FakeCommand(command: <String>[
'git',
'clone',
'--origin',
'upstream',
'--',
'file://$flutterRoot/',
'${checkoutsParentDirectory}flutter_conductor_checkouts/framework',
]),
const FakeCommand(command: <String>[
'git',
'rev-parse',
'HEAD',
], stdout: revision),
const FakeCommand(command: <String>[
'git',
'rev-parse',
'HEAD',
], stdout: revision),
const FakeCommand(command: <String>[
'git',
'checkout',
revision,
]),
const FakeCommand(command: <String>[
flutterBin,
'help',
]),
const FakeCommand(command: <String>[
flutterBin,
'help',
]),
const FakeCommand(command: <String>[
flutterBin,
'precache',
'--android',
'--ios',
'--macos',
]),
FakeCommand(
command: const <String>[
'find',
'${checkoutsParentDirectory}flutter_conductor_checkouts/framework/bin/cache',
'-type',
'f',
],
stdout: allBinaries.join('\n'),
),
for (String bin in allBinaries)
FakeCommand(
command: <String>['file', '--mime-type', '-b', bin],
stdout: 'application/x-mach-binary',
),
...codesignCheckCommands,
]);
await runner.run(<String>['codesign', '--$kVerify']);
expect(processManager.hasRemainingExpectations, false);
expect(stdio.stdout, contains('Verified that binaries are codesigned and have expected entitlements'));
});
test('succeeds if every binary is codesigned and has correct entitlements', () async { test('succeeds if every binary is codesigned and has correct entitlements', () async {
final List<FakeCommand> codesignCheckCommands = <FakeCommand>[]; final List<FakeCommand> codesignCheckCommands = <FakeCommand>[];
for (final String bin in binariesWithEntitlements) { for (final String bin in binariesWithEntitlements) {
...@@ -156,6 +240,7 @@ void main() { ...@@ -156,6 +240,7 @@ void main() {
]); ]);
await runner.run(<String>['codesign', '--$kVerify', '--$kRevision', revision]); await runner.run(<String>['codesign', '--$kVerify', '--$kRevision', revision]);
expect(processManager.hasRemainingExpectations, false); expect(processManager.hasRemainingExpectations, false);
expect(stdio.stdout, contains('Verified that binaries for commit $revision are codesigned and have expected entitlements'));
}); });
test('fails if a single binary is not codesigned', () async { test('fails if a single binary is not codesigned', () async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment