예제 #1
0
 def setUp(self):
     self.app = create_app(testing=True)
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     # Create a test user
     usr = Users(email='*****@*****.**', username='******')
     usr.set_password('testpass')
     db.session.add(usr)
     db.session.commit()
     self.user = usr
예제 #2
0
    def test_new_user(self):
        usr = Users(
            email='*****@*****.**',
            username='******',
        )
        usr.set_password('cat')
        db.session.add(usr)
        db.session.commit()

        self.assertTrue(usr.username is not None)
        self.assertTrue(usr.email is not None)
        self.assertTrue(usr.passwd_digest is not None)
        self.assertTrue(isinstance(usr.joined_on, datetime))
예제 #3
0
    def test_password_salts_are_random(self):
        u = Users(username='******')
        u.set_password('cat')

        u2 = Users(username='******')
        u2.set_password('cat')

        self.assertTrue(u.passwd_digest != u2.passwd_digest)
    def setUp(self):
        self.app = create_app(testing=True)
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        self.client = self.app.test_client()
        self.baseURL = '/api/v1'

        # Create a test user
        usr = Users(email='*****@*****.**', username='******')
        usr.set_password('testpass')
        db.session.add(usr)
        db.session.commit()
        self.user = usr

        # Setup a bearer token
        with self.app_context:
            self.token = create_access_token(self.user.id)
예제 #5
0
 def make_user(self, data):
     return Users(**data)
예제 #6
0
    def test_password_verification(self):
        u = Users(username='******')
        u.set_password('cat')

        self.assertTrue(u.check_password('cat'))
        self.assertFalse(u.check_password('dog'))
예제 #7
0
    def test_password_setter(self):
        u = Users(username='******')
        u.set_password('cat')

        self.assertTrue(u.passwd_digest is not None)