Skip to content

Commit

Permalink
Fix tests to respect the new unique constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaweedbrainCY committed Dec 5, 2024
1 parent db1bdea commit c1b1d08
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion api/tests/unit/test_encrypted_secret_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setUp(self):
db.create_all()
user = self.user_repo.create(username='user1', email='user1@test.com', password='test', randomSalt='salt', passphraseSalt='salt', today=datetime.datetime.now(), isVerified=True)
self.user_id = user.id
user2 = self.user_repo.create(username='user1', email='user1@test.com', password='test', randomSalt='salt', passphraseSalt='salt', today=datetime.datetime.now(), isVerified=True)
user2 = self.user_repo.create(username='user2', email='user2@test.com', password='test', randomSalt='salt', passphraseSalt='salt', today=datetime.datetime.now(), isVerified=True)
self.user_id2 = user2.id
_, self.session_token = self.session_repo.generate_session_token(self.user_id)
for secret_id in self.secret_ids:
Expand Down
2 changes: 1 addition & 1 deletion api/tests/unit/test_endpoint_protection.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setUp(self):
self.user_id = 1
with self.flask_application.app.app_context():
db.create_all()
user = UserRepo().create(username='user1', email='user1@test.com', password='test', randomSalt='salt', passphraseSalt='salt', today=datetime.datetime.now(), isVerified=True)
user = UserRepo().create(username='username', email='username@test.com', password='test', randomSalt='salt', passphraseSalt='salt', today=datetime.datetime.now(), isVerified=True)
self.user_id = user.id
self.session_id, self.session_token = SessionTokenRepo().generate_session_token(self.user_id)
db.session.commit()
Expand Down
2 changes: 1 addition & 1 deletion api/tests/unit/test_export_vault_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setUp(self):
user = self.user_repo.create(username='user1', email='user1@test.com', password='test', randomSalt='salt', passphraseSalt='salt', today=datetime.datetime.now(), isVerified=True)
self.zke_repo.create(user_id=user.id, encrypted_key="key")
self.user_id = user.id
user2 = self.user_repo.create(username='user1', email='user1@test.com', password='test', randomSalt='salt', passphraseSalt='salt', today=datetime.datetime.now(), isVerified=True)
user2 = self.user_repo.create(username='user2', email='user2@test.com', password='test', randomSalt='salt', passphraseSalt='salt', today=datetime.datetime.now(), isVerified=True)
self.user_id2 = user2.id
_, self.session_token = self.session_repo.generate_session_token(self.user_id)
for secret_id in self.secret_ids:
Expand Down
8 changes: 4 additions & 4 deletions api/tests/unit/test_get_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def setUp(self):
self.session_repo = SessionTokenRepo()

admin_user = UserModel(id=self.admin_user_id,username="admin", mail="admin@admin.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001", role="admin")
not_admin_user = UserModel(id=self.not_admin_user_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001", role="user")
user_without_role = UserModel(id=self.user_without_role_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001", role=None)
user_blocked = UserModel(id=self.user_blocked_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001", role=None, isBlocked=True)
user_unverified = UserModel(id=self.user_unverified_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001", role=None, isBlocked=False)
not_admin_user = UserModel(id=self.not_admin_user_id,username="user1", mail="user1@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001", role="user")
user_without_role = UserModel(id=self.user_without_role_id,username="user2", mail="user2@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001", role=None)
user_blocked = UserModel(id=self.user_blocked_id,username="user3", mail="user3@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001", role=None, isBlocked=True)
user_unverified = UserModel(id=self.user_unverified_id,username="user4", mail="user4@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001", role=None, isBlocked=False)

with self.flask_application.app.app_context():
db.create_all()
Expand Down
6 changes: 3 additions & 3 deletions api/tests/unit/test_security_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def setUp(self):
self.blocked_user_id = 3
self.flask_application = app

not_verified_user = UserModel(id=self.not_verified_user_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001")
verified_user_id = UserModel(id=self.verified_user_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001")
blocked_user_id = UserModel(id=self.blocked_user_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001", isBlocked = True)
not_verified_user = UserModel(id=self.not_verified_user_id,username="user1", mail="user1@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001")
verified_user_id = UserModel(id=self.verified_user_id,username="user2", mail="user2@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001")
blocked_user_id = UserModel(id=self.blocked_user_id,username="user3", mail="user3@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001", isBlocked = True)
with self.flask_application.app.app_context():
db.create_all()
db.session.add(not_verified_user)
Expand Down
12 changes: 6 additions & 6 deletions api/tests/unit/test_verify_email_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def setUp(self):
self.user_wrong_token_id = 5
self.blocked_user_id = 6

user = UserModel(id=self.user_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001")
user_already_verified = UserModel(id=self.already_verified_user_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001")
user_without_token = UserModel(id=self.user_without_token_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001")
user_expired_token = UserModel(id=self.user_expired_token_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001")
user_wrong_token = UserModel(id=self.user_wrong_token_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001")
blocked_user = UserModel(id=self.blocked_user_id,username="user", mail="user@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001", isBlocked=True)
user = UserModel(id=self.user_id,username="user1", mail="user1@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001")
user_already_verified = UserModel(id=self.already_verified_user_id,username="user2", mail="user2@user.com", password="pass", derivedKeySalt="AAA", isVerified = True, passphraseSalt = "AAAA", createdAt="01/01/2001")
user_without_token = UserModel(id=self.user_without_token_id,username="user3", mail="user3@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001")
user_expired_token = UserModel(id=self.user_expired_token_id,username="user4", mail="user4@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001")
user_wrong_token = UserModel(id=self.user_wrong_token_id,username="user5", mail="user5@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001")
blocked_user = UserModel(id=self.blocked_user_id,username="user6", mail="user6@user.com", password="pass", derivedKeySalt="AAA", isVerified = False, passphraseSalt = "AAAA", createdAt="01/01/2001", isBlocked=True)



Expand Down

0 comments on commit c1b1d08

Please sign in to comment.