def setUp(self): self.username = '******' self.hashed_password = '******' self.salt = os.urandom(32) self.content_credentials = 'app_id:secret_key' self.user = model.User(self.username, self.hashed_password, self.salt, self.content_credentials)
def register_user(self, username, plaintext_password): salt = os.urandom(64) password_hash = auth.hash_password(plaintext_password, salt) user = model.User(username, password_hash, salt) self._user_manager.add_user(user, self._content_manager) self._do_login(user) return user
def test_content_credentials_default_to_none_if_not_provided(self): """ The idea behind this behavior is that not all content managers will necessarily have authentication, so we want to make it optional """ user = model.User(self.username, self.hashed_password, self.salt) self.assertIsNone(user.content_credentials)
def test_returns_cached_user_if_already_added(self): username = '******' bob = model.User(username, 'bob_password', b'salt') self.user_manager.add_user(bob, self.content_manager) user = self.user_manager.get_user(username) self.assertIs(user, bob) self.assertIsNone(self.user_data_store.invoked_username)
def setUp(self): super(TestAddUser, self).setUp() self.user = model.User('bob', 'bob_password', b'salt') self.user_manager.add_user(self.user, self.content_manager)
def get_user(self, username): self.invoked_username = username if username != '<invalid user>' and self.deleted_user is None: return model.User(username, 'a password', b'salt')
def setUp(self): self.dynamodb = DynamoDbDouble() config = {'USER_DB_TABLE': 'the_user_table'} self.data_store = datastore.UserDataStore(config, self.dynamodb) self.user = model.User('realuser', 'a_password', b'salt') self.data_store.add_user(self.user)