Check added for automate server 2 for server presence

Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
This commit is contained in:
Nikita Mathur 2021-05-25 17:47:46 +05:30
parent dcb99872ff
commit 6ce9c04232
2 changed files with 18 additions and 1 deletions

View file

@ -24,7 +24,11 @@ module InspecPlugins
# the username of the account is used that is logged in
def self.profiles(config, profile_filter = nil) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
owner = config["owner"] || config["user"]
url = "#{config["server"]}/compliance/profiles/search"
if is_automate2_server?(config)
url = "#{config["server"]}/compliance/profiles/search"
else
raise ServerConfigurationMissing
end
headers = get_headers(config)
if profile_filter
@ -210,6 +214,10 @@ module InspecPlugins
config["version"]["version"]
end
def self.is_automate2_server?(config)
config["server_type"] == "automate2"
end
end
end
end

View file

@ -208,4 +208,13 @@ describe InspecPlugins::Compliance::API do
_(InspecPlugins::Compliance::API.exist?(config, "admin/missing-in-action")).must_equal false
end
end
describe "when the config has a automate2 server_type" do
it "automate server 2 is? methods return correctly" do
config = InspecPlugins::Compliance::Configuration.new
config.clean
config["server_type"] = "automate2"
_(InspecPlugins::Compliance::API.is_automate2_server?(config)).must_equal true
end
end
end