Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file resource mode matcher does not display file permissions correctly on failure #230

Closed
ScottKinder opened this issue Nov 10, 2015 · 3 comments
Labels
Type: Enhancement Improves an existing feature
Milestone

Comments

@ScottKinder
Copy link

When a file does not match the intended mode value, the failure return does not list what the mode is in the typical fashion, i.e., 0644, 0777, etc. Instead, as in the following example, it returns that it should equal 416 but instead equals 420. I would expect it to return the file permissions.

root@997d17a0fd01:~# cat spec.rb
describe file('/root/file') do
    its('mode') { should eq 0640 }
end
root@997d17a0fd01:~# ls -l file
-rw-r--r-- 1 root root 0 Nov 10 18:17 file
root@997d17a0fd01:~# inspec exec spec.rb
F

Failures:

  1) File /root/file mode should eq 416
     Failure/Error: its('mode') { should eq 0640 }

       expected: 416
            got: 420

       (compared using ==)
     # spec.rb:2:in `block (2 levels) in load'
     # /var/lib/gems/1.9.1/gems/inspec-0.9.2/lib/inspec/runner.rb:89:in `run_with'
     # /var/lib/gems/1.9.1/gems/inspec-0.9.2/lib/inspec/runner.rb:85:in `run'
     # /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
     # /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
     # /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
     # /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'

Finished in 0.04819 seconds (files took 0.21259 seconds to load)
1 example, 1 failure

Failed examples:

rspec  # File /root/file mode should eq 416
@chris-rock
Copy link
Contributor

@ScottKinder Thanks for reporting this! I agree with you, its hard to work with the current output. We need to optimize the output to print the permissions in a human readable way

@chris-rock chris-rock added the Type: Enhancement Improves an existing feature label Nov 23, 2015
@arlimus arlimus added this to the 0.9.7 milestone Dec 7, 2015
@srenatus srenatus self-assigned this Dec 16, 2015
@srenatus
Copy link
Contributor

@ScottKinder With #324, you can now write your example as follows:

describe file('/root/file') do
    its('mode') { should cmp '0640' }
end

...and get the output in the convenient octal format, too. What do you think, workable solution? 😉

@arlimus
Copy link
Contributor

arlimus commented Dec 21, 2015

Please reopen if this still persists in the latest release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Improves an existing feature
Projects
None yet
Development

No branches or pull requests

4 participants