Class: TraditionalEncrypterTest
- Inherits:
-
MiniTest::Test
- Object
- MiniTest::Test
- TraditionalEncrypterTest
- Defined in:
- lib/hotplate/gems/rubyzip-1.1.7/test/crypto/traditional_encryption_test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_encrypt ⇒ Object
- #test_gp_flags ⇒ Object
- #test_header ⇒ Object
- #test_header_bytesize ⇒ Object
- #test_reset! ⇒ Object
Instance Method Details
#setup ⇒ Object
4 5 6 7 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/crypto/traditional_encryption_test.rb', line 4 def setup @mtime = ::Zip::DOSTime.new(2014, 12, 17, 15, 56, 24) @encrypter = ::Zip::TraditionalEncrypter.new('password') end |
#test_encrypt ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/crypto/traditional_encryption_test.rb', line 25 def test_encrypt @encrypter.reset! Random.stub(:rand, 1) { @encrypter.header(@mtime) } assert_raises(NoMethodError) { @encrypter.encrypt(nil) } assert_raises(NoMethodError) { @encrypter.encrypt(1) } assert_equal '', @encrypter.encrypt('') assert_equal [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].pack("C*"), @encrypter.encrypt('a' * 10) end |
#test_gp_flags ⇒ Object
13 14 15 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/crypto/traditional_encryption_test.rb', line 13 def test_gp_flags assert_equal 9, @encrypter.gp_flags end |
#test_header ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/crypto/traditional_encryption_test.rb', line 17 def test_header @encrypter.reset! exepected = [239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack("C*") Random.stub(:rand, 1) do assert_equal exepected, @encrypter.header(@mtime) end end |
#test_header_bytesize ⇒ Object
9 10 11 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/crypto/traditional_encryption_test.rb', line 9 def test_header_bytesize assert_equal 12, @encrypter.header_bytesize end |
#test_reset! ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/crypto/traditional_encryption_test.rb', line 34 def test_reset! @encrypter.reset! Random.stub(:rand, 1) { @encrypter.header(@mtime) } [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].map(&:chr).each do |c| assert_equal c, @encrypter.encrypt('a') end assert_equal 56.chr, @encrypter.encrypt('a') @encrypter.reset! Random.stub(:rand, 1) { @encrypter.header(@mtime) } [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].map(&:chr).each do |c| assert_equal c, @encrypter.encrypt('a') end end |