Guess sign iOS with the first certificate when running in machine mode (#10870)
* Guess sign with the first certificate when multiple are available in machine mode * review
This commit is contained in:
@@ -38,7 +38,7 @@ void main() {
|
||||
|
||||
testUsingContext('No auto-sign if Xcode project settings are not available', () async {
|
||||
app = new BuildableIOSApp(projectBundleId: 'test.app');
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(app);
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app);
|
||||
expect(developmentTeam, isNull);
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ void main() {
|
||||
'DEVELOPMENT_TEAM': 'abc',
|
||||
},
|
||||
);
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(app);
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app);
|
||||
expect(developmentTeam, isNull);
|
||||
expect(testLogger.statusText, equals(
|
||||
'Automatically signing iOS for device deployment using specified development team in Xcode project: abc\n'
|
||||
@@ -59,7 +59,7 @@ void main() {
|
||||
testUsingContext('No auto-sign if security or openssl not available', () async {
|
||||
when(mockProcessManager.runSync(<String>['which', 'security']))
|
||||
.thenReturn(exitsFail);
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(app);
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app);
|
||||
expect(developmentTeam, isNull);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
@@ -77,7 +77,7 @@ void main() {
|
||||
|
||||
String developmentTeam;
|
||||
try {
|
||||
developmentTeam = await getCodeSigningIdentityDevelopmentTeam(app);
|
||||
developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app);
|
||||
fail('No identity should throw tool error');
|
||||
} on ToolExit {
|
||||
expect(developmentTeam, isNull);
|
||||
@@ -131,7 +131,7 @@ void main() {
|
||||
when(mockProcess.stderr).thenReturn(mockStdErr);
|
||||
when(mockProcess.exitCode).thenReturn(0);
|
||||
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(app);
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app);
|
||||
|
||||
expect(testLogger.statusText, contains('iPhone Developer: Profile 1 (1111AAAA11)'));
|
||||
expect(testLogger.errorText, isEmpty);
|
||||
@@ -189,7 +189,7 @@ void main() {
|
||||
when(mockOpenSslProcess.stderr).thenReturn(mockOpenSslStdErr);
|
||||
when(mockOpenSslProcess.exitCode).thenReturn(0);
|
||||
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(app);
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app);
|
||||
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
@@ -211,6 +211,68 @@ void main() {
|
||||
AnsiTerminal: () => testTerminal,
|
||||
});
|
||||
|
||||
testUsingContext('Test multiple identity in machine mode works', () async {
|
||||
when(mockProcessManager.runSync(<String>['which', 'security']))
|
||||
.thenReturn(exitsHappy);
|
||||
when(mockProcessManager.runSync(<String>['which', 'openssl']))
|
||||
.thenReturn(exitsHappy);
|
||||
when(mockProcessManager.runSync(
|
||||
argThat(contains('find-identity')), environment: any, workingDirectory: any,
|
||||
)).thenReturn(new ProcessResult(
|
||||
1, // pid
|
||||
0, // exitCode
|
||||
'''
|
||||
1) 86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 "iPhone Developer: Profile 1 (1111AAAA11)"
|
||||
2) da4b9237bacccdf19c0760cab7aec4a8359010b0 "iPhone Developer: Profile 2 (2222BBBB22)"
|
||||
3) 5bf1fd927dfb8679496a2e6cf00cbe50c1c87145 "iPhone Developer: Profile 3 (3333CCCC33)"
|
||||
3 valid identities found''',
|
||||
''
|
||||
));
|
||||
mockTerminalStdInStream =
|
||||
new Stream<String>.fromFuture(new Future<String>.error(new Exception('Cannot read from StdIn')));
|
||||
when(mockProcessManager.runSync(
|
||||
<String>['security', 'find-certificate', '-c', '1111AAAA11', '-p'],
|
||||
environment: any,
|
||||
workingDirectory: any,
|
||||
)).thenReturn(new ProcessResult(
|
||||
1, // pid
|
||||
0, // exitCode
|
||||
'This is a mock certificate',
|
||||
'',
|
||||
));
|
||||
|
||||
final MockProcess mockOpenSslProcess = new MockProcess();
|
||||
final MockStdIn mockOpenSslStdIn = new MockStdIn();
|
||||
final MockStream mockOpenSslStdErr = new MockStream();
|
||||
|
||||
when(mockProcessManager.start(
|
||||
argThat(contains('openssl')), environment: any, workingDirectory: any,
|
||||
)).thenReturn(new Future<Process>.value(mockOpenSslProcess));
|
||||
|
||||
when(mockOpenSslProcess.stdin).thenReturn(mockOpenSslStdIn);
|
||||
when(mockOpenSslProcess.stdout).thenReturn(new Stream<List<int>>.fromFuture(
|
||||
new Future<List<int>>.value(UTF8.encode(
|
||||
'subject= /CN=iPhone Developer: Profile 1 (1111AAAA11)/OU=5555EEEE55/O=My Team/C=US'
|
||||
)),
|
||||
));
|
||||
when(mockOpenSslProcess.stderr).thenReturn(mockOpenSslStdErr);
|
||||
when(mockOpenSslProcess.exitCode).thenReturn(0);
|
||||
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app, usesTerminalUi: false);
|
||||
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
contains('Signing iOS app for device deployment using developer identity: "iPhone Developer: Profile 1 (1111AAAA11)"'),
|
||||
);
|
||||
expect(testLogger.errorText, isEmpty);
|
||||
verify(mockOpenSslStdIn.write('This is a mock certificate'));
|
||||
expect(developmentTeam, '5555EEEE55');
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
AnsiTerminal: () => testTerminal,
|
||||
});
|
||||
|
||||
testUsingContext('Test saved certificate used', () async {
|
||||
when(mockProcessManager.runSync(<String>['which', 'security']))
|
||||
.thenReturn(exitsHappy);
|
||||
@@ -257,7 +319,7 @@ void main() {
|
||||
when(mockOpenSslProcess.exitCode).thenReturn(0);
|
||||
when(mockConfig.getValue('ios-signing-cert')).thenReturn('iPhone Developer: Profile 3 (3333CCCC33)');
|
||||
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(app);
|
||||
final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app);
|
||||
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
|
||||
Reference in New Issue
Block a user