def test_sync_user_roles__standard_user(self): user_model.User.get_user('standard-user@{}'.format(loanertest.USER_DOMAIN)) sync_users.sync_user_roles() self.make_assertions( 'standard-user@{}'.format(loanertest.USER_DOMAIN), [], False)
def test_sync_user_roles__superadmin(self): user_model.User.get_user('need-superadmin@{}'.format( loanertest.USER_DOMAIN)) user_model.User.get_user('remove-superadmin@{}'.format( loanertest.USER_DOMAIN)).update(superadmin=True) user_model.User.get_user('keep-superadmin@{}'.format( loanertest.USER_DOMAIN)).update(superadmin=True) sync_users.sync_user_roles() self.make_assertions( 'need-superadmin@{}'.format(loanertest.USER_DOMAIN), [], True) self.make_assertions( 'remove-superadmin@{}'.format(loanertest.USER_DOMAIN), [], False) self.make_assertions( 'keep-superadmin@{}'.format(loanertest.USER_DOMAIN), [], True)
def test_sync_User_roles__role(self): user_model.User.get_user('need-technician@{}'.format( loanertest.USER_DOMAIN)) user_model.User.get_user('remove-technician@{}'.format( loanertest.USER_DOMAIN)).update(roles=['technician']) user_model.User.get_user('keep-technician@{}'.format( loanertest.USER_DOMAIN)).update(roles=['technician']) sync_users.sync_user_roles() self.make_assertions( 'need-technician@{}'.format(loanertest.USER_DOMAIN), ['technician'], False) self.make_assertions( 'remove-technician@{}'.format(loanertest.USER_DOMAIN), [], False) self.make_assertions( 'keep-technician@{}'.format(loanertest.USER_DOMAIN), ['technician'], False)
def _sync_roles_if_necessary(self): """Determines if user roles need to be synced before starting bootstrap.""" if not self.bootstrap_started and not self.bootstrap_completed: logging.info( 'Attempting to sync user roles before bootstrap takes place.') sync_users.sync_user_roles()
def get(self): """Get method for handler.""" sync_users.sync_user_roles()
def test_sync_user_roles(self, mock_directoryclass, mock_logging_info): del mock_directoryclass # Unused. sync_users.sync_user_roles() mock_logging_info.assert_called_once()