mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
Add A2 support for profile compliance depends. (#3014)
Signed-off-by: Jared Quick <jquick@chef.io>
This commit is contained in:
parent
7a11c51297
commit
54c1ed62f9
2 changed files with 27 additions and 1 deletions
|
@ -62,7 +62,8 @@ module Compliance
|
||||||
config['token'] = Compliance::API.get_token(config)
|
config['token'] = Compliance::API.get_token(config)
|
||||||
|
|
||||||
# Needed for automate2 post request
|
# Needed for automate2 post request
|
||||||
config['profile'] = Compliance::API.profile_split(profile)
|
profile_stub = profile || target[:compliance]
|
||||||
|
config['profile'] = Compliance::API.profile_split(profile_stub)
|
||||||
|
|
||||||
new(profile_fetch_url, config)
|
new(profile_fetch_url, config)
|
||||||
rescue URI::Error => _e
|
rescue URI::Error => _e
|
||||||
|
|
|
@ -50,4 +50,29 @@ describe Compliance::Fetcher do
|
||||||
proc { fetcher.send(:compliance_profile_name) }.must_raise RuntimeError
|
proc { fetcher.send(:compliance_profile_name) }.must_raise RuntimeError
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'when the server calls a automate profile' do
|
||||||
|
before do
|
||||||
|
Compliance::Configuration.expects(:new).returns({ 'token' => "123abc" })
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns the correct profile name when parsing url' do
|
||||||
|
Compliance::API.stubs(:exist?).returns(true)
|
||||||
|
fetcher = Compliance::Fetcher.resolve('compliance://admin/ssh-baseline')
|
||||||
|
assert = ["admin", "ssh-baseline", nil]
|
||||||
|
fetcher.instance_variable_get(:"@config")['profile'].must_equal assert
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns the correct profile name when parsing compliance hash' do
|
||||||
|
Compliance::API.stubs(:exist?).returns(true)
|
||||||
|
hash = {
|
||||||
|
target: "https://a2.instance.com/api/v0/compliance/tar",
|
||||||
|
compliance: "admin/ssh-baseline",
|
||||||
|
sha256: "132j1kjdasfasdoaefaewo12312",
|
||||||
|
}
|
||||||
|
fetcher = Compliance::Fetcher.resolve(hash)
|
||||||
|
assert = ["admin", "ssh-baseline", nil]
|
||||||
|
fetcher.instance_variable_get(:"@config")['profile'].must_equal assert
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue