Bug 32426: (follow-up) Fix for Members.t / Patrons.t
[koha.git] / t / db_dependent / Koha / Encryption.t
1 use Modern::Perl;
2
3 use Test::More tests => 2;
4 use Test::Exception;
5 use t::lib::Mocks;
6 use Koha::Encryption;
7
8 t::lib::Mocks::mock_config('encryption_key', 'my secret passphrase');
9
10 my $string = 'a string to encrypt';
11
12 my $crypt = Koha::Encryption->new;
13 my $encrypted_string = $crypt->encrypt_hex($string);
14 is( $crypt->decrypt_hex($encrypted_string), $string, 'Decrypted to original text' );
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';