-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
executable file
·40 lines (32 loc) · 1.02 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'''
Unit tests for yubi_goog's.
'''
import unittest
import binascii
from yubigoog.__main__ import ytg_get_secret, ytg_setup
class TestYubiGoog(unittest.TestCase):
'''
Test TokenGenerator methods
'''
def setUp(self):
self.secret = 'T7BNSOQ42E353N55T7BNSOQ42E353N55'
self.secret_hex = '9fc2d93a1cd137ddb7bd9fc2d93a1cd137ddb7bd'
self.secret_bin = binascii.unhexlify(self.secret_hex)
def test_get_secret(self):
'''
Test secret conversion from Base32 to binary format (stored in hex
format for convenience).
'''
self.assertEqual(
self.secret_hex,
binascii.hexlify(ytg_get_secret(self.secret))
)
def test_setup(self):
'''
Test that the setup function gives the correct secret for the
Yubikey.
'''
hexlified = '9fc2d93a1cd137ddb7bd9fc2d93a1cd137ddb7bd'
self.assertEqual(hexlified, ytg_setup(self.secret_bin))
if __name__ == '__main__':
unittest.main()