From 8ba4439305babfd5a30208be5041780131ca68a4 Mon Sep 17 00:00:00 2001 From: scito Date: Mon, 19 Dec 2022 22:01:08 +0100 Subject: [PATCH] add utf-8 encoding tests --- example_export.txt | 4 ++++ example_keepass_output.totp.csv | 1 + example_output.csv | 1 + example_output.json | 10 +++++++- test/example_export_only_totp.txt | 4 ++++ test/print_verbose_output.txt | 24 ++++++++++++++++++++ test/printqr_output.txt | 29 ++++++++++++++++++++++++ test_extract_otp_secret_keys_pytest.py | 4 ++++ test_extract_otp_secret_keys_unittest.py | 8 +++++++ 9 files changed, 84 insertions(+), 1 deletion(-) diff --git a/example_export.txt b/example_export.txt index 12abdb1..1af539f 100644 --- a/example_export.txt +++ b/example_export.txt @@ -12,3 +12,7 @@ otpauth-migration://offline?data=CigKEPqlBekzoNEukL7qlsjBCDYSDnBpQHJhc3BiZXJyeXB # otpauth://hotp/hotp%20demo?secret=7KSQL2JTUDIS5EF65KLMRQIIGY&counter=4 otpauth-migration://offline?data=CiUKEPqlBekzoNEukL7qlsjBCDYSCWhvdHAgZGVtbyABKAEwATgEEAEYASAAKNuv15j6%2F%2F%2F%2F%2FwE%3D + +# otpauth://totp/encoding%3A%20%C2%BF%C3%A4%C3%84%C3%A9%C3%89%3F%20%28demo%29?secret=7KSQL2JTUDIS5EF65KLMRQIIGY +# Name: "encoding: ¿äÄéÉ? (demo)" +otpauth-migration://offline?data=CjYKEPqlBekzoNEukL7qlsjBCDYSHGVuY29kaW5nOiDCv8Okw4TDqcOJPyAoZGVtbykgASgBMAIQARgBIAAorfCurv%2F%2F%2F%2F%2F%2FAQ%3D%3D diff --git a/example_keepass_output.totp.csv b/example_keepass_output.totp.csv index 87add21..6ffe318 100644 --- a/example_keepass_output.totp.csv +++ b/example_keepass_output.totp.csv @@ -3,3 +3,4 @@ raspberrypi,pi@raspberrypi,7KSQL2JTUDIS5EF65KLMRQIIGY,OTP/TOTP ,pi@raspberrypi,7KSQL2JTUDIS5EF65KLMRQIIGY,OTP/TOTP ,pi@raspberrypi,7KSQL2JTUDIS5EF65KLMRQIIGY,OTP/TOTP raspberrypi,pi@raspberrypi,7KSQL2JTUDIS5EF65KLMRQIIGY,OTP/TOTP +,encoding: ¿äÄéÉ? (demo),7KSQL2JTUDIS5EF65KLMRQIIGY,OTP/TOTP diff --git a/example_output.csv b/example_output.csv index 98ee5b5..9b2d763 100644 --- a/example_output.csv +++ b/example_output.csv @@ -4,3 +4,4 @@ pi@raspberrypi,7KSQL2JTUDIS5EF65KLMRQIIGY,,totp,,otpauth://totp/pi%40raspberrypi pi@raspberrypi,7KSQL2JTUDIS5EF65KLMRQIIGY,,totp,,otpauth://totp/pi%40raspberrypi?secret=7KSQL2JTUDIS5EF65KLMRQIIGY pi@raspberrypi,7KSQL2JTUDIS5EF65KLMRQIIGY,raspberrypi,totp,,otpauth://totp/pi%40raspberrypi?secret=7KSQL2JTUDIS5EF65KLMRQIIGY&issuer=raspberrypi hotp demo,7KSQL2JTUDIS5EF65KLMRQIIGY,,hotp,4,otpauth://hotp/hotp%20demo?secret=7KSQL2JTUDIS5EF65KLMRQIIGY&counter=4 +encoding: ¿äÄéÉ? (demo),7KSQL2JTUDIS5EF65KLMRQIIGY,,totp,,otpauth://totp/encoding%3A%20%C2%BF%C3%A4%C3%84%C3%A9%C3%89%3F%20%28demo%29?secret=7KSQL2JTUDIS5EF65KLMRQIIGY diff --git a/example_output.json b/example_output.json index ac3f8a1..e1996a2 100644 --- a/example_output.json +++ b/example_output.json @@ -38,5 +38,13 @@ "type": "hotp", "counter": 4, "url": "otpauth://hotp/hotp%20demo?secret=7KSQL2JTUDIS5EF65KLMRQIIGY&counter=4" + }, + { + "name": "encoding: ¿äÄéÉ? (demo)", + "secret": "7KSQL2JTUDIS5EF65KLMRQIIGY", + "issuer": "", + "type": "totp", + "counter": null, + "url": "otpauth://totp/encoding%3A%20%C2%BF%C3%A4%C3%84%C3%A9%C3%89%3F%20%28demo%29?secret=7KSQL2JTUDIS5EF65KLMRQIIGY" } -] \ No newline at end of file +] diff --git a/test/example_export_only_totp.txt b/test/example_export_only_totp.txt index 022072e..08c992d 100644 --- a/test/example_export_only_totp.txt +++ b/test/example_export_only_totp.txt @@ -9,3 +9,7 @@ otpauth-migration://offline?data=CigKEPqlBekzoNEukL7qlsjBCDYSDnBpQHJhc3BiZXJyeXB # otpauth://totp/pi@raspberrypi?secret=7KSQL2JTUDIS5EF65KLMRQIIGY&issuer=raspberrypi # otpauth://totp/pi@raspberrypi?secret=7KSQL2JTUDIS5EF65KLMRQIIGY otpauth-migration://offline?data=CigKEPqlBekzoNEukL7qlsjBCDYSDnBpQHJhc3BiZXJyeXBpIAEoATACCjUKEPqlBekzoNEukL7qlsjBCDYSDnBpQHJhc3BiZXJyeXBpGgtyYXNwYmVycnlwaSABKAEwAhABGAEgACiQ7OOa%2Bf%2F%2F%2F%2F8B + +# otpauth://totp/encoding%3A%20%C2%BF%C3%A4%C3%84%C3%A9%C3%89%3F%20%28demo%29?secret=7KSQL2JTUDIS5EF65KLMRQIIGY +# Name: "encoding: ¿äÄéÉ? (demo)" +otpauth-migration://offline?data=CjYKEPqlBekzoNEukL7qlsjBCDYSHGVuY29kaW5nOiDCv8Okw4TDqcOJPyAoZGVtbykgASgBMAIQARgBIAAorfCurv%2F%2F%2F%2F%2F%2FAQ%3D%3D diff --git a/test/print_verbose_output.txt b/test/print_verbose_output.txt index 6e18512..da20bf7 100644 --- a/test/print_verbose_output.txt +++ b/test/print_verbose_output.txt @@ -112,3 +112,27 @@ Type: hotp Counter: 4 otpauth://hotp/hotp%20demo?secret=7KSQL2JTUDIS5EF65KLMRQIIGY&counter=4 + +# otpauth://totp/encoding%3A%20%C2%BF%C3%A4%C3%84%C3%A9%C3%89%3F%20%28demo%29?secret=7KSQL2JTUDIS5EF65KLMRQIIGY +# Name: "encoding: ¿äÄéÉ? (demo)" +otpauth-migration://offline?data=CjYKEPqlBekzoNEukL7qlsjBCDYSHGVuY29kaW5nOiDCv8Okw4TDqcOJPyAoZGVtbykgASgBMAIQARgBIAAorfCurv%2F%2F%2F%2F%2F%2FAQ%3D%3D + +5. Payload Line +otp_parameters { + secret: "\372\245\005\3513\240\321.\220\276\352\226\310\301\0106" + name: "encoding: ¿äÄéÉ? (demo)" + algorithm: ALGO_SHA1 + digits: 1 + type: OTP_TOTP +} +version: 1 +batch_size: 1 +batch_id: -171198419 + + +6. Secret Key +Name: encoding: ¿äÄéÉ? (demo) +Secret: 7KSQL2JTUDIS5EF65KLMRQIIGY +Type: totp +otpauth://totp/encoding%3A%20%C2%BF%C3%A4%C3%84%C3%A9%C3%89%3F%20%28demo%29?secret=7KSQL2JTUDIS5EF65KLMRQIIGY + diff --git a/test/printqr_output.txt b/test/printqr_output.txt index d2ba2a4..f81eac0 100644 --- a/test/printqr_output.txt +++ b/test/printqr_output.txt @@ -132,3 +132,32 @@ Counter: 4                                                                                             +Name: encoding: ¿äÄéÉ? (demo) +Secret: 7KSQL2JTUDIS5EF65KLMRQIIGY +Type: totp +                                                  +                                                  +    █▀▀▀▀▀█ ▄▀▀  ▀  ▄▀█ ▄▄▄██▀ ▄▀█▄█▀ █▀▀▀▀▀█     +    █ ███ █ █▄▀█▄▄ ▀  ▄▀█  █  █  ▀▀▀▄ █ ███ █     +    █ ▀▀▀ █  ▄ ▀ ▀▄▀▄ ▄▄▀▄▄█▄ ▀▄ █▀▀█ █ ▀▀▀ █     +    ▀▀▀▀▀▀▀ █ █ █▄█▄▀ ▀▄▀ █▄█ ▀ █ ▀ █ ▀▀▀▀▀▀▀     +    ▀   ▄ ▀ █▀▀▄▀ ▄▄▀▀▄█▄ █▄▀▀▄█▀██▄▄█▀ ▄█▀▀▄     +    ▄▀█▄█ ▀ ▀ █▄█▄▄    ▄███▄▄▀▀▀▄▄▀▄    ▄█▀▄▄     +     ▀█▀ ▄▀▄▄█ ▄▀███▀ ▄▀█▀▄▀▄  ▀██▄▄ ▄█▀█  ▀▄     +     ▄▀ █▄▀▀ █▀▄▄▄  ▄█▄█ ▀▄ ▄▄ ▄  ▀▀█▄▄ ▀█▄▄▄     +    ▀ ▄▄▄▀▀▄▄█▀▄ ▀▀▀█▄ █▄ ▀ ▄█▄▄▀▄▀▀▀▄▄█▄ ▀ ▀     +    █ ▄   ▀█ ▄▀ ██ █ ▄▄▀▀▀███▄     ▄▄██ ██▀█▀     +    █▀█▀██▀▀███▄  ▀▀▄▄▄▄█▀ █ ▄█▄█▄▀ ▄▄▀  ▄▄ ▀     +    ▄██▄▄ ▀ ▀   ▀▀  ██▄▄▄▀▀▄█▀█▄ ▀ █▄▀▄   ▀▄▄     +      ███▄▀█▄█▄▄█ ▀█▄ ▀▄█  ▄▀▄ █▄  ▄ █▄  ▄▀▄▀     +    █  ▄ ▄▀▀▄▄█▄▄█▄█ ▄▄▄ █▄▄▀█ █▀█▄ ▄▀▀█▄▄▄▀▀     +    ▄  ▀▄▀▀ ▄▄▀██  ▀▀▄█▀▀▄ ▀▀█   ▄ ████ █▀█▀█     +    █▀▄▀█ ▀▄▄ ▄ ▀▀▀ ▄▀ ▀ █▀▄▀▀█▀▀█▄▀█ ▀▄▀▄ █      +    ▀ ▀  ▀▀ ▄ █▄▀█▀▀▄▀█ ▀▄▄█▄▀ ██ ▀██▀▀▀█▀▄▄      +    █▀▀▀▀▀█  ▀█ ▄▄██▀ ▀██▄▀██ ▄▄██ ▀█ ▀ █ ▀█      +    █ ███ █  █▄ █▀▀█▀▀▀█▀█ ▀ ▀█ █▀▀ ██▀▀▀███▀     +    █ ▀▀▀ █  ▄ ▄▀█▄▄ ▀█ ▀▀  ▄ ▀█▀ ▄▀ █▀▀██ ▀▄     +    ▀▀▀▀▀▀▀ ▀ ▀ ▀ ▀▀   ▀  ▀ ▀▀▀▀ ▀  ▀   ▀ ▀       +                                                  +                                                  + diff --git a/test_extract_otp_secret_keys_pytest.py b/test_extract_otp_secret_keys_pytest.py index 99b1951..a07bde4 100644 --- a/test_extract_otp_secret_keys_pytest.py +++ b/test_extract_otp_secret_keys_pytest.py @@ -476,4 +476,8 @@ Secret: 7KSQL2JTUDIS5EF65KLMRQIIGY Type: hotp Counter: 4 +Name: encoding: ¿äÄéÉ? (demo) +Secret: 7KSQL2JTUDIS5EF65KLMRQIIGY +Type: totp + ''' diff --git a/test_extract_otp_secret_keys_unittest.py b/test_extract_otp_secret_keys_unittest.py index e4839b7..9be7905 100644 --- a/test_extract_otp_secret_keys_unittest.py +++ b/test_extract_otp_secret_keys_unittest.py @@ -73,6 +73,10 @@ class TestExtract(unittest.TestCase): 'Secret: 7KSQL2JTUDIS5EF65KLMRQIIGY', 'Type: hotp', 'Counter: 4', + '', + 'Name: encoding: ¿äÄéÉ? (demo)', + 'Secret: 7KSQL2JTUDIS5EF65KLMRQIIGY', + 'Type: totp', '' ] self.assertEqual(output, expected_output) @@ -107,6 +111,10 @@ Secret: 7KSQL2JTUDIS5EF65KLMRQIIGY Type: hotp Counter: 4 +Name: encoding: ¿äÄéÉ? (demo) +Secret: 7KSQL2JTUDIS5EF65KLMRQIIGY +Type: totp + ''' self.assertEqual(actual_output, expected_output)