Skip to content

Commit

Permalink
Test that an incorrectly stored mimetype is detected.
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Oct 20, 2018
1 parent 576a7dd commit d4bee33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Binary file added test/data/bad_mimetype_offset.container
Binary file not shown.
10 changes: 10 additions & 0 deletions test/read_file_test.rb
Expand Up @@ -77,6 +77,16 @@ def test_verify_compressed_mimetype
refute(ZipContainer::File.verify?(COMPRESSED_MIMETYPE))
end

# Check that a container with an incorrectly stored mimetype is detected.
def test_verify_bad_mimetype_offset
assert_raises(ZipContainer::MalformedContainerError) do
ZipContainer::File.verify!(BAD_MIMETYPE_OFFSET)
end

refute(ZipContainer::File.verify(BAD_MIMETYPE_OFFSET).empty?)
refute(ZipContainer::File.verify?(BAD_MIMETYPE_OFFSET))
end

# Check the raw mimetype bytes
def test_raw_mimetypes
empty_container = File.read(EMPTY_CONT)
Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Expand Up @@ -50,5 +50,6 @@
EMPTY_CONT = 'test/data/empty.container'.freeze
EMPTY_ZIP = 'test/data/empty.zip'.freeze
COMPRESSED_MIMETYPE = 'test/data/compressed_mimetype.container'.freeze
BAD_MIMETYPE_OFFSET = 'test/data/bad_mimetype_offset.container'.freeze
EXAMPLE = 'test/data/example.container'.freeze
SUBCLASS = 'test/data/subclassed.container'.freeze

0 comments on commit d4bee33

Please sign in to comment.