#NEWLINE# def test_grant_and_revoke_role( self ) : #NEWLINE# #INDENT# user_db = UserDB ( name = 'test-user-1' ) #NEWLINE# user_db = User . add_or_update ( user_db ) #NEWLINE# role_dbs = rbac_services . get_roles_for_user ( user_db = user_db ) #NEWLINE# self . assertItemsEqual ( role_dbs , [ ] ) #NEWLINE# role_dbs = user_db . get_roles ( ) #NEWLINE# self . assertItemsEqual ( role_dbs , [ ] ) #NEWLINE# rbac_services . assign_role_to_user ( role_db = self . roles [ 'custom_role_1' ] , user_db = user_db ) #NEWLINE# role_dbs = rbac_services . get_roles_for_user ( user_db = user_db ) #NEWLINE# self . assertItemsEqual ( role_dbs , [ self . roles [ 'custom_role_1' ] ] ) #NEWLINE# role_dbs = user_db . get_roles ( ) #NEWLINE# self . assertItemsEqual ( role_dbs , [ self . roles [ 'custom_role_1' ] ] ) #NEWLINE# rbac_services . revoke_role_from_user ( role_db = self . roles [ 'custom_role_1' ] , user_db = user_db ) #NEWLINE# role_dbs = rbac_services . get_roles_for_user ( user_db = user_db ) #NEWLINE# self . assertItemsEqual ( role_dbs , [ ] ) #NEWLINE# role_dbs = user_db . get_roles ( ) #NEWLINE# self . assertItemsEqual ( role_dbs , [ ] )