@@ -71,6 +71,51 @@ public void GetAllUsers()
71
71
Log ( "The test for Get-AzureRemoteAppUser with {0} users completed successfully." , countOfExpectedUsers ) ;
72
72
}
73
73
74
+ [ Fact ]
75
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
76
+ public void GetAllUsersForApp ( )
77
+ {
78
+ int countOfExpectedUsers = 0 ;
79
+ GetAzureRemoteAppUser MockCmdlet = SetUpTestCommon < GetAzureRemoteAppUser > ( ) ;
80
+
81
+ // Required parameters for this test
82
+ MockCmdlet . CollectionName = collectionName ;
83
+ MockCmdlet . Alias = appAlias ;
84
+
85
+ // Setup the environment for testing this cmdlet
86
+ MockObject . SetUpDefaultRemoteAppCollectionByName ( remoteAppManagementClientMock , collectionName ) ;
87
+ countOfExpectedUsers = MockObject . SetUpRemoteAppSecurityPrincipalsForApp ( remoteAppManagementClientMock , collectionName , appAlias , userName ) ;
88
+ MockCmdlet . ResetPipelines ( ) ;
89
+
90
+ Log ( "Calling Get-AzureRemoteAppUser which should have {0} users." , countOfExpectedUsers ) ;
91
+
92
+ MockCmdlet . ExecuteCmdlet ( ) ;
93
+ if ( MockCmdlet . runTime ( ) . ErrorStream . Count != 0 )
94
+ {
95
+ Assert . True ( false ,
96
+ String . Format ( "Get-AzureRemoteAppUser returned the following error {0}." ,
97
+ MockCmdlet . runTime ( ) . ErrorStream [ 0 ] . Exception . Message
98
+ )
99
+ ) ;
100
+ }
101
+
102
+ List < ConsentStatusModel > users = MockObject . ConvertList < ConsentStatusModel > ( MockCmdlet . runTime ( ) . OutputPipeline ) ;
103
+ Assert . NotNull ( users ) ;
104
+
105
+ Assert . True ( users . Count == countOfExpectedUsers ,
106
+ String . Format ( "The expected number of users returned {0} does not match the actual {1}." ,
107
+ countOfExpectedUsers ,
108
+ users . Count
109
+ )
110
+ ) ;
111
+
112
+ Assert . True ( MockObject . ContainsExpectedServicePrincipalList ( MockObject . mockUsersConsents , users ) ,
113
+ "The actual result does not match the expected"
114
+ ) ;
115
+
116
+ Log ( "The test for Get-AzureRemoteAppUser with {0} users completed successfully." , countOfExpectedUsers ) ;
117
+ }
118
+
74
119
[ Fact ]
75
120
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
76
121
public void GetUsersByName ( )
@@ -206,6 +251,97 @@ public void AddOrgIDUserThatDoesntExist()
206
251
Log ( "The test for Add-AzureRemoteAppOrgIDUser successfully added {0} users the new count is {1}." , countOfNewUsers , countOfExistingUsers + countOfNewUsers ) ;
207
252
}
208
253
254
+ [ Fact ]
255
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
256
+ public void AddUsersToApp ( )
257
+ {
258
+ int countOfExistingUsers = 0 ;
259
+ int countOfNewUsers = 0 ;
260
+ AddAzureRemoteAppUser MockCmdlet = SetUpTestCommon < AddAzureRemoteAppUser > ( ) ;
261
+
262
+ // Required parameters for this test
263
+ MockCmdlet . CollectionName = collectionName ;
264
+ MockCmdlet . Alias = appAlias ;
265
+ MockCmdlet . Type = PrincipalProviderType . OrgId ;
266
+ MockCmdlet . UserUpn = new string [ ]
267
+ {
268
+ "testUser1" ,
269
+ "testUser2" ,
270
+ } ;
271
+
272
+ // Setup the environment for testing this cmdlet
273
+ MockObject . SetUpDefaultRemoteAppCollectionByName ( remoteAppManagementClientMock , collectionName ) ;
274
+ countOfExistingUsers = MockObject . SetUpDefaultRemoteAppSecurityPrincipals ( remoteAppManagementClientMock , collectionName , userName ) ;
275
+ countOfNewUsers = MockObject . SetUpRemoteAppUserToAddForApp ( remoteAppManagementClientMock , collectionName , appAlias , PrincipalProviderType . OrgId , MockCmdlet . UserUpn ) ;
276
+ MockCmdlet . ResetPipelines ( ) ;
277
+
278
+ Log ( "Calling Add-AzureRemoteAppOrgIDUser and adding {0} users." , countOfNewUsers ) ;
279
+
280
+ MockCmdlet . ExecuteCmdlet ( ) ;
281
+ if ( MockCmdlet . runTime ( ) . ErrorStream . Count != 0 )
282
+ {
283
+ Assert . True ( false ,
284
+ String . Format ( "Add-AzureRemoteAppOrgIDUser returned the following error {0}." ,
285
+ MockCmdlet . runTime ( ) . ErrorStream [ 0 ] . Exception . Message
286
+ )
287
+ ) ;
288
+ }
289
+
290
+ List < SecurityPrincipalOperationsResult > status = MockObject . ConvertList < SecurityPrincipalOperationsResult > ( MockCmdlet . runTime ( ) . OutputPipeline ) ;
291
+ Assert . NotNull ( status ) ;
292
+
293
+ Assert . True ( MockObject . HasExpectedResults < SecurityPrincipalOperationsResult > ( status , MockObject . ContainsExpectedStatus ) ,
294
+ "The actual result does not match the expected."
295
+ ) ;
296
+
297
+ Log ( "The test for Add-AzureRemoteAppOrgIDUser successfully added {0} users the new count is {1}." , countOfNewUsers , countOfExistingUsers + countOfNewUsers ) ;
298
+ }
299
+
300
+ [ Fact ]
301
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
302
+ public void RemoveUserThatExistsFromApp ( )
303
+ {
304
+ int countOfExistingUsers = 0 ;
305
+ int countOfDeletedUsers = 0 ;
306
+ RemoveAzureRemoteAppUser MockCmdlet = SetUpTestCommon < RemoveAzureRemoteAppUser > ( ) ;
307
+
308
+ // Required parameters for this test
309
+ MockCmdlet . CollectionName = collectionName ;
310
+ MockCmdlet . Alias = appAlias ;
311
+ MockCmdlet . Type = PrincipalProviderType . OrgId ;
312
+ MockCmdlet . UserUpn = new string [ ]
313
+ {
314
+ userName
315
+ } ;
316
+
317
+ // Setup the environment for testing this cmdlet
318
+ MockObject . SetUpDefaultRemoteAppCollectionByName ( remoteAppManagementClientMock , collectionName ) ;
319
+ countOfExistingUsers = MockObject . SetUpDefaultRemoteAppSecurityPrincipals ( remoteAppManagementClientMock , collectionName , userName ) ;
320
+ countOfDeletedUsers = MockObject . SetUpRemoteAppUserToRemoveFromApp ( remoteAppManagementClientMock , collectionName , appAlias , PrincipalProviderType . OrgId , MockCmdlet . UserUpn ) ;
321
+ MockCmdlet . ResetPipelines ( ) ;
322
+
323
+ Log ( "Calling Remove-AzureRemoteAppOrgIdUser and removing {0} users." , countOfDeletedUsers ) ;
324
+
325
+ MockCmdlet . ExecuteCmdlet ( ) ;
326
+ if ( MockCmdlet . runTime ( ) . ErrorStream . Count != 0 )
327
+ {
328
+ Assert . True ( false ,
329
+ String . Format ( "Remove-AzureRemoteAppMSAUser returned the following error {0}." ,
330
+ MockCmdlet . runTime ( ) . ErrorStream [ 0 ] . Exception . Message
331
+ )
332
+ ) ;
333
+ }
334
+
335
+ List < SecurityPrincipalOperationsResult > status = MockObject . ConvertList < SecurityPrincipalOperationsResult > ( MockCmdlet . runTime ( ) . OutputPipeline ) ;
336
+ Assert . NotNull ( status ) ;
337
+
338
+ Assert . True ( MockObject . HasExpectedResults < SecurityPrincipalOperationsResult > ( status , MockObject . ContainsExpectedStatus ) ,
339
+ "The actual result does not match the expected."
340
+ ) ;
341
+
342
+ Log ( "The test for Remove-AzureRemoteAppOrgIdUser successfully removed {0} users the new count is {1}." , countOfDeletedUsers , countOfExistingUsers - countOfDeletedUsers ) ;
343
+ }
344
+
209
345
[ Fact ]
210
346
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
211
347
public void RemoveMSAUserThatExists ( )
0 commit comments