Fix rspec for aes256
This commit is contained in:
parent
11001d010c
commit
b829f19570
|
@ -1,6 +1,5 @@
|
|||
require 'spec_helper'
|
||||
require 'securerandom'
|
||||
require 'openssl'
|
||||
|
||||
|
||||
describe Rex::Text do
|
||||
|
@ -18,14 +17,18 @@ describe Rex::Text do
|
|||
}
|
||||
|
||||
describe '#encrypt_aes256' do
|
||||
it 'raises a CipherError exception due to a short IV' do
|
||||
it 'raises an exception due to a short IV' do
|
||||
iv = SecureRandom.random_bytes(1)
|
||||
expect { Rex::Text.encrypt_aes256(iv, key, value) }.to raise_error(OpenSSL::Cipher::CipherError)
|
||||
# Because it could raise either a OpenSSL::Cipher::CipherError or an ArgumentError
|
||||
# dependong on the environment, we will just expect it to raise an exception
|
||||
expect { Rex::Text.encrypt_aes256(iv, key, value) }.to raise_exception
|
||||
end
|
||||
|
||||
it 'raises a CipherError exception due to a short key' do
|
||||
it 'raises an exception due to a short key' do
|
||||
key = SecureRandom.random_bytes(1)
|
||||
expect { Rex::Text.encrypt_aes256(iv, key, value) }.to raise_error(OpenSSL::Cipher::CipherError)
|
||||
# Because it could raise either a OpenSSL::Cipher::CipherError or an ArgumentError
|
||||
# dependong on the environment, we will just expect it to raise an exception
|
||||
expect { Rex::Text.encrypt_aes256(iv, key, value) }.to raise_exception
|
||||
end
|
||||
|
||||
it 'encrypts the string Hello World' do
|
||||
|
@ -35,14 +38,18 @@ describe Rex::Text do
|
|||
end
|
||||
|
||||
describe '#decrypt_aes256' do
|
||||
it 'raises a CipherError exception due to a short IV' do
|
||||
it 'raises an exception due to a short IV' do
|
||||
iv = SecureRandom.random_bytes(1)
|
||||
expect { Rex::Text.decrypt_aes256(iv, key, value) }.to raise_error(OpenSSL::Cipher::CipherError)
|
||||
# Because it could raise either a OpenSSL::Cipher::CipherError or an ArgumentError
|
||||
# dependong on the environment, we will just expect it to raise an exception
|
||||
expect { Rex::Text.decrypt_aes256(iv, key, value) }.to raise_exception
|
||||
end
|
||||
|
||||
it 'raises a CipherError exception due to a short key' do
|
||||
it 'raises an exception due to a short key' do
|
||||
key = SecureRandom.random_bytes(1)
|
||||
expect { Rex::Text.decrypt_aes256(iv, key, value) }.to raise_error(OpenSSL::Cipher::CipherError)
|
||||
# Because it could raise either a OpenSSL::Cipher::CipherError or an ArgumentError
|
||||
# dependong on the environment, we will just expect it to raise an exception
|
||||
expect { Rex::Text.decrypt_aes256(iv, key, value) }.to raise_exception
|
||||
end
|
||||
|
||||
it 'decrypts the value to Hello World' do
|
||||
|
|
Loading…
Reference in New Issue