rubyzip 1.3.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -8
  3. data/Rakefile +3 -0
  4. data/lib/zip.rb +4 -3
  5. data/lib/zip/central_directory.rb +9 -5
  6. data/lib/zip/constants.rb +52 -0
  7. data/lib/zip/crypto/decrypted_io.rb +40 -0
  8. data/lib/zip/crypto/traditional_encryption.rb +9 -9
  9. data/lib/zip/decompressor.rb +19 -1
  10. data/lib/zip/dos_time.rb +12 -7
  11. data/lib/zip/entry.rb +57 -38
  12. data/lib/zip/entry_set.rb +2 -0
  13. data/lib/zip/errors.rb +1 -0
  14. data/lib/zip/extra_field.rb +11 -9
  15. data/lib/zip/extra_field/generic.rb +10 -9
  16. data/lib/zip/extra_field/ntfs.rb +4 -0
  17. data/lib/zip/extra_field/old_unix.rb +3 -1
  18. data/lib/zip/extra_field/universal_time.rb +42 -12
  19. data/lib/zip/extra_field/unix.rb +3 -1
  20. data/lib/zip/extra_field/zip64.rb +4 -2
  21. data/lib/zip/file.rb +79 -54
  22. data/lib/zip/filesystem.rb +193 -177
  23. data/lib/zip/inflater.rb +24 -36
  24. data/lib/zip/input_stream.rb +33 -26
  25. data/lib/zip/ioextras.rb +1 -1
  26. data/lib/zip/ioextras/abstract_input_stream.rb +19 -8
  27. data/lib/zip/ioextras/abstract_output_stream.rb +1 -1
  28. data/lib/zip/null_decompressor.rb +1 -9
  29. data/lib/zip/output_stream.rb +14 -5
  30. data/lib/zip/pass_thru_compressor.rb +2 -2
  31. data/lib/zip/pass_thru_decompressor.rb +13 -22
  32. data/lib/zip/streamable_directory.rb +3 -3
  33. data/lib/zip/streamable_stream.rb +6 -10
  34. data/lib/zip/version.rb +1 -1
  35. data/samples/example.rb +2 -2
  36. data/samples/example_filesystem.rb +1 -1
  37. data/samples/gtk_ruby_zip.rb +19 -19
  38. data/samples/qtzip.rb +6 -6
  39. data/samples/write_simple.rb +2 -4
  40. data/samples/zipfind.rb +23 -22
  41. metadata +28 -169
  42. data/test/basic_zip_file_test.rb +0 -60
  43. data/test/case_sensitivity_test.rb +0 -69
  44. data/test/central_directory_entry_test.rb +0 -69
  45. data/test/central_directory_test.rb +0 -100
  46. data/test/crypto/null_encryption_test.rb +0 -57
  47. data/test/crypto/traditional_encryption_test.rb +0 -80
  48. data/test/data/WarnInvalidDate.zip +0 -0
  49. data/test/data/file1.txt +0 -46
  50. data/test/data/file1.txt.deflatedData +0 -0
  51. data/test/data/file2.txt +0 -1504
  52. data/test/data/globTest.zip +0 -0
  53. data/test/data/globTest/foo.txt +0 -0
  54. data/test/data/globTest/foo/bar/baz/foo.txt +0 -0
  55. data/test/data/globTest/food.txt +0 -0
  56. data/test/data/gpbit3stored.zip +0 -0
  57. data/test/data/mimetype +0 -1
  58. data/test/data/notzippedruby.rb +0 -7
  59. data/test/data/ntfs.zip +0 -0
  60. data/test/data/oddExtraField.zip +0 -0
  61. data/test/data/path_traversal/Makefile +0 -10
  62. data/test/data/path_traversal/jwilk/README.md +0 -5
  63. data/test/data/path_traversal/jwilk/absolute1.zip +0 -0
  64. data/test/data/path_traversal/jwilk/absolute2.zip +0 -0
  65. data/test/data/path_traversal/jwilk/dirsymlink.zip +0 -0
  66. data/test/data/path_traversal/jwilk/dirsymlink2a.zip +0 -0
  67. data/test/data/path_traversal/jwilk/dirsymlink2b.zip +0 -0
  68. data/test/data/path_traversal/jwilk/relative0.zip +0 -0
  69. data/test/data/path_traversal/jwilk/relative2.zip +0 -0
  70. data/test/data/path_traversal/jwilk/symlink.zip +0 -0
  71. data/test/data/path_traversal/relative1.zip +0 -0
  72. data/test/data/path_traversal/tilde.zip +0 -0
  73. data/test/data/path_traversal/tuzovakaoff/README.md +0 -3
  74. data/test/data/path_traversal/tuzovakaoff/absolutepath.zip +0 -0
  75. data/test/data/path_traversal/tuzovakaoff/symlink.zip +0 -0
  76. data/test/data/rubycode.zip +0 -0
  77. data/test/data/rubycode2.zip +0 -0
  78. data/test/data/test.xls +0 -0
  79. data/test/data/testDirectory.bin +0 -0
  80. data/test/data/zip64-sample.zip +0 -0
  81. data/test/data/zipWithDirs.zip +0 -0
  82. data/test/data/zipWithEncryption.zip +0 -0
  83. data/test/deflater_test.rb +0 -65
  84. data/test/encryption_test.rb +0 -42
  85. data/test/entry_set_test.rb +0 -163
  86. data/test/entry_test.rb +0 -154
  87. data/test/errors_test.rb +0 -35
  88. data/test/extra_field_test.rb +0 -76
  89. data/test/file_extract_directory_test.rb +0 -54
  90. data/test/file_extract_test.rb +0 -145
  91. data/test/file_permissions_test.rb +0 -65
  92. data/test/file_split_test.rb +0 -57
  93. data/test/file_test.rb +0 -666
  94. data/test/filesystem/dir_iterator_test.rb +0 -58
  95. data/test/filesystem/directory_test.rb +0 -139
  96. data/test/filesystem/file_mutating_test.rb +0 -87
  97. data/test/filesystem/file_nonmutating_test.rb +0 -508
  98. data/test/filesystem/file_stat_test.rb +0 -64
  99. data/test/gentestfiles.rb +0 -126
  100. data/test/inflater_test.rb +0 -14
  101. data/test/input_stream_test.rb +0 -182
  102. data/test/ioextras/abstract_input_stream_test.rb +0 -102
  103. data/test/ioextras/abstract_output_stream_test.rb +0 -106
  104. data/test/ioextras/fake_io_test.rb +0 -18
  105. data/test/local_entry_test.rb +0 -154
  106. data/test/output_stream_test.rb +0 -128
  107. data/test/pass_thru_compressor_test.rb +0 -30
  108. data/test/pass_thru_decompressor_test.rb +0 -14
  109. data/test/path_traversal_test.rb +0 -141
  110. data/test/samples/example_recursive_test.rb +0 -37
  111. data/test/settings_test.rb +0 -95
  112. data/test/test_helper.rb +0 -234
  113. data/test/unicode_file_names_and_comments_test.rb +0 -62
  114. data/test/zip64_full_test.rb +0 -51
  115. data/test/zip64_support_test.rb +0 -14
@@ -1,60 +0,0 @@
1
- require 'test_helper'
2
-
3
- class BasicZipFileTest < MiniTest::Test
4
- include AssertEntry
5
-
6
- def setup
7
- @zip_file = ::Zip::File.new(TestZipFile::TEST_ZIP2.zip_name)
8
- @testEntryNameIndex = 0
9
- end
10
-
11
- def test_entries
12
- assert_equal(TestZipFile::TEST_ZIP2.entry_names.sort,
13
- @zip_file.entries.entries.sort.map { |e| e.name })
14
- end
15
-
16
- def test_each
17
- count = 0
18
- visited = {}
19
- @zip_file.each do |entry|
20
- assert(TestZipFile::TEST_ZIP2.entry_names.include?(entry.name))
21
- assert(!visited.include?(entry.name))
22
- visited[entry.name] = nil
23
- count = count.succ
24
- end
25
- assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
26
- end
27
-
28
- def test_foreach
29
- count = 0
30
- visited = {}
31
- ::Zip::File.foreach(TestZipFile::TEST_ZIP2.zip_name) do |entry|
32
- assert(TestZipFile::TEST_ZIP2.entry_names.include?(entry.name))
33
- assert(!visited.include?(entry.name))
34
- visited[entry.name] = nil
35
- count = count.succ
36
- end
37
- assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
38
- end
39
-
40
- def test_get_input_stream
41
- count = 0
42
- visited = {}
43
- @zip_file.each do |entry|
44
- assert_entry(entry.name, @zip_file.get_input_stream(entry), entry.name)
45
- assert(!visited.include?(entry.name))
46
- visited[entry.name] = nil
47
- count = count.succ
48
- end
49
- assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
50
- end
51
-
52
- def test_get_input_stream_block
53
- fileAndEntryName = @zip_file.entries.first.name
54
- @zip_file.get_input_stream(fileAndEntryName) do |zis|
55
- assert_entry_contents_for_stream(fileAndEntryName,
56
- zis,
57
- fileAndEntryName)
58
- end
59
- end
60
- end
@@ -1,69 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ZipCaseSensitivityTest < MiniTest::Test
4
- include CommonZipFileFixture
5
-
6
- SRC_FILES = [['test/data/file1.txt', 'testfile.rb'],
7
- ['test/data/file2.txt', 'testFILE.rb']]
8
-
9
- def teardown
10
- ::Zip.case_insensitive_match = false
11
- end
12
-
13
- # Ensure that everything functions normally when +case_insensitive_match = false+
14
- def test_add_case_sensitive
15
- ::Zip.case_insensitive_match = false
16
-
17
- SRC_FILES.each { |fn, _en| assert(::File.exist?(fn)) }
18
- zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE)
19
-
20
- SRC_FILES.each { |fn, en| zf.add(en, fn) }
21
- zf.close
22
-
23
- zfRead = ::Zip::File.new(EMPTY_FILENAME)
24
- assert_equal(SRC_FILES.size, zfRead.entries.length)
25
- SRC_FILES.each_with_index { |a, i|
26
- assert_equal(a.last, zfRead.entries[i].name)
27
- AssertEntry.assert_contents(a.first,
28
- zfRead.get_input_stream(a.last) { |zis| zis.read })
29
- }
30
- end
31
-
32
- # Ensure that names are treated case insensitively when adding files and +case_insensitive_match = false+
33
- def test_add_case_insensitive
34
- ::Zip.case_insensitive_match = true
35
-
36
- SRC_FILES.each { |fn, _en| assert(::File.exist?(fn)) }
37
- zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE)
38
-
39
- assert_raises Zip::EntryExistsError do
40
- SRC_FILES.each { |fn, en| zf.add(en, fn) }
41
- end
42
- end
43
-
44
- # Ensure that names are treated case insensitively when reading files and +case_insensitive_match = true+
45
- def test_add_case_sensitive_read_case_insensitive
46
- ::Zip.case_insensitive_match = false
47
-
48
- SRC_FILES.each { |fn, _en| assert(::File.exist?(fn)) }
49
- zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE)
50
-
51
- SRC_FILES.each { |fn, en| zf.add(en, fn) }
52
- zf.close
53
-
54
- ::Zip.case_insensitive_match = true
55
-
56
- zfRead = ::Zip::File.new(EMPTY_FILENAME)
57
- assert_equal(SRC_FILES.collect { |_fn, en| en.downcase }.uniq.size, zfRead.entries.length)
58
- assert_equal(SRC_FILES.last.last.downcase, zfRead.entries.first.name.downcase)
59
- AssertEntry.assert_contents(SRC_FILES.last.first,
60
- zfRead.get_input_stream(SRC_FILES.last.last) { |zis| zis.read })
61
- end
62
-
63
- private
64
-
65
- def assert_contains(zf, entryName, filename = entryName)
66
- assert(zf.entries.detect { |e| e.name == entryName } != nil, "entry #{entryName} not in #{zf.entries.join(', ')} in zip file #{zf}")
67
- assert_entry_contents(zf, entryName, filename) if File.exist?(filename)
68
- end
69
- end
@@ -1,69 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ZipCentralDirectoryEntryTest < MiniTest::Test
4
- def test_read_from_stream
5
- File.open('test/data/testDirectory.bin', 'rb') do |file|
6
- entry = ::Zip::Entry.read_c_dir_entry(file)
7
-
8
- assert_equal('longAscii.txt', entry.name)
9
- assert_equal(::Zip::Entry::DEFLATED, entry.compression_method)
10
- assert_equal(106_490, entry.size)
11
- assert_equal(3784, entry.compressed_size)
12
- assert_equal(0xfcd1799c, entry.crc)
13
- assert_equal('', entry.comment)
14
-
15
- entry = ::Zip::Entry.read_c_dir_entry(file)
16
- assert_equal('empty.txt', entry.name)
17
- assert_equal(::Zip::Entry::STORED, entry.compression_method)
18
- assert_equal(0, entry.size)
19
- assert_equal(0, entry.compressed_size)
20
- assert_equal(0x0, entry.crc)
21
- assert_equal('', entry.comment)
22
-
23
- entry = ::Zip::Entry.read_c_dir_entry(file)
24
- assert_equal('short.txt', entry.name)
25
- assert_equal(::Zip::Entry::STORED, entry.compression_method)
26
- assert_equal(6, entry.size)
27
- assert_equal(6, entry.compressed_size)
28
- assert_equal(0xbb76fe69, entry.crc)
29
- assert_equal('', entry.comment)
30
-
31
- entry = ::Zip::Entry.read_c_dir_entry(file)
32
- assert_equal('longBinary.bin', entry.name)
33
- assert_equal(::Zip::Entry::DEFLATED, entry.compression_method)
34
- assert_equal(1_000_024, entry.size)
35
- assert_equal(70_847, entry.compressed_size)
36
- assert_equal(0x10da7d59, entry.crc)
37
- assert_equal('', entry.comment)
38
-
39
- entry = ::Zip::Entry.read_c_dir_entry(file)
40
- assert_nil(entry)
41
- # Fields that are not check by this test:
42
- # version made by 2 bytes
43
- # version needed to extract 2 bytes
44
- # general purpose bit flag 2 bytes
45
- # last mod file time 2 bytes
46
- # last mod file date 2 bytes
47
- # compressed size 4 bytes
48
- # uncompressed size 4 bytes
49
- # disk number start 2 bytes
50
- # internal file attributes 2 bytes
51
- # external file attributes 4 bytes
52
- # relative offset of local header 4 bytes
53
-
54
- # file name (variable size)
55
- # extra field (variable size)
56
- # file comment (variable size)
57
- end
58
- end
59
-
60
- def test_read_entry_from_truncated_zip_file
61
- fragment = ''
62
- File.open('test/data/testDirectory.bin') { |f| fragment = f.read(12) } # cdir entry header is at least 46 bytes
63
- fragment.extend(IOizeString)
64
- entry = ::Zip::Entry.new
65
- entry.read_c_dir_entry(fragment)
66
- fail 'ZipError expected'
67
- rescue ::Zip::Error
68
- end
69
- end
@@ -1,100 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ZipCentralDirectoryTest < MiniTest::Test
4
- def teardown
5
- ::Zip.reset!
6
- end
7
-
8
- def test_read_from_stream
9
- ::File.open(TestZipFile::TEST_ZIP2.zip_name, 'rb') do |zipFile|
10
- cdir = ::Zip::CentralDirectory.read_from_stream(zipFile)
11
-
12
- assert_equal(TestZipFile::TEST_ZIP2.entry_names.size, cdir.size)
13
- assert(cdir.entries.sort.compare_enumerables(TestZipFile::TEST_ZIP2.entry_names.sort) do |cdirEntry, testEntryName|
14
- cdirEntry.name == testEntryName
15
- end)
16
- assert_equal(TestZipFile::TEST_ZIP2.comment, cdir.comment)
17
- end
18
- end
19
-
20
- def test_read_from_invalid_stream
21
- File.open('test/data/file2.txt', 'rb') do |zipFile|
22
- cdir = ::Zip::CentralDirectory.new
23
- cdir.read_from_stream(zipFile)
24
- end
25
- fail 'ZipError expected!'
26
- rescue ::Zip::Error
27
- end
28
-
29
- def test_read_from_truncated_zip_file
30
- fragment = ''
31
- File.open('test/data/testDirectory.bin', 'rb') { |f| fragment = f.read }
32
- fragment.slice!(12) # removed part of first cdir entry. eocd structure still complete
33
- fragment.extend(IOizeString)
34
- entry = ::Zip::CentralDirectory.new
35
- entry.read_from_stream(fragment)
36
- fail 'ZipError expected'
37
- rescue ::Zip::Error
38
- end
39
-
40
- def test_write_to_stream
41
- entries = [::Zip::Entry.new('file.zip', 'flimse', 'myComment', 'somethingExtra'),
42
- ::Zip::Entry.new('file.zip', 'secondEntryName'),
43
- ::Zip::Entry.new('file.zip', 'lastEntry.txt', 'Has a comment too')]
44
- cdir = ::Zip::CentralDirectory.new(entries, 'my zip comment')
45
- File.open('test/data/generated/cdirtest.bin', 'wb') { |f| cdir.write_to_stream(f) }
46
- cdirReadback = ::Zip::CentralDirectory.new
47
- File.open('test/data/generated/cdirtest.bin', 'rb') { |f| cdirReadback.read_from_stream(f) }
48
-
49
- assert_equal(cdir.entries.sort, cdirReadback.entries.sort)
50
- end
51
-
52
- def test_write64_to_stream
53
- ::Zip.write_zip64_support = true
54
- entries = [::Zip::Entry.new('file.zip', 'file1-little', 'comment1', '', 200, 101, ::Zip::Entry::STORED, 200),
55
- ::Zip::Entry.new('file.zip', 'file2-big', 'comment2', '', 18_000_000_000, 102, ::Zip::Entry::DEFLATED, 20_000_000_000),
56
- ::Zip::Entry.new('file.zip', 'file3-alsobig', 'comment3', '', 15_000_000_000, 103, ::Zip::Entry::DEFLATED, 21_000_000_000),
57
- ::Zip::Entry.new('file.zip', 'file4-little', 'comment4', '', 100, 104, ::Zip::Entry::DEFLATED, 121)]
58
- [0, 250, 18_000_000_300, 33_000_000_350].each_with_index do |offset, index|
59
- entries[index].local_header_offset = offset
60
- end
61
- cdir = ::Zip::CentralDirectory.new(entries, 'zip comment')
62
- File.open('test/data/generated/cdir64test.bin', 'wb') { |f| cdir.write_to_stream(f) }
63
- cdirReadback = ::Zip::CentralDirectory.new
64
- File.open('test/data/generated/cdir64test.bin', 'rb') { |f| cdirReadback.read_from_stream(f) }
65
-
66
- assert_equal(cdir.entries.sort, cdirReadback.entries.sort)
67
- assert_equal(::Zip::VERSION_NEEDED_TO_EXTRACT_ZIP64, cdirReadback.instance_variable_get(:@version_needed_for_extract))
68
- end
69
-
70
- def test_equality
71
- cdir1 = ::Zip::CentralDirectory.new([::Zip::Entry.new('file.zip', 'flimse', nil,
72
- 'somethingExtra'),
73
- ::Zip::Entry.new('file.zip', 'secondEntryName'),
74
- ::Zip::Entry.new('file.zip', 'lastEntry.txt')],
75
- 'my zip comment')
76
- cdir2 = ::Zip::CentralDirectory.new([::Zip::Entry.new('file.zip', 'flimse', nil,
77
- 'somethingExtra'),
78
- ::Zip::Entry.new('file.zip', 'secondEntryName'),
79
- ::Zip::Entry.new('file.zip', 'lastEntry.txt')],
80
- 'my zip comment')
81
- cdir3 = ::Zip::CentralDirectory.new([::Zip::Entry.new('file.zip', 'flimse', nil,
82
- 'somethingExtra'),
83
- ::Zip::Entry.new('file.zip', 'secondEntryName'),
84
- ::Zip::Entry.new('file.zip', 'lastEntry.txt')],
85
- 'comment?')
86
- cdir4 = ::Zip::CentralDirectory.new([::Zip::Entry.new('file.zip', 'flimse', nil,
87
- 'somethingExtra'),
88
- ::Zip::Entry.new('file.zip', 'lastEntry.txt')],
89
- 'comment?')
90
- assert_equal(cdir1, cdir1)
91
- assert_equal(cdir1, cdir2)
92
-
93
- assert(cdir1 != cdir3)
94
- assert(cdir2 != cdir3)
95
- assert(cdir2 != cdir3)
96
- assert(cdir3 != cdir4)
97
-
98
- assert(cdir3 != 'hello')
99
- end
100
- end
@@ -1,57 +0,0 @@
1
- require 'test_helper'
2
-
3
- class NullEncrypterTest < MiniTest::Test
4
- def setup
5
- @encrypter = ::Zip::NullEncrypter.new
6
- end
7
-
8
- def test_header_bytesize
9
- assert_equal 0, @encrypter.header_bytesize
10
- end
11
-
12
- def test_gp_flags
13
- assert_equal 0, @encrypter.gp_flags
14
- end
15
-
16
- def test_header
17
- assert_empty @encrypter.header(nil)
18
- end
19
-
20
- def test_encrypt
21
- assert_nil @encrypter.encrypt(nil)
22
-
23
- ['', 'a' * 10, 0xffffffff].each do |data|
24
- assert_equal data, @encrypter.encrypt(data)
25
- end
26
- end
27
-
28
- def test_reset!
29
- assert_respond_to @encrypter, :reset!
30
- end
31
- end
32
-
33
- class NullDecrypterTest < MiniTest::Test
34
- def setup
35
- @decrypter = ::Zip::NullDecrypter.new
36
- end
37
-
38
- def test_header_bytesize
39
- assert_equal 0, @decrypter.header_bytesize
40
- end
41
-
42
- def test_gp_flags
43
- assert_equal 0, @decrypter.gp_flags
44
- end
45
-
46
- def test_decrypt
47
- assert_nil @decrypter.decrypt(nil)
48
-
49
- ['', 'a' * 10, 0xffffffff].each do |data|
50
- assert_equal data, @decrypter.decrypt(data)
51
- end
52
- end
53
-
54
- def test_reset!
55
- assert_respond_to @decrypter, :reset!
56
- end
57
- end
@@ -1,80 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TraditionalEncrypterTest < MiniTest::Test
4
- def setup
5
- @mtime = ::Zip::DOSTime.new(2014, 12, 17, 15, 56, 24)
6
- @encrypter = ::Zip::TraditionalEncrypter.new('password')
7
- end
8
-
9
- def test_header_bytesize
10
- assert_equal 12, @encrypter.header_bytesize
11
- end
12
-
13
- def test_gp_flags
14
- assert_equal 9, @encrypter.gp_flags
15
- end
16
-
17
- def test_header
18
- @encrypter.reset!
19
- exepected = [239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack('C*')
20
- Random.stub(:rand, 1) do
21
- assert_equal exepected, @encrypter.header(@mtime)
22
- end
23
- end
24
-
25
- def test_encrypt
26
- @encrypter.reset!
27
- Random.stub(:rand, 1) { @encrypter.header(@mtime) }
28
- assert_raises(NoMethodError) { @encrypter.encrypt(nil) }
29
- assert_raises(NoMethodError) { @encrypter.encrypt(1) }
30
- assert_equal '', @encrypter.encrypt('')
31
- assert_equal [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].pack('C*'), @encrypter.encrypt('a' * 10)
32
- end
33
-
34
- def test_reset!
35
- @encrypter.reset!
36
- Random.stub(:rand, 1) { @encrypter.header(@mtime) }
37
- [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].map(&:chr).each do |c|
38
- assert_equal c, @encrypter.encrypt('a')
39
- end
40
- assert_equal 56.chr, @encrypter.encrypt('a')
41
- @encrypter.reset!
42
- Random.stub(:rand, 1) { @encrypter.header(@mtime) }
43
- [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].map(&:chr).each do |c|
44
- assert_equal c, @encrypter.encrypt('a')
45
- end
46
- end
47
- end
48
-
49
- class TraditionalDecrypterTest < MiniTest::Test
50
- def setup
51
- @decrypter = ::Zip::TraditionalDecrypter.new('password')
52
- end
53
-
54
- def test_header_bytesize
55
- assert_equal 12, @decrypter.header_bytesize
56
- end
57
-
58
- def test_gp_flags
59
- assert_equal 9, @decrypter.gp_flags
60
- end
61
-
62
- def test_decrypt
63
- @decrypter.reset!([239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack('C*'))
64
- [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].map(&:chr).each do |c|
65
- assert_equal 'a', @decrypter.decrypt(c)
66
- end
67
- end
68
-
69
- def test_reset!
70
- @decrypter.reset!([239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack('C*'))
71
- [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].map(&:chr).each do |c|
72
- assert_equal 'a', @decrypter.decrypt(c)
73
- end
74
- assert_equal 91.chr, @decrypter.decrypt(2.chr)
75
- @decrypter.reset!([239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack('C*'))
76
- [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].map(&:chr).each do |c|
77
- assert_equal 'a', @decrypter.decrypt(c)
78
- end
79
- end
80
- end
Binary file
data/test/data/file1.txt DELETED
@@ -1,46 +0,0 @@
1
-
2
- AUTOMAKE_OPTIONS = gnu
3
-
4
- EXTRA_DIST = test.zip
5
-
6
- CXXFLAGS= -g
7
-
8
- noinst_LIBRARIES = libzipios.a
9
-
10
- bin_PROGRAMS = test_zip test_izipfilt test_izipstream
11
- # test_flist
12
-
13
- libzipios_a_SOURCES = backbuffer.h fcol.cpp fcol.h \
14
- fcol_common.h fcolexceptions.cpp fcolexceptions.h \
15
- fileentry.cpp fileentry.h flist.cpp \
16
- flist.h flistentry.cpp flistentry.h \
17
- flistscanner.h ifiltstreambuf.cpp ifiltstreambuf.h \
18
- inflatefilt.cpp inflatefilt.h izipfilt.cpp \
19
- izipfilt.h izipstream.cpp izipstream.h \
20
- zipfile.cpp zipfile.h ziphead.cpp \
21
- ziphead.h flistscanner.ll
22
-
23
- # test_flist_SOURCES = test_flist.cpp
24
-
25
- test_izipfilt_SOURCES = test_izipfilt.cpp
26
-
27
- test_izipstream_SOURCES = test_izipstream.cpp
28
-
29
- test_zip_SOURCES = test_zip.cpp
30
-
31
- # Notice that libzipios.a is not specified as -L. -lzipios
32
- # If it was, automake would not include it as a dependency.
33
-
34
- # test_flist_LDADD = libzipios.a
35
-
36
- test_izipfilt_LDADD = libzipios.a -lz
37
-
38
- test_zip_LDADD = libzipios.a -lz
39
-
40
- test_izipstream_LDADD = libzipios.a -lz
41
-
42
-
43
-
44
- flistscanner.cc : flistscanner.ll
45
- $(LEX) -+ -PFListScanner -o$@ $^
46
-