@@ -236,74 +236,49 @@ describe('MembershipService', function() {
236
236
// NOTE: ideally the above tests catch any issues as they do a better job of
237
237
// declaring intent, if not, this test will compare raw output.
238
238
it ( 'should build a map for the tabbed role list interface' , function ( ) {
239
- expect ( MembershipService . mapRolebindingsForUI ( roleBindings , keyedRoles ) )
240
- . toEqual ( [ {
241
- "kind" : "User" ,
242
- "sortOrder" : 1 ,
243
- "name" : "User" ,
244
- "subjects" : {
245
- "-jill" : {
246
- "name" : "jill" ,
247
- "roles" : {
248
- "ClusterRole-admin" : {
249
- "kind" : "ClusterRole" ,
250
- "metadata" : {
251
- "name" : "admin"
252
- }
253
- } ,
254
- "ClusterRole-view" : {
255
- "kind" : "ClusterRole" ,
256
- "metadata" : {
257
- "name" : "view"
258
- }
259
- }
260
- }
261
- } ,
262
- "-jack" : {
263
- "name" : "jack" ,
264
- "roles" : {
265
- "ClusterRole-edit" : {
266
- "kind" : "ClusterRole" ,
267
- "metadata" : {
268
- "name" : "edit"
269
- }
270
- }
271
- }
272
- }
273
- }
274
- } , {
275
- "kind" : "Group" ,
276
- "sortOrder" : 2 ,
277
- "name" : "Group" ,
278
- "subjects" : { }
279
- } , {
280
- "kind" : "ServiceAccount" ,
281
- "sortOrder" : 3 ,
282
- "description" : "Service accounts provide a flexible way to control API access without sharing a regular user’s credentials." ,
283
- "helpLinkKey" : "service_accounts" ,
284
- "name" : "ServiceAccount" ,
285
- "subjects" : {
286
- "fake-project-foo" : {
287
- "name" : "foo" ,
288
- "namespace" : "fake-project" ,
289
- "roles" : { }
290
- }
291
- }
292
- } , {
293
- "kind" : "SystemUser" ,
294
- "sortOrder" : 4 ,
295
- "description" : "System users are virtual users automatically provisioned by the system." ,
296
- "helpLinkKey" : "users_and_groups" ,
297
- "name" : "SystemUser" ,
298
- "subjects" : { }
299
- } , {
300
- "kind" : "SystemGroup" ,
301
- "sortOrder" : 5 ,
302
- "description" : "System groups are virtual groups automatically provisioned by the system." ,
303
- "helpLinkKey" : "users_and_groups" ,
304
- "name" : "SystemGroup" ,
305
- "subjects" : { }
306
- } ] ) ;
239
+
240
+ var mappedRoleBindings = MembershipService . mapRolebindingsForUI ( roleBindings , keyedRoles ) ;
241
+ var userBinding = mappedRoleBindings [ 0 ] ;
242
+ var groupBinding = mappedRoleBindings [ 1 ] ;
243
+ var serviceAccountBinding = mappedRoleBindings [ 2 ] ;
244
+ var systemUserBinding = mappedRoleBindings [ 3 ] ;
245
+ var systemGroupBinding = mappedRoleBindings [ 4 ] ;
246
+
247
+ expect ( userBinding . kind ) . toEqual ( 'User' ) ;
248
+ expect ( userBinding . sortOrder ) . toEqual ( 1 ) ;
249
+ expect ( userBinding . name ) . toEqual ( 'User' ) ;
250
+ expect ( _ . size ( userBinding . subjects ) ) . toEqual ( 2 ) ;
251
+ expect ( _ . map ( userBinding . subjects , 'name' ) ) . toEqual ( [ 'jill' , 'jack' ] ) ;
252
+ expect ( _ . keys ( userBinding . subjects [ '-jill' ] . roles ) ) . toEqual ( [ 'ClusterRole-admin' , 'ClusterRole-view' ] ) ;
253
+ expect ( _ . map ( userBinding . subjects [ '-jill' ] . roles , 'metadata.name' ) ) . toEqual ( [ 'admin' , 'view' ] ) ;
254
+ expect ( _ . keys ( userBinding . subjects [ '-jack' ] . roles ) ) . toEqual ( [ 'ClusterRole-edit' ] ) ;
255
+ expect ( _ . map ( userBinding . subjects [ '-jack' ] . roles , 'metadata.name' ) ) . toEqual ( [ 'edit' ] ) ;
256
+
257
+ expect ( groupBinding ) . toEqual ( {
258
+ kind : 'Group' ,
259
+ sortOrder : 2 ,
260
+ name : 'Group' ,
261
+ subjects : { }
262
+ } ) ;
263
+
264
+ expect ( serviceAccountBinding . kind ) . toEqual ( 'ServiceAccount' ) ;
265
+ expect ( serviceAccountBinding . sortOrder ) . toEqual ( 3 ) ;
266
+ expect ( serviceAccountBinding . description ) . toEqual ( 'Service accounts provide a flexible way to control API access without sharing a regular user’s credentials.' ) ;
267
+ expect ( serviceAccountBinding . name ) . toEqual ( 'ServiceAccount' ) ;
268
+ expect ( serviceAccountBinding . helpLinkKey ) . toEqual ( 'service_accounts' ) ;
269
+ expect ( serviceAccountBinding . subjects [ 'fake-project-foo' ] . name ) . toEqual ( 'foo' ) ;
270
+ expect ( serviceAccountBinding . subjects [ 'fake-project-foo' ] . namespace ) . toEqual ( 'fake-project' ) ;
271
+
272
+ expect ( systemUserBinding . kind ) . toEqual ( 'SystemUser' ) ;
273
+ expect ( systemUserBinding . sortOrder ) . toEqual ( 4 ) ;
274
+ expect ( systemUserBinding . description ) . toEqual ( 'System users are virtual users automatically provisioned by the system.' ) ;
275
+ expect ( systemUserBinding . helpLinkKey ) . toEqual ( 'users_and_groups' ) ;
276
+
277
+ expect ( systemGroupBinding . kind ) . toEqual ( 'SystemGroup' ) ;
278
+ expect ( systemGroupBinding . sortOrder ) . toEqual ( 5 ) ;
279
+ expect ( systemGroupBinding . description ) . toEqual ( 'System groups are virtual groups automatically provisioned by the system.' ) ;
280
+ expect ( systemGroupBinding . helpLinkKey ) . toEqual ( 'users_and_groups' ) ;
281
+
307
282
} ) ;
308
283
} ) ;
309
284
0 commit comments