Sha256: 56c3d678c317782a3d4ea48e5303b9e2199879d668d7729558dc73a25f78c5b6

Contents?: true

Size: 1.82 KB

Versions: 21

Compression:

Stored size: 1.82 KB

Contents

# encoding: utf-8

# options
inspec_bin = '/opt/chef-compliance/embedded/bin/inspec'
api_url = 'https://0.0.0.0'
profile = '/inspec/examples/profile'

# TODO: determine tokens automatically, define in kitchen yml
access_token = ENV['COMPLIANCE_ACCESS_TOKEN']
refresh_token = ENV['COMPLIANCE_REFRESH_TOKEN']

%w{refresh_token access_token}.each do |type|
  case type
  when 'access_token'
    token_options = "--token '#{access_token}'"
  when 'refresh_token'
    token_options = "--refresh_token '#{refresh_token}'"
  end

  # verifies that the help command works
  describe command("#{inspec_bin} compliance help") do
    its('stdout') { should include 'inspec compliance help [COMMAND]' }
    its('stderr') { should eq '' }
    its('exit_status') { should eq 0 }
  end

  # login via access token token
  describe command("#{inspec_bin} compliance login #{api_url} --insecure --user admin #{token_options}") do
    its('stdout') { should include 'Successfully authenticated' }
    its('stderr') { should eq '' }
    its('exit_status') { should eq 0 }
  end

  # see available resources
  describe command("#{inspec_bin} compliance profiles") do
    its('stdout') { should include 'base/ssh' }
    its('stderr') { should eq '' }
    its('exit_status') { should eq 0 }
  end

  # upload a compliance profile
  describe command("#{inspec_bin} compliance upload #{profile} --overwrite") do
    its('stdout') { should include 'Profile is valid' }
    its('stdout') { should include 'Successfully uploaded profile' }
    its('stdout') { should_not include 'error(s)' }
    its('stderr') { should eq '' }
    its('exit_status') { should eq 0 }
  end

  # logout
  describe command("#{inspec_bin} compliance logout") do
    its('stdout') { should include 'Successfully logged out' }
    its('stderr') { should eq '' }
    its('exit_status') { should eq 0 }
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
inspec-0.30.0 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.29.0 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.28.1 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.28.0 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.27.1 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.27.0 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.26.0 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.25.0 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.24.0 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.23 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.22.1 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.22.0 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.21.6 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.21.5 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.21.4 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.21.3 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.21.2 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.21.1 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.21.0 lib/bundles/inspec-compliance/test/integration/default/cli.rb
inspec-0.20.1 lib/bundles/inspec-compliance/test/integration/default/cli.rb