@@ -38,7 +38,7 @@ void main() {
3838
3939 testUsingContext ('No auto-sign if Xcode project settings are not available' , () async {
4040 app = new BuildableIOSApp (projectBundleId: 'test.app' );
41- final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (app);
41+ final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (iosApp : app);
4242 expect (developmentTeam, isNull);
4343 });
4444
@@ -49,7 +49,7 @@ void main() {
4949 'DEVELOPMENT_TEAM' : 'abc' ,
5050 },
5151 );
52- final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (app);
52+ final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (iosApp : app);
5353 expect (developmentTeam, isNull);
5454 expect (testLogger.statusText, equals (
5555 'Automatically signing iOS for device deployment using specified development team in Xcode project: abc\n '
@@ -59,7 +59,7 @@ void main() {
5959 testUsingContext ('No auto-sign if security or openssl not available' , () async {
6060 when (mockProcessManager.runSync (< String > ['which' , 'security' ]))
6161 .thenReturn (exitsFail);
62- final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (app);
62+ final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (iosApp : app);
6363 expect (developmentTeam, isNull);
6464 },
6565 overrides: < Type , Generator > {
@@ -77,7 +77,7 @@ void main() {
7777
7878 String developmentTeam;
7979 try {
80- developmentTeam = await getCodeSigningIdentityDevelopmentTeam (app);
80+ developmentTeam = await getCodeSigningIdentityDevelopmentTeam (iosApp : app);
8181 fail ('No identity should throw tool error' );
8282 } on ToolExit {
8383 expect (developmentTeam, isNull);
@@ -131,7 +131,7 @@ void main() {
131131 when (mockProcess.stderr).thenReturn (mockStdErr);
132132 when (mockProcess.exitCode).thenReturn (0 );
133133
134- final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (app);
134+ final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (iosApp : app);
135135
136136 expect (testLogger.statusText, contains ('iPhone Developer: Profile 1 (1111AAAA11)' ));
137137 expect (testLogger.errorText, isEmpty);
@@ -189,7 +189,7 @@ void main() {
189189 when (mockOpenSslProcess.stderr).thenReturn (mockOpenSslStdErr);
190190 when (mockOpenSslProcess.exitCode).thenReturn (0 );
191191
192- final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (app);
192+ final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (iosApp : app);
193193
194194 expect (
195195 testLogger.statusText,
@@ -211,6 +211,68 @@ void main() {
211211 AnsiTerminal : () => testTerminal,
212212 });
213213
214+ testUsingContext ('Test multiple identity in machine mode works' , () async {
215+ when (mockProcessManager.runSync (< String > ['which' , 'security' ]))
216+ .thenReturn (exitsHappy);
217+ when (mockProcessManager.runSync (< String > ['which' , 'openssl' ]))
218+ .thenReturn (exitsHappy);
219+ when (mockProcessManager.runSync (
220+ argThat (contains ('find-identity' )), environment: any, workingDirectory: any,
221+ )).thenReturn (new ProcessResult (
222+ 1 , // pid
223+ 0 , // exitCode
224+ '''
225+ 1) 86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 "iPhone Developer: Profile 1 (1111AAAA11)"
226+ 2) da4b9237bacccdf19c0760cab7aec4a8359010b0 "iPhone Developer: Profile 2 (2222BBBB22)"
227+ 3) 5bf1fd927dfb8679496a2e6cf00cbe50c1c87145 "iPhone Developer: Profile 3 (3333CCCC33)"
228+ 3 valid identities found''' ,
229+ ''
230+ ));
231+ mockTerminalStdInStream =
232+ new Stream <String >.fromFuture (new Future <String >.error (new Exception ('Cannot read from StdIn' )));
233+ when (mockProcessManager.runSync (
234+ < String > ['security' , 'find-certificate' , '-c' , '1111AAAA11' , '-p' ],
235+ environment: any,
236+ workingDirectory: any,
237+ )).thenReturn (new ProcessResult (
238+ 1 , // pid
239+ 0 , // exitCode
240+ 'This is a mock certificate' ,
241+ '' ,
242+ ));
243+
244+ final MockProcess mockOpenSslProcess = new MockProcess ();
245+ final MockStdIn mockOpenSslStdIn = new MockStdIn ();
246+ final MockStream mockOpenSslStdErr = new MockStream ();
247+
248+ when (mockProcessManager.start (
249+ argThat (contains ('openssl' )), environment: any, workingDirectory: any,
250+ )).thenReturn (new Future <Process >.value (mockOpenSslProcess));
251+
252+ when (mockOpenSslProcess.stdin).thenReturn (mockOpenSslStdIn);
253+ when (mockOpenSslProcess.stdout).thenReturn (new Stream <List <int >>.fromFuture (
254+ new Future <List <int >>.value (UTF8 .encode (
255+ 'subject= /CN=iPhone Developer: Profile 1 (1111AAAA11)/OU=5555EEEE55/O=My Team/C=US'
256+ )),
257+ ));
258+ when (mockOpenSslProcess.stderr).thenReturn (mockOpenSslStdErr);
259+ when (mockOpenSslProcess.exitCode).thenReturn (0 );
260+
261+ final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (iosApp: app, usesTerminalUi: false );
262+
263+ expect (
264+ testLogger.statusText,
265+ contains ('Signing iOS app for device deployment using developer identity: "iPhone Developer: Profile 1 (1111AAAA11)"' ),
266+ );
267+ expect (testLogger.errorText, isEmpty);
268+ verify (mockOpenSslStdIn.write ('This is a mock certificate' ));
269+ expect (developmentTeam, '5555EEEE55' );
270+ },
271+ overrides: < Type , Generator > {
272+ ProcessManager : () => mockProcessManager,
273+ AnsiTerminal : () => testTerminal,
274+ });
275+
214276 testUsingContext ('Test saved certificate used' , () async {
215277 when (mockProcessManager.runSync (< String > ['which' , 'security' ]))
216278 .thenReturn (exitsHappy);
@@ -257,7 +319,7 @@ void main() {
257319 when (mockOpenSslProcess.exitCode).thenReturn (0 );
258320 when (mockConfig.getValue ('ios-signing-cert' )).thenReturn ('iPhone Developer: Profile 3 (3333CCCC33)' );
259321
260- final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (app);
322+ final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam (iosApp : app);
261323
262324 expect (
263325 testLogger.statusText,
0 commit comments