Example #1
0
 def test_import_users_with_hash(self, user_mgt_app):
     _, recorder = _instrument_user_manager(user_mgt_app, 200, '{}')
     users = [
         auth.ImportUserRecord(uid='user1', password_hash=b'password'),
         auth.ImportUserRecord(uid='user2'),
     ]
     hash_alg = auth.UserImportHash.scrypt(b'key',
                                           rounds=8,
                                           memory_cost=14,
                                           salt_separator=b'sep')
     result = auth.import_users(users, hash_alg=hash_alg, app=user_mgt_app)
     assert result.success_count == 2
     assert result.failure_count is 0
     assert result.errors == []
     expected = {
         'users': [{
             'localId': 'user1',
             'passwordHash': _user_import.b64_encode(b'password')
         }, {
             'localId': 'user2'
         }],
         'hashAlgorithm':
         'SCRYPT',
         'signerKey':
         _user_import.b64_encode(b'key'),
         'rounds':
         8,
         'memoryCost':
         14,
         'saltSeparator':
         _user_import.b64_encode(b'sep'),
     }
     self._check_rpc_calls(recorder, expected)
Example #2
0
 def test_all_params(self):
     providers = [auth.UserProvider(uid='test', provider_id='google.com')]
     metadata = auth.UserMetadata(100, 150)
     user = auth.ImportUserRecord(uid='test',
                                  email='*****@*****.**',
                                  photo_url='https://test.com/user.png',
                                  phone_number='+1234567890',
                                  display_name='name',
                                  user_metadata=metadata,
                                  password_hash=b'password',
                                  password_salt=b'NaCl',
                                  custom_claims={'admin': True},
                                  email_verified=True,
                                  disabled=False,
                                  provider_data=providers)
     expected = {
         'localId': 'test',
         'email': '*****@*****.**',
         'photoUrl': 'https://test.com/user.png',
         'phoneNumber': '+1234567890',
         'displayName': 'name',
         'createdAt': 100,
         'lastLoginAt': 150,
         'passwordHash': _user_import.b64_encode(b'password'),
         'salt': _user_import.b64_encode(b'NaCl'),
         'customAttributes': json.dumps({'admin': True}),
         'emailVerified': True,
         'disabled': False,
         'providerUserInfo': [{
             'rawId': 'test',
             'providerId': 'google.com'
         }],
     }
     assert user.to_dict() == expected
 def test_scrypt(self):
     scrypt = auth.UserImportHash.scrypt(
         key=b'key', salt_separator=b'sep', rounds=8, memory_cost=14)
     expected = {
         'hashAlgorithm': 'SCRYPT',
         'signerKey': _user_import.b64_encode(b'key'),
         'rounds': 8,
         'memoryCost': 14,
         'saltSeparator': _user_import.b64_encode(b'sep'),
     }
     assert scrypt.to_dict() == expected
Example #4
0
 def test_hmac(self, func, name):
     hmac = func(key=b'key')
     expected = {
         'hashAlgorithm': name,
         'signerKey': _user_import.b64_encode(b'key'),
     }
     assert hmac.to_dict() == expected