|
Lines 1-8
Link Here
|
| 1 |
use Modern::Perl; |
1 |
use Modern::Perl; |
| 2 |
|
2 |
|
| 3 |
use Test::More tests => 1; |
3 |
use Test::More tests => 2; |
| 4 |
use Koha::Encryption; |
4 |
use Test::Exception; |
| 5 |
use t::lib::Mocks; |
5 |
use t::lib::Mocks; |
|
|
6 |
use Koha::Encryption; |
| 6 |
|
7 |
|
| 7 |
t::lib::Mocks::mock_config('encryption_key', 'my secret passphrase'); |
8 |
t::lib::Mocks::mock_config('encryption_key', 'my secret passphrase'); |
| 8 |
|
9 |
|
|
Lines 11-13
my $string = 'a string to encrypt';
Link Here
|
| 11 |
my $crypt = Koha::Encryption->new; |
12 |
my $crypt = Koha::Encryption->new; |
| 12 |
my $encrypted_string = $crypt->encrypt_hex($string); |
13 |
my $encrypted_string = $crypt->encrypt_hex($string); |
| 13 |
is( $crypt->decrypt_hex($encrypted_string), $string, 'Decrypted to original text' ); |
14 |
is( $crypt->decrypt_hex($encrypted_string), $string, 'Decrypted to original text' ); |
| 14 |
- |
15 |
|
|
|
16 |
# Check if exception raised when key is empty or missing |
| 17 |
t::lib::Mocks::mock_config('encryption_key', ''); |
| 18 |
throws_ok { $crypt = Koha::Encryption->new } 'Koha::Exceptions::MissingParameter', 'Exception raised'; |