Merge pull request #4223 from inspec/zenspider/travis_umask

Set the umask on travis in before_install so that file resource permission matcher can be tested
This commit is contained in:
Miah Johnson 2019-06-20 11:34:53 -07:00 committed by GitHub
commit bbf7e81b92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -21,6 +21,7 @@ before_install:
- "gem update --system '3.0'"
- gem --version
- bundle --version
- umask 0022
env:
- SLOW=1 NO_AWS=1
- CI_ENABLE_COVERAGE=true SLOW=1

View file

@ -84,12 +84,17 @@ describe Inspec::Resources::FileResource do
let(:file) { stub(unix_mode_mask: 000, mode: 644) }
it "more_permissive_than?" do
skip_until 2019, 6, 21, "Breaks on travis-ci because file has 664, not 644"
resource = MockLoader.new(:ubuntu1404).load_resource("file", "/fakepath/fakefile")
_(resource).wont_be :more_permissive_than?, "755"
_(resource).wont_be :more_permissive_than?, "644"
_(resource).must_be :more_permissive_than?, "640"
# TODO: this is NOT a valid way to test. Please use _actual_ mock files
# so we aren't beholden to the CI umask and other trivialities.
path = "test/unit/mock/files/emptyfile"
File.chmod 0644, path
perms = "perms = %03o" % [File.stat(path).mode]
_(resource).wont_be :more_permissive_than?, "755", perms
_(resource).wont_be :more_permissive_than?, "644", perms
_(resource).must_be :more_permissive_than?, "640", perms
proc { resource.send(:more_permissive_than?, "0888") }.must_raise(ArgumentError)
end