added apipath cli option to inspec compliance with default to /api

This commit is contained in:
Julian Tabel 2016-03-14 15:08:27 +01:00
parent f6578baf26
commit bd594f3608
2 changed files with 6 additions and 4 deletions

View file

@ -10,10 +10,10 @@ module Compliance
# everything will be stored in local Configuration store
class API # rubocop:disable Metrics/ClassLength
# logs into the server, retrieves a token and stores it locally
def self.login(server, username, password, insecure)
def self.login(server, username, password, insecure, apipath)
config = Compliance::Configuration.new
config['server'] = server
url = "#{server}/oauth/token"
config['server'] = "#{server}#{apipath}"
url = "#{config['server']}/oauth/token"
success, data = Compliance::API.post(url, username, password, insecure)
if !data.nil?

View file

@ -16,8 +16,10 @@ module Compliance
desc: 'Chef Compliance Password'
option :insecure, aliases: :k, type: :boolean,
desc: 'Explicitly allows InSpec to perform "insecure" SSL connections and transfers'
option :apipath, type: :string, default: '/api',
desc: 'Set the path to the API, defaults to /api'
def login(server)
success, msg = Compliance::API.login(server, options['user'], options['password'], options['insecure'])
success, msg = Compliance::API.login(server, options['user'], options['password'], options['insecure'], options['apipath'])
if success
puts 'Successfully authenticated'
else