mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
Merge pull request #5897 from inspec/cw/backport-auotmate-version-fix-inspec-4
backport automate version fix inspec 4
This commit is contained in:
commit
72e3de5f22
3 changed files with 7 additions and 6 deletions
|
@ -84,7 +84,7 @@ module InspecPlugins
|
||||||
return {} if data.nil? || data.empty?
|
return {} if data.nil? || data.empty?
|
||||||
|
|
||||||
parsed = JSON.parse(data)
|
parsed = JSON.parse(data)
|
||||||
return {} unless parsed.key?("version") && !parsed["version"].empty?
|
return {} unless parsed.key?("build_timestamp") && !parsed["build_timestamp"].empty?
|
||||||
|
|
||||||
parsed
|
parsed
|
||||||
end
|
end
|
||||||
|
|
|
@ -219,9 +219,10 @@ module InspecPlugins
|
||||||
def version
|
def version
|
||||||
config = InspecPlugins::Compliance::Configuration.new
|
config = InspecPlugins::Compliance::Configuration.new
|
||||||
info = InspecPlugins::Compliance::API.version(config)
|
info = InspecPlugins::Compliance::API.version(config)
|
||||||
if !info.nil? && info["version"]
|
if !info.nil? && info["build_timestamp"]
|
||||||
puts "Name: #{info["api"]}"
|
# key info["api"] is not longer available in latest version api response
|
||||||
puts "Version: #{info["version"]}"
|
puts "Name: automate"
|
||||||
|
puts "Version: #{info["build_timestamp"]}"
|
||||||
else
|
else
|
||||||
puts "Could not determine server version."
|
puts "Could not determine server version."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -110,9 +110,9 @@ describe InspecPlugins::Compliance::API do
|
||||||
it "should return an empty hash" do
|
it "should return an empty hash" do
|
||||||
response = mock
|
response = mock
|
||||||
response.stubs(:code).returns("200")
|
response.stubs(:code).returns("200")
|
||||||
response.stubs(:body).returns('{"api":"compliance","version":"1.2.3"}')
|
response.stubs(:body).returns('{"build_timestamp": "20220223121207"}')
|
||||||
InspecPlugins::Compliance::HTTP.expects(:get).with("myserver/version", "test-headers", true).returns(response)
|
InspecPlugins::Compliance::HTTP.expects(:get).with("myserver/version", "test-headers", true).returns(response)
|
||||||
_(InspecPlugins::Compliance::API.version(config)).must_equal({ "version" => "1.2.3", "api" => "compliance" })
|
_(InspecPlugins::Compliance::API.version(config)).must_equal({ "build_timestamp" => "20220223121207" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue