Skip to content

Commit

Permalink
Renamed test-mode class to silence pytest collection warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
koniiiik committed Jan 2, 2024
1 parent 3ef97a9 commit 4cd2445
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test_dovecot_userpassdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_test_filename():
get_test_filename.__test__ = False


class TestUserPassDBEntry(dovecot_userpassdb.UserPassDBEntry):
class CustomUserPassDBEntry(dovecot_userpassdb.UserPassDBEntry):
def get_filename(self):
return get_test_filename()

Expand Down Expand Up @@ -61,7 +61,7 @@ def run_checkpass(self, username, password):
os.dup2(res_write_fd, 4)
argv = [sys.argv[0], "./dump_env.py"]
# We need to skip the unittest error handlers here.
os._exit(TestUserPassDBEntry.checkpass_main(argv=argv))
os._exit(CustomUserPassDBEntry.checkpass_main(argv=argv))

# Parent process.
os.close(pass_read_fd)
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_checkpass_fails_before_password_set(self):
self.run_checkpass('user', 'password')

def test_set_new_password(self):
TestUserPassDBEntry.set_and_write_password('user', 'password123')
CustomUserPassDBEntry.set_and_write_password('user', 'password123')
with open(get_test_filename(), 'r') as f:
imaprc_state = json.load(f)

Expand All @@ -101,14 +101,14 @@ def test_set_new_password(self):
))

def test_change_password(self):
TestUserPassDBEntry.set_and_write_password('user', 'password123')
CustomUserPassDBEntry.set_and_write_password('user', 'password123')

with open(get_test_filename(), 'r') as f:
imaprc_state = json.load(f)

self.assertIn('password', imaprc_state)

TestUserPassDBEntry.set_and_write_password('user', 'password456')
CustomUserPassDBEntry.set_and_write_password('user', 'password456')
with open(get_test_filename(), 'r') as f:
imaprc_state = json.load(f)

Expand All @@ -118,13 +118,13 @@ def test_change_password(self):
))

def test_checkpass_fails_wrong_password(self):
TestUserPassDBEntry.set_and_write_password('user', 'password123')
CustomUserPassDBEntry.set_and_write_password('user', 'password123')

with self.assertRaisesRegex(CheckpassError, '^1$'):
self.run_checkpass('user', 'wrong password')

def test_checkpass_succeeds_correct_password(self):
TestUserPassDBEntry.set_and_write_password('nobody', 'password123')
CustomUserPassDBEntry.set_and_write_password('nobody', 'password123')
env = self.run_checkpass('nobody', 'password123')
self.assertEqual(env['EXTRA'], 'userdb_uid userdb_gid')

Expand All @@ -135,7 +135,7 @@ def test_checkpass_succeeds_correct_password(self):
self.assertEqual(env['userdb_gid'], str(nobody_pwd.pw_gid))

def test_timing_without_configured_password(self):
TestUserPassDBEntry.set_and_write_password('nobody', 'password123')
CustomUserPassDBEntry.set_and_write_password('nobody', 'password123')

# Just to see that it's correct.
self.run_checkpass('nobody', 'password123')
Expand Down

0 comments on commit 4cd2445

Please sign in to comment.