Skip to content

file content doesn't work properly #244

@maratsal

Description

@maratsal

Describe the problem

When run kitchen verify it reports that content of the file is not matching. However when I check file content manually - the content is right. Seems when kitchen verify is fetching content of the file it appends ssh last login information to the content of the file:
The check:

  describe file('/etc/security/limits.d/95-hardening.conf') do
    it { should be_file }
    its('content') { should match "# FILE MANAGED BY CHEF, DO NOT EDIT\n* hard core 0" }
    its('mode') { should cmp '0644' }
  end

Failure:

  ×  hardening-base: Hardening Checks (1 failed)
     ✔  File /etc/security/limits.d/95-hardening.conf should be file
     ×  File /etc/security/limits.d/95-hardening.conf content should match "# FILE MANAGED BY CHEF, DO NOT EDIT\n* hard core 0"
     expected "# FILE MANAGED BY CHEF, DO NOT EDIT\n* hard core 0Last login: Sat Oct 26 21:09:58 EDT 2019\n" to match "# FILE MANAGED BY CHEF, DO NOT EDIT\n* hard core 0"
     Diff:
     @@ -1,3 +1,3 @@
      # FILE MANAGED BY CHEF, DO NOT EDIT
     -* hard core 0
     +* hard core 0Last login: Sat Oct 26 21:09:58 EDT 2019

chef dk version I use:

$ chef --version
ChefDK version: 4.5.1
Chef Infra Client version: 15.4.45
Chef InSpec version: 4.18.0
Test Kitchen version: 2.3.3
Foodcritic version: 16.1.1
Cookstyle version: 5.9.3

And here is my OS:

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15
BuildVersion:	19A602

Metadata

Metadata

Assignees

No one assigned

    Labels

    Aspect: UXHow users feel interacting with the project, focusing on function, ease-of-use and accessibility.Triage: Needs Verify

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions