hotplate 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +1 -0
  4. data/bin/toast +2 -0
  5. data/hotplate.gemspec +30 -0
  6. data/lib/hotplate/cli/build.rb +51 -0
  7. data/lib/hotplate/cli/init.rb +64 -0
  8. data/lib/hotplate/cli/main.rb +39 -0
  9. data/lib/hotplate/gems/rubyzip-1.1.7/README.md +271 -0
  10. data/lib/hotplate/gems/rubyzip-1.1.7/Rakefile +19 -0
  11. data/lib/hotplate/gems/rubyzip-1.1.7/TODO +15 -0
  12. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/central_directory.rb +208 -0
  13. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/compressor.rb +10 -0
  14. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/constants.rb +63 -0
  15. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/encryption.rb +11 -0
  16. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/null_encryption.rb +45 -0
  17. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/traditional_encryption.rb +99 -0
  18. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/decompressor.rb +13 -0
  19. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/deflater.rb +32 -0
  20. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/dos_time.rb +49 -0
  21. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/entry.rb +696 -0
  22. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/entry_set.rb +86 -0
  23. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/errors.rb +16 -0
  24. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/generic.rb +43 -0
  25. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/ntfs.rb +92 -0
  26. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/old_unix.rb +45 -0
  27. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/universal_time.rb +47 -0
  28. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/unix.rb +38 -0
  29. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/zip64.rb +67 -0
  30. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/zip64_placeholder.rb +16 -0
  31. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field.rb +101 -0
  32. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/file.rb +436 -0
  33. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/filesystem.rb +626 -0
  34. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/inflater.rb +66 -0
  35. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/input_stream.rb +164 -0
  36. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras/abstract_input_stream.rb +115 -0
  37. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras/abstract_output_stream.rb +45 -0
  38. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras.rb +38 -0
  39. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_compressor.rb +15 -0
  40. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_decompressor.rb +27 -0
  41. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_input_stream.rb +10 -0
  42. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/output_stream.rb +190 -0
  43. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/pass_thru_compressor.rb +23 -0
  44. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/pass_thru_decompressor.rb +41 -0
  45. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/streamable_directory.rb +15 -0
  46. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/streamable_stream.rb +56 -0
  47. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/version.rb +3 -0
  48. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip.rb +63 -0
  49. data/lib/hotplate/gems/rubyzip-1.1.7/samples/example.rb +91 -0
  50. data/lib/hotplate/gems/rubyzip-1.1.7/samples/example_filesystem.rb +33 -0
  51. data/lib/hotplate/gems/rubyzip-1.1.7/samples/example_recursive.rb +48 -0
  52. data/lib/hotplate/gems/rubyzip-1.1.7/samples/gtkRubyzip.rb +86 -0
  53. data/lib/hotplate/gems/rubyzip-1.1.7/samples/qtzip.rb +101 -0
  54. data/lib/hotplate/gems/rubyzip-1.1.7/samples/write_simple.rb +13 -0
  55. data/lib/hotplate/gems/rubyzip-1.1.7/samples/zipfind.rb +74 -0
  56. data/lib/hotplate/gems/rubyzip-1.1.7/test/basic_zip_file_test.rb +64 -0
  57. data/lib/hotplate/gems/rubyzip-1.1.7/test/central_directory_entry_test.rb +73 -0
  58. data/lib/hotplate/gems/rubyzip-1.1.7/test/central_directory_test.rb +104 -0
  59. data/lib/hotplate/gems/rubyzip-1.1.7/test/crypto/null_encryption_test.rb +53 -0
  60. data/lib/hotplate/gems/rubyzip-1.1.7/test/crypto/traditional_encryption_test.rb +80 -0
  61. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/WarnInvalidDate.zip +0 -0
  62. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/file1.txt +46 -0
  63. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/file1.txt.deflatedData +0 -0
  64. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/file2.txt +1504 -0
  65. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest/foo/bar/baz/foo.txt +0 -0
  66. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest/foo.txt +0 -0
  67. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest/food.txt +0 -0
  68. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest.zip +0 -0
  69. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/mimetype +1 -0
  70. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/notzippedruby.rb +7 -0
  71. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/ntfs.zip +0 -0
  72. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/rubycode.zip +0 -0
  73. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/rubycode2.zip +0 -0
  74. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/testDirectory.bin +0 -0
  75. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/zip64-sample.zip +0 -0
  76. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/zipWithDirs.zip +0 -0
  77. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/zipWithEncryption.zip +0 -0
  78. data/lib/hotplate/gems/rubyzip-1.1.7/test/deflater_test.rb +67 -0
  79. data/lib/hotplate/gems/rubyzip-1.1.7/test/encryption_test.rb +42 -0
  80. data/lib/hotplate/gems/rubyzip-1.1.7/test/entry_set_test.rb +138 -0
  81. data/lib/hotplate/gems/rubyzip-1.1.7/test/entry_test.rb +165 -0
  82. data/lib/hotplate/gems/rubyzip-1.1.7/test/errors_test.rb +36 -0
  83. data/lib/hotplate/gems/rubyzip-1.1.7/test/extra_field_test.rb +78 -0
  84. data/lib/hotplate/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb +56 -0
  85. data/lib/hotplate/gems/rubyzip-1.1.7/test/file_extract_test.rb +90 -0
  86. data/lib/hotplate/gems/rubyzip-1.1.7/test/file_split_test.rb +60 -0
  87. data/lib/hotplate/gems/rubyzip-1.1.7/test/file_test.rb +559 -0
  88. data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/dir_iterator_test.rb +62 -0
  89. data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/directory_test.rb +131 -0
  90. data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_mutating_test.rb +100 -0
  91. data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb +514 -0
  92. data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_stat_test.rb +66 -0
  93. data/lib/hotplate/gems/rubyzip-1.1.7/test/gentestfiles.rb +134 -0
  94. data/lib/hotplate/gems/rubyzip-1.1.7/test/inflater_test.rb +14 -0
  95. data/lib/hotplate/gems/rubyzip-1.1.7/test/input_stream_test.rb +170 -0
  96. data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb +103 -0
  97. data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb +106 -0
  98. data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/fake_io_test.rb +18 -0
  99. data/lib/hotplate/gems/rubyzip-1.1.7/test/local_entry_test.rb +156 -0
  100. data/lib/hotplate/gems/rubyzip-1.1.7/test/output_stream_test.rb +129 -0
  101. data/lib/hotplate/gems/rubyzip-1.1.7/test/pass_thru_compressor_test.rb +31 -0
  102. data/lib/hotplate/gems/rubyzip-1.1.7/test/pass_thru_decompressor_test.rb +15 -0
  103. data/lib/hotplate/gems/rubyzip-1.1.7/test/settings_test.rb +92 -0
  104. data/lib/hotplate/gems/rubyzip-1.1.7/test/test_helper.rb +228 -0
  105. data/lib/hotplate/gems/rubyzip-1.1.7/test/unicode_file_names_and_comments_test.rb +52 -0
  106. data/lib/hotplate/gems/rubyzip-1.1.7/test/zip64_full_test.rb +53 -0
  107. data/lib/hotplate/gems/rubyzip-1.1.7/test/zip64_support_test.rb +15 -0
  108. data/lib/hotplate/java/build.gradle +38 -0
  109. data/lib/hotplate/java/gradle/wrapper/gradle-wrapper.jar +0 -0
  110. data/lib/hotplate/java/gradle/wrapper/gradle-wrapper.properties +6 -0
  111. data/lib/hotplate/java/gradlew +164 -0
  112. data/lib/hotplate/java/gradlew.bat +90 -0
  113. data/lib/hotplate/java/template.java +25 -0
  114. data/lib/hotplate/version.rb +3 -0
  115. data/lib/hotplate.rb +2 -0
  116. metadata +186 -0
@@ -0,0 +1,73 @@
1
+ require 'test_helper'
2
+
3
+ class ZipCentralDirectoryEntryTest < MiniTest::Test
4
+
5
+ def test_read_from_stream
6
+ File.open("test/data/testDirectory.bin", "rb") {
7
+ |file|
8
+ entry = ::Zip::Entry.read_c_dir_entry(file)
9
+
10
+ assert_equal("longAscii.txt", entry.name)
11
+ assert_equal(::Zip::Entry::DEFLATED, entry.compression_method)
12
+ assert_equal(106490, entry.size)
13
+ assert_equal(3784, entry.compressed_size)
14
+ assert_equal(0xfcd1799c, entry.crc)
15
+ assert_equal("", entry.comment)
16
+
17
+ entry = ::Zip::Entry.read_c_dir_entry(file)
18
+ assert_equal("empty.txt", entry.name)
19
+ assert_equal(::Zip::Entry::STORED, entry.compression_method)
20
+ assert_equal(0, entry.size)
21
+ assert_equal(0, entry.compressed_size)
22
+ assert_equal(0x0, entry.crc)
23
+ assert_equal("", entry.comment)
24
+
25
+ entry = ::Zip::Entry.read_c_dir_entry(file)
26
+ assert_equal("short.txt", entry.name)
27
+ assert_equal(::Zip::Entry::STORED, entry.compression_method)
28
+ assert_equal(6, entry.size)
29
+ assert_equal(6, entry.compressed_size)
30
+ assert_equal(0xbb76fe69, entry.crc)
31
+ assert_equal("", entry.comment)
32
+
33
+ entry = ::Zip::Entry.read_c_dir_entry(file)
34
+ assert_equal("longBinary.bin", entry.name)
35
+ assert_equal(::Zip::Entry::DEFLATED, entry.compression_method)
36
+ assert_equal(1000024, entry.size)
37
+ assert_equal(70847, entry.compressed_size)
38
+ assert_equal(0x10da7d59, entry.crc)
39
+ assert_equal('', entry.comment)
40
+
41
+ entry = ::Zip::Entry.read_c_dir_entry(file)
42
+ assert_equal(nil, entry)
43
+ # Fields that are not check by this test:
44
+ # version made by 2 bytes
45
+ # version needed to extract 2 bytes
46
+ # general purpose bit flag 2 bytes
47
+ # last mod file time 2 bytes
48
+ # last mod file date 2 bytes
49
+ # compressed size 4 bytes
50
+ # uncompressed size 4 bytes
51
+ # disk number start 2 bytes
52
+ # internal file attributes 2 bytes
53
+ # external file attributes 4 bytes
54
+ # relative offset of local header 4 bytes
55
+
56
+ # file name (variable size)
57
+ # extra field (variable size)
58
+ # file comment (variable size)
59
+
60
+ }
61
+ end
62
+
63
+ def test_ReadEntryFromTruncatedZipFile
64
+ fragment=""
65
+ File.open("test/data/testDirectory.bin") { |f| fragment = f.read(12) } # cdir entry header is at least 46 bytes
66
+ fragment.extend(IOizeString)
67
+ entry = ::Zip::Entry.new
68
+ entry.read_c_dir_entry(fragment)
69
+ fail "ZipError expected"
70
+ rescue ::Zip::Error
71
+ end
72
+
73
+ end
@@ -0,0 +1,104 @@
1
+ require 'test_helper'
2
+
3
+ class ZipCentralDirectoryTest < MiniTest::Test
4
+
5
+ def teardown
6
+ ::Zip.reset!
7
+ end
8
+
9
+ def test_read_from_stream
10
+ ::File.open(TestZipFile::TEST_ZIP2.zip_name, "rb") {
11
+ |zipFile|
12
+ cdir = ::Zip::CentralDirectory.read_from_stream(zipFile)
13
+
14
+ assert_equal(TestZipFile::TEST_ZIP2.entry_names.size, cdir.size)
15
+ assert(cdir.entries.sort.compare_enumerables(TestZipFile::TEST_ZIP2.entry_names.sort) {
16
+ |cdirEntry, testEntryName|
17
+ cdirEntry.name == testEntryName
18
+ })
19
+ assert_equal(TestZipFile::TEST_ZIP2.comment, cdir.comment)
20
+ }
21
+ end
22
+
23
+ def test_readFromInvalidStream
24
+ File.open("test/data/file2.txt", "rb") {
25
+ |zipFile|
26
+ cdir = ::Zip::CentralDirectory.new
27
+ cdir.read_from_stream(zipFile)
28
+ }
29
+ fail "ZipError expected!"
30
+ rescue ::Zip::Error
31
+ end
32
+
33
+ def test_ReadFromTruncatedZipFile
34
+ fragment=""
35
+ File.open("test/data/testDirectory.bin", "rb") { |f| fragment = f.read }
36
+ fragment.slice!(12) # removed part of first cdir entry. eocd structure still complete
37
+ fragment.extend(IOizeString)
38
+ entry = ::Zip::CentralDirectory.new
39
+ entry.read_from_stream(fragment)
40
+ fail "ZipError expected"
41
+ rescue ::Zip::Error
42
+ end
43
+
44
+ def test_write_to_stream
45
+ entries = [::Zip::Entry.new("file.zip", "flimse", "myComment", "somethingExtra"),
46
+ ::Zip::Entry.new("file.zip", "secondEntryName"),
47
+ ::Zip::Entry.new("file.zip", "lastEntry.txt", "Has a comment too")]
48
+ cdir = ::Zip::CentralDirectory.new(entries, "my zip comment")
49
+ File.open("test/data/generated/cdirtest.bin", "wb") { |f| cdir.write_to_stream(f) }
50
+ cdirReadback = ::Zip::CentralDirectory.new
51
+ File.open("test/data/generated/cdirtest.bin", "rb") { |f| cdirReadback.read_from_stream(f) }
52
+
53
+ assert_equal(cdir.entries.sort, cdirReadback.entries.sort)
54
+ end
55
+
56
+ def test_write64_to_stream
57
+ ::Zip.write_zip64_support = true
58
+ entries = [::Zip::Entry.new("file.zip", "file1-little", "comment1", "", 200, 101, ::Zip::Entry::STORED, 200),
59
+ ::Zip::Entry.new("file.zip", "file2-big", "comment2", "", 18000000000, 102, ::Zip::Entry::DEFLATED, 20000000000),
60
+ ::Zip::Entry.new("file.zip", "file3-alsobig", "comment3", "", 15000000000, 103, ::Zip::Entry::DEFLATED, 21000000000),
61
+ ::Zip::Entry.new("file.zip", "file4-little", "comment4", "", 100, 104, ::Zip::Entry::DEFLATED, 121)]
62
+ [0, 250, 18000000300, 33000000350].each_with_index do |offset, index|
63
+ entries[index].local_header_offset = offset
64
+ end
65
+ cdir = ::Zip::CentralDirectory.new(entries, "zip comment")
66
+ File.open("test/data/generated/cdir64test.bin", "wb") { |f| cdir.write_to_stream(f) }
67
+ cdirReadback = ::Zip::CentralDirectory.new
68
+ File.open("test/data/generated/cdir64test.bin", "rb") { |f| cdirReadback.read_from_stream(f) }
69
+
70
+ assert_equal(cdir.entries.sort, cdirReadback.entries.sort)
71
+ assert_equal(::Zip::VERSION_NEEDED_TO_EXTRACT_ZIP64, cdirReadback.instance_variable_get(:@version_needed_for_extract))
72
+ end
73
+
74
+ def test_equality
75
+ cdir1 = ::Zip::CentralDirectory.new([::Zip::Entry.new("file.zip", "flimse", nil,
76
+ "somethingExtra"),
77
+ ::Zip::Entry.new("file.zip", "secondEntryName"),
78
+ ::Zip::Entry.new("file.zip", "lastEntry.txt")],
79
+ "my zip comment")
80
+ cdir2 = ::Zip::CentralDirectory.new([::Zip::Entry.new("file.zip", "flimse", nil,
81
+ "somethingExtra"),
82
+ ::Zip::Entry.new("file.zip", "secondEntryName"),
83
+ ::Zip::Entry.new("file.zip", "lastEntry.txt")],
84
+ "my zip comment")
85
+ cdir3 = ::Zip::CentralDirectory.new([::Zip::Entry.new("file.zip", "flimse", nil,
86
+ "somethingExtra"),
87
+ ::Zip::Entry.new("file.zip", "secondEntryName"),
88
+ ::Zip::Entry.new("file.zip", "lastEntry.txt")],
89
+ "comment?")
90
+ cdir4 = ::Zip::CentralDirectory.new([::Zip::Entry.new("file.zip", "flimse", nil,
91
+ "somethingExtra"),
92
+ ::Zip::Entry.new("file.zip", "lastEntry.txt")],
93
+ "comment?")
94
+ assert_equal(cdir1, cdir1)
95
+ assert_equal(cdir1, cdir2)
96
+
97
+ assert(cdir1 != cdir3)
98
+ assert(cdir2 != cdir3)
99
+ assert(cdir2 != cdir3)
100
+ assert(cdir3 != cdir4)
101
+
102
+ assert(cdir3 != "hello")
103
+ end
104
+ end
@@ -0,0 +1,53 @@
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
+ [nil, '', 'a' * 10, 0xffffffff].each do |data|
22
+ assert_equal data, @encrypter.encrypt(data)
23
+ end
24
+ end
25
+
26
+ def test_reset!
27
+ assert_respond_to @encrypter, :reset!
28
+ end
29
+ end
30
+
31
+ class NullDecrypterTest < MiniTest::Test
32
+ def setup
33
+ @decrypter = ::Zip::NullDecrypter.new
34
+ end
35
+
36
+ def test_header_bytesize
37
+ assert_equal 0, @decrypter.header_bytesize
38
+ end
39
+
40
+ def test_gp_flags
41
+ assert_equal 0, @decrypter.gp_flags
42
+ end
43
+
44
+ def test_decrypt
45
+ [nil, '', 'a' * 10, 0xffffffff].each do |data|
46
+ assert_equal data, @decrypter.decrypt(data)
47
+ end
48
+ end
49
+
50
+ def test_reset!
51
+ assert_respond_to @decrypter, :reset!
52
+ end
53
+ end
@@ -0,0 +1,80 @@
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
@@ -0,0 +1,46 @@
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
+