Module: InspecPlugins::Compliance::API::Login

Includes:
Inspec::Dist
Included in:
InspecPlugins::Compliance::API
Defined in:
lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb

Defined Under Namespace

Modules: Automate2Server Classes: CannotDetermineServerType

Constant Summary

Constants included from Inspec::Dist

Inspec::Dist::AUTOMATE_PRODUCT_NAME, Inspec::Dist::COMPLIANCE_PRODUCT_NAME, Inspec::Dist::EXEC_NAME, Inspec::Dist::PRODUCT_NAME, Inspec::Dist::SERVER_PRODUCT_NAME

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.authenticate_login(options) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb', line 62

def self.(options)
  InspecPlugins::Compliance::API.(
    options["url"],
    options["token"],
    options["insecure"]
  )
end

.configuration_stored_message(config) ⇒ Object



70
71
72
# File 'lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb', line 70

def self.configuration_stored_message(config)
  "Stored configuration for Chef #{config["server_type"].capitalize}: #{config["server"]}' with user: '#{config["user"]}'"
end

Instance Method Details

#login(options) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
# File 'lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb', line 11

def (options)
  raise ArgumentError, "Please specify a server using `#{EXEC_NAME} automate login https://SERVER` or `#{EXEC_NAME} compliance login https://SERVER`" unless options["server"]

  options["server_type"] = "automate2"
  options["server"] = URI("https://#{options["server"]}").to_s if URI(options["server"]).scheme.nil?

  Login::Automate2Server.(options)
end