First working version
This commit is contained in:
31
otpauth_migration_decoder/tests/test_validate_migration.py
Normal file
31
otpauth_migration_decoder/tests/test_validate_migration.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import pytest
|
||||
from click import BadParameter
|
||||
|
||||
from src.decoder import validate_migration
|
||||
|
||||
|
||||
def test_validate_migration__migration__ok():
|
||||
# arrange
|
||||
migration = 'otpauth-migration://offline?data=CjEKCkhlbGxvId6tvu8SGEV4YW1wbGU6YWxpY2VAZ29vZ2xlLmNvbRoHRXhhbXBsZTAC'
|
||||
|
||||
# act
|
||||
result = validate_migration(None, None, migration)
|
||||
|
||||
# assert
|
||||
assert result == ['CjEKCkhlbGxvId6tvu8SGEV4YW1wbGU6YWxpY2VAZ29vZ2xlLmNvbRoHRXhhbXBsZTAC']
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'broken_migration',
|
||||
[
|
||||
'otpauth-migration://online?data=CjEKCkhlbGxvId6tvu8SGEV4YW1wbGU6YWxpY2VAZ29vZ2xlLmNvbRoHRXhhbXBsZTAC',
|
||||
'CjEKCkhlbGxvId6tvu8SGEV4YW1wbGU6YWxpY2VAZ29vZ2xlLmNvbRoHRXhhbXBsZTAC',
|
||||
'offline?data=CjEKCkhlbGxvId6tvu8SGEV4YW1wbGU6YWxpY2VAZ29vZ2xlLmNvbRoHRXhhbXBsZTAC',
|
||||
'otpauth-migration://online?data=Cu8SGEV4YW1wbGU6YWxpY2VAZ29vZ2xlLmNvbRoHRXhhbXBsZTAC',
|
||||
'data=CjEKCkhlbGxvId6tvu8SGEV4YW1wbGU6YWxpY2VAZ29vZ2xlLmNvbRoHRXhhbXBsZTAC',
|
||||
]
|
||||
)
|
||||
def test_validate_migration__broken_migration__raise(broken_migration):
|
||||
# act & assert
|
||||
with pytest.raises(BadParameter):
|
||||
validate_migration(None, None, broken_migration)
|
||||
Reference in New Issue
Block a user