Skip to content

Commit 81ef989

Browse files
committed
Refactor RSAParametersTest to use class properties for passphrase and salt, improving test clarity and maintainability
1 parent faed6c7 commit 81ef989

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/RSAParametersTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
class RSAParametersTest extends TestCase
1313
{
14-
14+
protected string $salt = 'salt';
15+
protected string $passphrase = 'passphrase';
16+
1517
/** @test */
1618
public function canGenerateKeys() :void
1719
{
1820
$parameters = new RSAParameters();
19-
$keys = $parameters->generateKeys();
21+
$keys = $parameters->generateKeys(passphrase: $this->passphrase, salt: $this->salt);
2022

2123
$this->assertInstanceOf(RSAParameters::class, $keys);
2224
}
@@ -25,11 +27,11 @@ public function canGenerateKeys() :void
2527
public function canExportKeysAndImportToFile() : void
2628
{
2729
$parameters = new RSAParameters();
28-
$parameters->generateKeys();
30+
$parameters->generateKeys(passphrase: $this->passphrase, salt: $this->salt);
2931
$locator = new TestingParametersLocator();
3032

3133
$writer = new RsaParametersWriter($locator);
32-
$writer->write($parameters);
34+
$writer->write($parameters, privateKeyPass: $this->passphrase, salt: $this->salt);
3335

3436
// Assert if exported files are on disk
3537
$this->assertTrue(file_exists($locator->locatePrivateKey()));
@@ -53,6 +55,6 @@ public function canExportKeysAndImportToFile() : void
5355
$csp2->setParameters($parameters2);
5456

5557
// Check if imported parameters are same as parameters that was exported
56-
$this->assertEquals($text, $csp2->decrypt($encryptedText));
58+
$this->assertEquals($text, $csp2->decrypt($encryptedText, privateKeyPass: $this->passphrase, salt: $this->salt));
5759
}
5860
}

0 commit comments

Comments
 (0)