diff --git a/tests/unit/framework/helpers/SecurityTest.php b/tests/unit/framework/helpers/SecurityTest.php new file mode 100644 index 0000000..6a1d2fd --- /dev/null +++ b/tests/unit/framework/helpers/SecurityTest.php @@ -0,0 +1,43 @@ +assertTrue(Security::validatePassword($password, $hash)); + $this->assertFalse(Security::validatePassword('test', $hash)); + } + + public function testHashData() + { + $data = 'known data'; + $key = 'secret'; + $hashedData = Security::hashData($data, $key); + $this->assertFalse($data === $hashedData); + $this->assertEquals($data, Security::validateData($hashedData, $key)); + $hashedData[strlen($hashedData) - 1] = 'A'; + $this->assertFalse(Security::validateData($hashedData, $key)); + } + + public function testEncrypt() + { + $data = 'known data'; + $key = 'secret'; + $encryptedData = Security::encrypt($data, $key); + $this->assertFalse($data === $encryptedData); + $decryptedData = Security::decrypt($encryptedData, $key); + $this->assertEquals($data, $decryptedData); + } +}