def test_hexstring_generator(self): hex_str = AttributesGenerator.hexstring() self.assertEqual(len(hex_str), 8) self.assertTrue(all(hex_str)) hex_str = AttributesGenerator.hexstring(32) self.assertEqual(len(hex_str), 32) self.assertTrue(all(hex_str))
def test_password_generate(self): password_str = AttributesGenerator.password() self.assertEqual(len(password_str), 24) self.assertTrue(all(password_str)) password_str = AttributesGenerator.password(8) self.assertEqual(len(password_str), 8) self.assertTrue(all(password_str))
def test_cephx_key_generator(self, m_time, m_urandom): coded_key = AttributesGenerator.cephx_key() uncoded_key = base64.b64decode(coded_key) package = uncoded_key[:-16] key = uncoded_key[-16:] key_type, sec, usec, length = struct.unpack('<hiih', package) self.assertEqual(key, 'f' * 16) self.assertEqual(key_type, 1) self.assertEqual(sec, 1437172408) self.assertEqual(usec, 0) self.assertEqual(length, 16)