Fix the A2 vendoring with depends on the A2 server. (#3022)

Signed-off-by: Jared Quick <jquick@chef.io>
This commit is contained in:
Jared Quick 2018-05-04 12:25:40 -04:00 committed by GitHub
parent 92bb4fd3ee
commit dabb1aa142
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -96,6 +96,12 @@ module Compliance
%r{^#{@config['server']}/owners/(?<owner>[^/]+)/compliance/(?<id>[^/]+)/tar$}
end.match(@target)
if Compliance::API.is_automate2_server?(@config)
m = {}
m[:owner] = @config['profile'][0]
m[:id] = @config['profile'][1]
end
raise 'Unable to determine compliance profile name. This can be caused by ' \
'an incorrect server in your configuration. Try to login to compliance ' \
'via the `inspec compliance login` command.' if m.nil?

View file

@ -3,6 +3,16 @@ require 'helper'
describe Compliance::Fetcher do
let(:config) { { 'server' => 'myserver' } }
describe 'when the server is an automate2 server' do
before { Compliance::API.expects(:is_automate2_server?).with(config).returns(true) }
it 'returns the correct owner and profile name' do
config['profile'] = ['admin', 'ssh-baseline', nil]
fetcher = Compliance::Fetcher.new('myserver/profile', config)
fetcher.send(:compliance_profile_name).must_equal 'admin/ssh-baseline'
end
end
describe 'when the server is an automate server pre-0.8.0' do
before { Compliance::API.expects(:is_automate_server_pre_080?).with(config).returns(true) }