mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
91403d8c81
* Merge `login` and `login_automate` commands This provides a single interface for logging into either Chef Automate or Chef Compliance servers. Server type is evaluated at run time via HTTP responses from designated endpoints. This also moves the login logic from `Compliance::ComplianceCLI` to a separate set of modules in `Compliance::API`. This removes logic from Thor and allows for more in depth Unit testing. Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Remove empty line below class definition Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Add message to `raise CannotDetermineServerType` Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Refactor `token_info` assignment Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Remove unnecessary rubocop disable Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Modify `Login` module namespacing Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Remove mentions of login_automate and --usertoken Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Modify `determine_server_type` to return a symbol Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Add support for `login_automate` and `--usertoken` Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Fix encoding typo Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Address PR feedback This does the following: - Moves `CannotDetermineServerType` error to `.login` - Changes methods that store configuration to return the configuration - Moves user output to one location in `.login` - Makes other small improvements Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
56 lines
1.6 KiB
Ruby
56 lines
1.6 KiB
Ruby
# encoding: utf-8
|
|
# author: Dominik Richter
|
|
# author: Christoph Hartmann
|
|
|
|
require 'functional/helper'
|
|
|
|
# basic testing without availability of any server
|
|
describe 'inspec compliance' do
|
|
include FunctionalHelper
|
|
|
|
it 'help' do
|
|
out = inspec('compliance help')
|
|
out.exit_status.must_equal 0
|
|
out.stdout.must_include 'inspec compliance exec PROFILE'
|
|
end
|
|
|
|
# ensure we are logged out
|
|
it 'logout' do
|
|
out = inspec('compliance logout')
|
|
out.exit_status.must_equal 0
|
|
out.stdout.must_include ''
|
|
end
|
|
|
|
it 'login server url missing' do
|
|
out = inspec('compliance login')
|
|
# TODO: We need to convince Thor that this is an error
|
|
# This will be fixed in the 1.0 release of Thor
|
|
# See: https://github.com/erikhuda/thor/issues/244
|
|
out.exit_status.must_equal 0
|
|
out.stderr.must_include 'ERROR: "inspec login" was called with no arguments'
|
|
end
|
|
|
|
it 'inspec compliance profiles without authentication' do
|
|
out = inspec('compliance profile')
|
|
out.stdout.must_include 'You need to login first with `inspec compliance login`'
|
|
out.exit_status.must_equal 0
|
|
end
|
|
|
|
it 'try to upload a profile without directory' do
|
|
out = inspec('compliance upload')
|
|
out.stderr.must_include 'ERROR: "inspec upload" was called with no arguments'
|
|
out.exit_status.must_equal 0
|
|
end
|
|
|
|
it 'try to upload a profile a non-existing path' do
|
|
out = inspec('compliance upload /path/to/dir')
|
|
out.stdout.must_include 'You need to login first with `inspec compliance login`'
|
|
out.exit_status.must_equal 0
|
|
end
|
|
|
|
it 'logout' do
|
|
out = inspec('compliance logout')
|
|
out.exit_status.must_equal 0
|
|
out.stdout.must_include ''
|
|
end
|
|
end
|