Skip to content

Commit

Permalink
Updating inspec with bastion options as per inspec/train#310
Browse files Browse the repository at this point in the history
Signed-off-by: Noel Georgi <18496730+frezbo@users.noreply.github.com>
  • Loading branch information
frezbo committed Jun 28, 2018
1 parent f09d115 commit 4590d41
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ habitat/results
/.direnv
/.envrc
results/
TAGS

www/source/index.html.slim
www/Gemfile.lock
Expand Down
7 changes: 7 additions & 0 deletions lib/inspec/base_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def self.exit_on_failure?
true
end

# rubocop:disable MethodLength
def self.target_options
option :target, aliases: :t, type: :string,
desc: 'Simple targeting option using URIs, e.g. ssh://user:pass@host:port'
Expand Down Expand Up @@ -54,6 +55,12 @@ def self.target_options
desc: 'Read configuration from JSON file (`-` reads from stdin).'
option :proxy_command, type: :string,
desc: 'Specifies the command to use to connect to the server'
option :bastion_host, type: :string,
desc: 'Specifies the bastion host if applicable'
option :bastion_user, type: :string,
desc: 'Specifies the bastion user if applicable'
option :bastion_port, type: :string,
desc: 'Specifies the bastion port if applicable'
end

def self.profile_options
Expand Down
8 changes: 8 additions & 0 deletions test/functional/inspec_exec_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@
end
end

describe 'when --bastion-host and --proxy_command is used' do
it 'raises an exception when both flags are provided' do
out = inspec('exec ' + example_profile + ' -t ssh://dummy@dummy --proxy_command dummy --bastion_host dummy')
out.exit_status.must_equal 1
out.stderr.must_include "Client error, can't connect to 'ssh' backend: Only one of proxy_command or bastion_host needs to be specified"
end
end

describe 'with sensitive resources' do
it 'hides sensitive output' do
out = inspec('exec ' + sensitive_profile + ' --no-create-lockfile')
Expand Down

0 comments on commit 4590d41

Please sign in to comment.