From 6cdf953241d4d4dde5602af6d39f42bbcef6aa1b Mon Sep 17 00:00:00 2001 From: xster Date: Thu, 27 Sep 2018 14:43:54 -0700 Subject: [PATCH] Revert "remove code signing special casing for Googlers (#22287)" (#22376) This reverts commit 1eb38abdb74e49287dcb18ab818e1a5a687ea4ba. --- .../lib/src/ios/code_signing.dart | 10 ++- .../test/ios/code_signing_test.dart | 63 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/ios/code_signing.dart b/packages/flutter_tools/lib/src/ios/code_signing.dart index f8788874a1..0774bf14b4 100644 --- a/packages/flutter_tools/lib/src/ios/code_signing.dart +++ b/packages/flutter_tools/lib/src/ios/code_signing.dart @@ -163,11 +163,19 @@ Future> getCodeSigningIdentityDevelopmentTeam({ if (await opensslProcess.exitCode != 0) return null; - return { + final Map signingConfigs = { 'DEVELOPMENT_TEAM': _certificateOrganizationalUnitExtractionPattern .firstMatch(opensslOutput) ?.group(1), }; + + if (opensslOutput.contains('iPhone Developer: Google Development')) { + signingConfigs['PROVISIONING_PROFILE_SPECIFIER'] = 'Google Development'; + signingConfigs['CODE_SIGN_STYLE'] = 'Manual'; + printStatus("Manually selecting Google's mobile provisioning profile (see go/google-flutter-signing)."); + } + + return signingConfigs; } Future _chooseSigningIdentity(List validCodeSigningIdentities, bool usesTerminalUi) async { diff --git a/packages/flutter_tools/test/ios/code_signing_test.dart b/packages/flutter_tools/test/ios/code_signing_test.dart index b8e8950a79..be540de1e0 100644 --- a/packages/flutter_tools/test/ios/code_signing_test.dart +++ b/packages/flutter_tools/test/ios/code_signing_test.dart @@ -149,6 +149,69 @@ void main() { ProcessManager: () => mockProcessManager, }); + testUsingContext('Test Google cert also manually selects a provisioning profile', () async { + when(mockProcessManager.runSync(['which', 'security'])) + .thenReturn(exitsHappy); + when(mockProcessManager.runSync(['which', 'openssl'])) + .thenReturn(exitsHappy); + when(mockProcessManager.runSync( + argThat(contains('find-identity')), + environment: anyNamed('environment'), + workingDirectory: anyNamed('workingDirectory'), + )).thenReturn(ProcessResult( + 1, // pid + 0, // exitCode + ''' +1) 86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 "iPhone Developer: Google Development (1111AAAA11)" + 1 valid identities found''', + '' + )); + when(mockProcessManager.runSync( + ['security', 'find-certificate', '-c', '1111AAAA11', '-p'], + environment: anyNamed('environment'), + workingDirectory: anyNamed('workingDirectory'), + )).thenReturn(ProcessResult( + 1, // pid + 0, // exitCode + 'This is a mock certificate', + '', + )); + + final MockProcess mockProcess = MockProcess(); + final MockStdIn mockStdIn = MockStdIn(); + final MockStream mockStdErr = MockStream(); + + when(mockProcessManager.start( + argThat(contains('openssl')), + environment: anyNamed('environment'), + workingDirectory: anyNamed('workingDirectory'), + )).thenAnswer((Invocation invocation) => Future.value(mockProcess)); + + when(mockProcess.stdin).thenReturn(mockStdIn); + when(mockProcess.stdout) + .thenAnswer((Invocation invocation) => Stream>.fromFuture( + Future>.value(utf8.encode( + 'subject= /CN=iPhone Developer: Google Development (1111AAAA11)/OU=3333CCCC33/O=My Team/C=US' + )) + )); + when(mockProcess.stderr).thenAnswer((Invocation invocation) => mockStdErr); + when(mockProcess.exitCode).thenAnswer((_) async => 0); + + final Map signingConfigs = await getCodeSigningIdentityDevelopmentTeam(iosApp: app); + + expect(testLogger.statusText, contains('iPhone Developer: Google Development (1111AAAA11)')); + expect(testLogger.errorText, isEmpty); + verify(mockStdIn.write('This is a mock certificate')); + expect(signingConfigs, { + 'DEVELOPMENT_TEAM': '3333CCCC33', + 'PROVISIONING_PROFILE_SPECIFIER': 'Google Development', + 'CODE_SIGN_STYLE': 'Manual', + }); + }, + overrides: { + ProcessManager: () => mockProcessManager, + }); + testUsingContext('Test multiple identity and certificate organization works', () async { when(mockProcessManager.runSync(['which', 'security'])) .thenReturn(exitsHappy);