示例#1
0
 def test_end_to_end_nosalt(self):
     splunk_secret = base64.b64encode(os.urandom(255))[:254]
     plaintext1 = base64.b64encode(os.urandom(255))[:24].decode()
     ciphertext = splunksecrets.encrypt(splunk_secret,
                                        plaintext1,
                                        nosalt=True)
     plaintext2 = splunksecrets.decrypt(splunk_secret,
                                        ciphertext,
                                        nosalt=True)
     self.assertEqual(plaintext2, plaintext1)
示例#2
0
 def test_encrypt_character_matches_salt2(self):
     ciphertext = splunksecrets.encrypt(splunk_secret, "DEFAULTSA" * 8)
     self.assertEqual(ciphertext, "$1$681ZK4BL5qRLsmMRT6EotpYVgOge69IZZhhxq0P+2ZBCaRTkci1IwiwRG9Ty2bHaSoG1p9QSXWIYA7mrYsyFqfWYqlvg+oQ+sg==")  # noqa: E501
示例#3
0
 def test_encrypt_character_matches_salt1(self):
     ciphertext = splunksecrets.encrypt(splunk_secret, "A" * 8)
     self.assertEqual(ciphertext, "$1$qowYK8EKp+UK")
示例#4
0
 def test_encrypt_nosalt(self):
     ciphertext = splunksecrets.encrypt(splunk_secret, "temp1234", nosalt=True)
     self.assertEqual(ciphertext, "$1$2+1yGuQ1gcMK")
示例#5
0
 def test_encrypt(self):
     ciphertext = splunksecrets.encrypt(splunk_secret, "temp1234")
     self.assertEqual(ciphertext, "$1$n6g0W7F51ZAK")
示例#6
0
 def test_end_to_end_character_matches_salt(self):
     splunk_secret = base64.b64encode(os.urandom(255))[:255]
     plaintext1 = "".join([random.choice("DEFAULTSA") for _ in range(24)])
     ciphertext = splunksecrets.encrypt(splunk_secret, plaintext1)
     plaintext2 = splunksecrets.decrypt(splunk_secret, ciphertext)
     self.assertEqual(plaintext2, plaintext1)
示例#7
0
 def test_end_to_end(self):
     splunk_secret = base64.b64encode(os.urandom(255))[:255]
     plaintext1 = base64.b64encode(os.urandom(255))[:24].decode()
     ciphertext = splunksecrets.encrypt(splunk_secret[:16], plaintext1)
     plaintext2 = splunksecrets.decrypt(splunk_secret[:16], ciphertext)
     self.assertEqual(plaintext2, plaintext1)
示例#8
0
 def test_encrypt_raises_value_error_short_secret(self):
     with self.assertRaises(ValueError):
         splunk_secret = base64.b64encode(os.urandom(255))[:15]
         splunksecrets.encrypt(splunk_secret, "temp1234")