def test_mklogtoken(): key = "0123456789abcdef" username = "******" password = "******" token = token_encode(key, username, password) tinfo = token_decode(token) tusrnm, tpaswd, tkntms = token_info(tinfo) assert username == tusrnm and password == tpaswd and tkntms > 0
def test_mklogtoken(self): key = "0123456789abcdef" username = "******" password = "******" token = token_encode(key, username, password) # Check decoded token decoded_token = token_decode(key, token).split(':') self.assertEqual(username, decoded_token[0].split('=')[1]) self.assertEqual(password, decoded_token[1].split('=')[1]) # Check token_info tusrnm, tpaswd, tkntms = token_info(key, token) self.assertEqual(username, tusrnm) self.assertEqual(password, tpaswd) self.assertGreater(tkntms, 0, '')
def test_mklogtoken(self): self.banner("Testing tokenEncode/tokenDecode/tokenInfo") key = "0123456789ABCDEF" username = '******' password = '******' token = token_encode(key, username, password) tinfo = token_decode(key, token) print("Token with key: '%s'; " "encoding: 'username:=%s:" "password=%s:" "timestamp=<issue_time>' is '%s'" % (key, username, password, token)) print "Decoded token: '%s' -> '%s'" % (token, tinfo) username2, password2, timestamp2 = token_info(token) print("Token info: 'username=%s:password=%s:timestamp=%s'" % (username2, password2, timestamp2)) self.assertEqual("%s:%s" % (username, password), "%s:%s" % (username2, password2))