【问题标题】:How to test user belongs to a list of group using Chef Inspec?如何使用 Chef Inspec 测试用户属于组列表?
【发布时间】:2017-10-03 12:01:32
【问题描述】:

我有一个用户 bogus_user 属于三个组 bogus_user, sftpusers and airflow

在我的规范中,我有以下声明,但我必须将组按特定顺序放置才能通过验证。我不认为这很理想,有没有办法让它检查组列表而不关心顺序?

describe user('bogus_user') do
  it { should exist }
  its('uid') { should eq 1002 }
  its('groups') { should include [ 'bogus_user', 'sftpusers', 'airflow' ] }
  its('home') { should eq '/var/ftp/pub/bogus_user' }
end

【问题讨论】:

    标签: inspec


    【解决方案1】:

    这不是最好也不是最理想的解决方案,但它确实有效:

    describe user('bogus_user') do
      it { should exist }
      its('uid') { should eq 1002 }
      %w(bogus_user sftpusers airflow).each do |group|
        its('groups') { should include group }
      end
      its('home') { should eq '/var/ftp/pub/bogus_user' }
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-27
      • 2018-03-30
      • 2017-12-14
      • 1970-01-01
      • 1970-01-01
      • 2021-04-11
      • 2018-01-12
      • 1970-01-01
      相关资源
      最近更新 更多