def test_create_on_existing_email(self): settings.PASSWORD_LOGIN = True email = self.fake.email() password = self.fake.password() payload = dict(email=email, name=self.fake.name(), password=password, code=Role.SIGNATURE.dumps(email)) RoleFactory.create(email=email) res = self.client.post('/api/2/roles', data=payload) self.assertEqual(res.status_code, 409)
def test_create_on_existing_email(self): settings.PASSWORD_LOGIN = True email = self.fake.email() password = self.fake.password() payload = dict( email=email, name=self.fake.name(), password=password, code=Role.SIGNATURE.dumps(email) ) RoleFactory.create(email=email) res = self.client.post('/api/2/roles', data=payload) self.assertEqual(res.status_code, 409)
def test_create_on_existing_email(self): email = self.fake.email() password = self.fake.password() payload = dict( email=email, name=self.fake.name(), password=password, code=Role.SIGNATURE_SERIALIZER.dumps(email, salt=email) ) RoleFactory.create(email=email) res = self.client.post('/api/1/roles', data=payload) self.assertEqual(res.status_code, 200) self.assertEqual(res.json['status'], 'ok') role = Role.by_email(email).first() self.assertIsNotNone(role) self.assertFalse(role.check_password(password))
def test_password(self): password = self.fake.password() role = RoleFactory.create() self.assertFalse(role.check_password(password)) role.set_password(password) self.assertTrue(role.check_password(password)) role.set_password(self.fake.password()) self.assertFalse(role.check_password(password))
def setUp(self): super(RoleModelTest, self).setUp() self.role = RoleFactory.create() db.session.commit()
def setUp(self): super(SessionsApiTestCase, self).setUp() self.role = RoleFactory.create()