File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
tests/UnitTests/Encryption Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,31 @@ public function testCreateFromFiles(): void
120120 $ this ->validateEncryption ($ encryption );
121121 }
122122
123+ public function testValidate (): void
124+ {
125+ $ this ->expectNotToPerformAssertions ();
126+
127+ $ privateKey = sodium_crypto_box_keypair ();
128+ $ publicKey = sodium_crypto_box_publickey ($ privateKey );
129+
130+ $ encryption = new Encryption ($ privateKey , $ publicKey , []);
131+
132+ $ encryption ->validate ();
133+ }
134+
135+ public function testValidateFailsWithInvalidPublicKey (): void
136+ {
137+ $ privateKey = sodium_crypto_box_keypair ();
138+ $ publicKey = sodium_crypto_box_publickey (sodium_crypto_box_keypair ());
139+
140+ $ this ->expectException (EncryptionException::class);
141+ $ this ->expectExceptionMessage ('The encryption key is not valid. ' );
142+
143+ $ encryption = new Encryption ($ privateKey , $ publicKey , []);
144+
145+ $ encryption ->validate ();
146+ }
147+
123148 private function validateEncryption (Encryption $ encryption ): void
124149 {
125150 $ data = $ encryption ->reveal ($ encryption ->seal (self ::DATA ));
You can’t perform that action at this time.
0 commit comments