Exemple #1
0
 def test_retrieve_user(self):
     with mock.patch('lizard_auth_client.client._do_post', return_value={
             'success': True,
             'user': {'username': '******'}}):
         user_data = client.sso_get_user_django('root')
         logger.debug(pprint.pformat(user_data))
         self.assertEqual(user_data['username'], 'root')
 def handle(self, *args, **options):
     """
     """
     sso_user = options.get('sso_user')
     if not sso_user:
         msg = '[E] Please provide the username for the user ' \
               'you are trying to sync.'
         raise Exception(msg)
     if V:
         print("[*] About to SSO-sync data for a User "
               "with username '%s'..." % sso_user)
     try:
         user_data = sso_get_user_django(sso_user)
         if V:
             print("[+] Received serialized User object: %s"
                   % str(user_data))
         user = construct_user(user_data)
         if V:
             print("[+] OK, build User instance: %s" % str(user))
         user.save()
         if V:
             print("[+] OK, succesfully saved this User instance!")
     except Exception as err:
         print("[E] err = '%s'" % str(err))