Skip to content

Commit

Permalink
Create test_auth_utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Sep 18, 2024
1 parent 0312d72 commit 6c02e6e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions app/tests/test_auth_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import unittest
from app.auth_utils import hash_password, verify_password, generate_token, verify_token

class TestAuthUtils(unittest.TestCase):
def setUp(self):
self.password = 'mysecretpassword'
self.user_id = 1
self.secret_key = 'mysecretkey'

def test_hash_password(self):
hashed_password = hash_password(self.password)
self.assertIsNotNone(hashed_password)

def test_verify_password(self):
hashed_password = hash_password(self.password)
self.assertTrue(verify_password(self.password, hashed_password))

def test_generate_token(self):
token = generate_token(self.user_id, self.secret_key)
self.assertIsNotNone(token)

def test_verify_token(self):
token = generate_token(self.user_id, self.secret_key)
user_id = verify_token(token, self.secret_key)
self.assertEqual(user_id, self.user_id)

if __name__ == '__main__':
unittest.main()

0 comments on commit 6c02e6e

Please sign in to comment.