<s> import unittest <EOL> import binascii <EOL> import struct <EOL> import yubi_goog <EOL> class TestYubiGoog ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . google_secret = "<STR_LIT>" <EOL> self . test_secret = binascii . hexlify ( '<STR_LIT>' . encode ( '<STR_LIT:ascii>' ) ) <EOL> self . test_vectors = [ { '<STR_LIT:time>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:time>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:time>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT>' } ] <EOL> def test_decode_secret ( self ) : <EOL> decoded = yubi_goog . decode_secret ( self . google_secret ) . upper ( ) <EOL> self . assertEqual ( decoded , "<STR_LIT>" . encode ( '<STR_LIT:ascii>' ) ) <EOL> def test_totp ( self ) : <EOL> for pair in self . test_vectors : <EOL> time = pair [ '<STR_LIT:time>' ] <EOL> real_otp = pair [ '<STR_LIT>' ] <EOL> tm = int ( int ( time ) / <NUM_LIT:30> ) <EOL> tm = struct . pack ( '<STR_LIT>' , tm ) <EOL> otp = yubi_goog . totp ( self . test_secret , tm ) <EOL> self . assertEqual ( otp , real_otp ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
