Sha256: f8a99dedf73da30a2c48ff7a3e4acd9aacf9eba97849223f0d740dd8371bde6a
Contents?: true
Size: 1.33 KB
Versions: 4
Compression:
Stored size: 1.33 KB
Contents
require_relative 'test_helper' class PgpReaderTest < Minitest::Test describe IOStreams::Pgp::Reader do let :temp_file do Tempfile.new('iostreams') end let :decrypted do file_name = File.join(File.dirname(__FILE__), 'files', 'text.txt') File.read(file_name) end after do temp_file.delete end describe '.open' do it 'reads encrypted file' do IOStreams::Pgp::Writer.open(temp_file.path, recipient: 'receiver@example.org') do |io| io.write(decrypted) end result = IOStreams::Pgp::Reader.open(temp_file.path, passphrase: 'receiver_passphrase') { |file| file.read } assert_equal decrypted, result end it 'fails with bad passphrase' do assert_raises IOStreams::Pgp::Failure do IOStreams::Pgp::Reader.open(temp_file.path, passphrase: 'BAD') { |file| file.read } end end it 'streams input' do IOStreams::Pgp::Writer.open(temp_file.path, recipient: 'receiver@example.org') do |io| io.write(decrypted) end encrypted = IOStreams::File::Reader.open(temp_file.path, &:read) io = StringIO.new(encrypted) result = IOStreams::Pgp::Reader.open(io, passphrase: 'receiver_passphrase', &:read) assert_equal decrypted, result end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
iostreams-0.20.3 | test/pgp_reader_test.rb |
iostreams-0.20.2 | test/pgp_reader_test.rb |
iostreams-0.20.1 | test/pgp_reader_test.rb |
iostreams-0.20.0 | test/pgp_reader_test.rb |