mirror of
https://github.com/inspec/inspec
synced 2024-11-24 21:53:15 +00:00
Test cases and documentation added
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
This commit is contained in:
parent
e663d29e5c
commit
8f06362cab
6 changed files with 98 additions and 5 deletions
|
@ -208,6 +208,7 @@ Chef Supermarket:
|
|||
|
||||
``` ruby
|
||||
inspec exec supermarket://username/linux-baseline
|
||||
inspec exec supermarket://username/linux-baseline --supermarket_url="https://myprivatesupermarket.mydomain.com"
|
||||
```
|
||||
|
||||
Local profile (executes all tests in `controls/`):
|
||||
|
@ -566,6 +567,14 @@ This subcommand has the following syntax:
|
|||
inspec supermarket SUBCOMMAND ...
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
This subcommand has additional options:
|
||||
|
||||
* ``--supermarket_url``
|
||||
Specify private supermarket url to run supermarket commands on private supermarket.
|
||||
|
||||
|
||||
## vendor
|
||||
|
||||
Download all dependencies and generate a lockfile in a `vendor` directory.
|
||||
|
|
|
@ -8,8 +8,27 @@ To use the CLI, this InSpec add-on adds the following commands:
|
|||
|
||||
Compliance profiles from Supermarket can be executed in two ways:
|
||||
|
||||
- via supermarket exec: `inspec supermarket exec nathenharvey/tmp-compliance-profile`
|
||||
- via supermarket scheme: `inspec exec supermarket://nathenharvey/tmp-compliance-profile`
|
||||
- via supermarket exec:
|
||||
|
||||
**Public Supermarket**
|
||||
|
||||
`inspec supermarket exec nathenharvey/tmp-compliance-profile`
|
||||
|
||||
**Private Supermarket**
|
||||
|
||||
`inspec supermarket exec nathenharvey/tmp-compliance-profile --supermarket_url="PRIVATE_SUPERMARKET_URL"`
|
||||
|
||||
|
||||
- via supermarket scheme:
|
||||
|
||||
**Public Supermarket**
|
||||
|
||||
`inspec exec supermarket://nathenharvey/tmp-compliance-profile`
|
||||
|
||||
**Private Supermarket**
|
||||
|
||||
`inspec exec supermarket://nathenharvey/tmp-compliance-profile --supermarket_url="PRIVATE_SUPERMARKET_URL"`
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ module Inspec
|
|||
|
||||
def self.supermarket_options
|
||||
option :supermarket_url, type: :string,
|
||||
desc: "Specify supermarket url to run supermarket commands"
|
||||
desc: "Specify private supermarket url to run supermarket commands on private supermarket"
|
||||
end
|
||||
|
||||
def self.exec_options
|
||||
|
|
|
@ -11,7 +11,7 @@ class PluginRegistry
|
|||
# @return [Plugin] plugin instance if it can be resolved, nil otherwise
|
||||
def resolve(target, opts = {})
|
||||
modules.each do |m|
|
||||
res = if [Inspec::Fetcher::Url, Supermarket::Fetcher].include? m
|
||||
res = if ["Inspec::Fetcher::Url", "Supermarket::Fetcher"].include? m.to_s
|
||||
m.resolve(target, opts)
|
||||
else
|
||||
m.resolve(target)
|
||||
|
|
|
@ -642,6 +642,26 @@ Test Summary: 2 successful, 0 failures, 0 skipped\n"
|
|||
end
|
||||
end
|
||||
|
||||
it "can run supermarket profiles directly from the command line with --supermarket_url option" do
|
||||
|
||||
skip_windows! # Breakage confirmed, only on CI: https://buildkite.com/chef-oss/inspec-inspec-master-verify/builds/2355#2c9d032e-4a24-4e7c-aef2-1c9e2317d9e2
|
||||
inspec("exec supermarket://nathenharvey/tmp-compliance-profile --supermarket_url='https://supermarket.chef.io' --no-create-lockfile")
|
||||
|
||||
if is_windows?
|
||||
_(stdout).must_include "Profile Summary: 1 successful control, 1 control failure, 0 controls skipped\n"
|
||||
else
|
||||
_(stdout).must_include "Profile Summary: 2 successful controls, 0 control failures, 0 controls skipped\n"
|
||||
end
|
||||
|
||||
_(stderr).must_equal ""
|
||||
|
||||
if is_windows?
|
||||
assert_exit_code 100, out # references root
|
||||
else
|
||||
assert_exit_code 0, out
|
||||
end
|
||||
end
|
||||
|
||||
it "can run supermarket profiles from inspec.yml" do
|
||||
skip_windows! # Breakage confirmed, only on CI: https://buildkite.com/chef-oss/inspec-inspec-master-verify/builds/2355#2c9d032e-4a24-4e7c-aef2-1c9e2317d9e2
|
||||
|
||||
|
|
|
@ -39,4 +39,49 @@ describe "inspec supermarket" do
|
|||
|
||||
assert_exit_code 100, out
|
||||
end
|
||||
end
|
||||
|
||||
it "supermarket profiles" do
|
||||
out = inspec("supermarket profiles --supermarket_url='https://supermarket.chef.io'")
|
||||
|
||||
_(out.stdout).must_include "dev-sec/linux-patch-baseline"
|
||||
_(out.stdout).must_include "dev-sec/windows-baseline"
|
||||
_(out.stderr).must_equal ""
|
||||
|
||||
assert_exit_code 0, out
|
||||
end
|
||||
|
||||
it "info with --supermarket_url option" do
|
||||
out = inspec("supermarket info dev-sec/ssh-baseline --supermarket_url='https://supermarket.chef.io'")
|
||||
|
||||
_(out.stdout).must_include "name: \e[0m ssh-baseline"
|
||||
_(out.stderr).must_equal ""
|
||||
|
||||
assert_exit_code 0, out
|
||||
end
|
||||
|
||||
it "supermarket exec with --supermarket_url option" do
|
||||
if is_windows?
|
||||
out = inspec("supermarket exec dev-sec/windows-patch-baseline --supermarket_url='https://supermarket.chef.io'")
|
||||
else
|
||||
out = inspec("supermarket exec dev-sec/ssh-baseline --supermarket_url='https://supermarket.chef.io'")
|
||||
end
|
||||
|
||||
_(out.stdout).must_include "Profile Summary"
|
||||
_(out.stdout).must_include "Test Summary"
|
||||
_(out.stderr).must_equal ""
|
||||
|
||||
skip_windows! # Breakage confirmed, only on CI: https://buildkite.com/chef-oss/inspec-inspec-master-verify/builds/2355#2c9d032e-4a24-4e7c-aef2-1c9e2317d9e2
|
||||
|
||||
assert_exit_code 100, out
|
||||
end
|
||||
|
||||
it "supermarket profiles with --supermarket_url option" do
|
||||
out = inspec("supermarket profiles --supermarket_url='https://supermarket.chef.io'")
|
||||
|
||||
_(out.stdout).must_include "dev-sec/linux-patch-baseline"
|
||||
_(out.stdout).must_include "dev-sec/windows-baseline"
|
||||
_(out.stderr).must_equal ""
|
||||
|
||||
assert_exit_code 0, out
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue