-
-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Django doesn't namespace the commands, which make them look ambiguous when used. Including `two_factor_` in the name makes them unambiguous. See also #77.
- Loading branch information
Showing
4 changed files
with
11 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -981,22 +981,22 @@ def _assert_raises(self, err_type, err_message): | |
|
||
def test_raises(self): | ||
with self._assert_raises(CommandError, 'User "some_username" does not exist'): | ||
call_command('disable', 'some_username') | ||
call_command('two_factor_disable', 'some_username') | ||
|
||
with self._assert_raises(CommandError, 'User "other_username" does not exist'): | ||
call_command('disable', 'other_username', 'some_username') | ||
call_command('two_factor_disable', 'other_username', 'some_username') | ||
|
||
def test_disable_single(self): | ||
user = self.create_user() | ||
self.enable_otp(user) | ||
call_command('disable', '[email protected]') | ||
call_command('two_factor_disable', '[email protected]') | ||
self.assertEqual(list(devices_for_user(user)), []) | ||
|
||
def test_happy_flow_multiple(self): | ||
usernames = ['user%[email protected]' % i for i in range(0, 3)] | ||
users = [self.create_user(username) for username in usernames] | ||
[self.enable_otp(user) for user in users] | ||
call_command('disable', *usernames[:2]) | ||
call_command('two_factor_disable', *usernames[:2]) | ||
self.assertEqual(list(devices_for_user(users[0])), []) | ||
self.assertEqual(list(devices_for_user(users[1])), []) | ||
self.assertNotEqual(list(devices_for_user(users[2])), []) | ||
|
@@ -1015,27 +1015,27 @@ def setUp(self): | |
|
||
def test_raises(self): | ||
with self._assert_raises(CommandError, 'User "some_username" does not exist'): | ||
call_command('status', 'some_username') | ||
call_command('two_factor_status', 'some_username') | ||
|
||
with self._assert_raises(CommandError, 'User "other_username" does not exist'): | ||
call_command('status', 'other_username', 'some_username') | ||
call_command('two_factor_status', 'other_username', 'some_username') | ||
|
||
def test_status_single(self): | ||
user = self.create_user() | ||
stdout = StringIO() | ||
call_command('status', '[email protected]', stdout=stdout) | ||
call_command('two_factor_status', '[email protected]', stdout=stdout) | ||
self.assertEqual(stdout.getvalue(), '[email protected]: disabled\n') | ||
|
||
stdout = StringIO() | ||
self.enable_otp(user) | ||
call_command('status', '[email protected]', stdout=stdout) | ||
call_command('two_factor_status', '[email protected]', stdout=stdout) | ||
self.assertEqual(stdout.getvalue(), '[email protected]: enabled\n') | ||
|
||
def test_status_mutiple(self): | ||
users = [self.create_user(n) for n in ['[email protected]', '[email protected]']] | ||
self.enable_otp(users[0]) | ||
stdout = StringIO() | ||
call_command('status', '[email protected]', '[email protected]', stdout=stdout) | ||
call_command('two_factor_status', '[email protected]', '[email protected]', stdout=stdout) | ||
self.assertEqual(stdout.getvalue(), '[email protected]: enabled\n' | ||
'[email protected]: disabled\n') | ||
|
||
|
File renamed without changes.
File renamed without changes.