Commit graph

569 commits

Author SHA1 Message Date
Clinton Wolfe
a839d4602c Add ability to sort results in reporting phase
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-08-10 14:32:08 -04:00
Clinton Wolfe
3aca12d622 Add option to suppress diff output
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-08-10 14:31:28 -04:00
Clinton Wolfe
ceca77e118 Mark inputs as sensitive
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-08-10 14:30:11 -04:00
Nick Schwaderer
d8b06560a1 Ensure truncate message only returns on truncated values
At the moment we return the "Truncate" text whenever the setting is
utilized. This PR ensures that we only advise truncation when it's been
executed.

Signed-off-by: Nick Schwaderer <nschwaderer@chef.io>
2020-07-29 09:50:25 +01:00
Nick Schwaderer
2744ff43e5
Merge pull request #5128 from james-stocks/js/report_bad_profiles
Report faulty profiles instead of crashing
2020-07-15 13:28:17 +01:00
James Stocks
833aac3ef1 Add profile load failure message to CLI reporter
Signed-off-by: James Stocks <jstocks@chef.io>
2020-07-09 14:02:42 +01:00
Nick Schwaderer
6d340b323c Allow ‘=‘ character in CLI inputs
Fixes #5131

Due to the use of `#split(‘=‘)` against inputs supplied via the CLI we had an edge case where inputs with `’=‘` in the value would cause a breakage.

This PR supplies a test for the regression and fixes the bug with a regex solution.

Signed-off-by: Nick Schwaderer <nschwaderer@chef.io>
2020-07-09 12:50:21 +01:00
James Stocks
08398cc3c1 Address linting mistakes.
Signed-off-by: James Stocks <jstocks@chef.io>
2020-07-03 15:53:09 +01:00
James Stocks
fd4c501c70 Change profile skip_message to status_message
Keep a duplicate of the message in skip_message for the JSON reporters, for backwards compaibility.

Signed-off-by: James Stocks <jstocks@chef.io>
2020-07-03 15:53:09 +01:00
James Stocks
41087c5ec6 Set profiles that fail to load as failed
Signed-off-by: James Stocks <jstocks@chef.io>
2020-07-02 13:33:07 +01:00
Nick Schwaderer
480567564b Review skip_windows violations and expiration
We have 72 `skip_windows` that need addressing. This PR removes
confirmed instances where the tests now work on windows. It also marks
tests with a comment where they are confirmed to still break. Unmarked
instances still need review.

It also updates the `skip_windows` expiration date.

72 `skip_windows` needing resolution OR alternative documentation upon investigation

Signed-off-by: Nick Schwaderer <nschwaderer@chef.io>
2020-07-02 11:53:38 +01:00
Nick Schwaderer
dca57b61c0
Merge pull request #4907 from inspec/cw/telemetry-run-context
Telemetry - determine run context from stack introspection
2020-06-17 18:17:09 +01:00
Clinton Wolfe
09bbc7e2e7 Remove a ruby expression-based test
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-06-05 17:40:49 -04:00
Clinton Wolfe
925363766e Document and test to verify that it skips resources in describe blocks
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-06-05 17:40:49 -04:00
Clinton Wolfe
f39cf8c904 Tests to exercise only_if functionality
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-06-05 17:39:54 -04:00
James Stocks
d5f825e716
Merge pull request #5026 from inspec/cw/silence-deprecations
CLI Option to silence deprecations
2020-06-05 14:10:50 +01:00
Nick Schwaderer
fb1aeb0655
Merge pull request #5011 from inspec/cw/complex-cli-inputs
Boolean, Numeric, and Structured CLI inputs
2020-06-05 04:23:48 -07:00
Clinton Wolfe
88da919558 Fix exit code check for windows
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-05-25 23:27:00 -04:00
Clinton Wolfe
439c93b115 Add a functional test to check Thor run context detection
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-05-25 21:00:24 -04:00
Clinton Wolfe
dcc70bc541 Trim log message, make boolean check case insensitive
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-05-23 00:25:08 -04:00
James Stocks
32fa14f1b0
Merge pull request #5039 from james-stocks/js/issue_5037
Allow for waiver time as well as date
2020-05-22 16:52:23 +01:00
James Stocks
23ed9bcf06
Merge pull request #5007 from inspec/cw/reporters-as-plugins
Reporters as Plugins
2020-05-22 16:10:29 +01:00
James Stocks
350c0bfe8f Handle waiver expiration dates being YAML strings
This is technically incorrect YAML, but if you transcode YAML between several tools you may end up with a date/time value being an explicit string.
It would be helpful if InSpec supported any string value that easily translates to a Time.

Signed-off-by: James Stocks <jstocks@chef.io>
2020-05-20 15:00:43 +01:00
James Stocks
35e36ad40a Allow for waiver time as well as date
Fixes #5037

The YAML parser may parse a waiver timestamp as a Time rather than a Date. Even when the user doesn't care about time, they may be using a tool that outputs YAML with trailing zeroes for hour, minutes, seconds etc.

Signed-off-by: James Stocks <jstocks@chef.io>
2020-05-20 14:59:07 +01:00
Nick Schwaderer
989d86c2ce Stores output of inspec json to archive and artifact
Signed-off-by: Nick Schwaderer <nschwaderer@chef.io>
2020-05-20 12:34:17 +01:00
Clinton Wolfe
6a59618d2b Add a failing test case for silencing deprecations
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-05-13 22:45:58 -04:00
Clinton Wolfe
ee095a244a Soften the exception to a warning when the input is not parseable
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-05-07 10:47:57 -04:00
James Stocks
ba99226baf Remove TODO Windows skip
I removed the skip to see what would break, and on my Windows laptop
these tests pass OK. The TODO didn't explain what wasn't applicable to
Windows, so I'm just going to remove it.

Signed-off-by: James Stocks <jstocks@chef.io>
2020-05-07 14:01:32 +01:00
James Stocks
1510ff1078 Remove Windows skip from test/functional/inspec_exec_jsonmin_test.rb
Signed-off-by: James Stocks <jstocks@chef.io>
2020-05-07 13:16:22 +01:00
James Stocks
2103b52dbe
Merge pull request #4994 from james-stocks/js/json
Reporter options to truncate message and suppress stacktrace
2020-05-07 12:54:34 +01:00
Clinton Wolfe
12f3f313cb Don't try to test JSON input under powershell
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-05-06 16:33:50 -04:00
Clinton Wolfe
786e3728d7 Failing tests for #4799
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-05-05 18:09:11 -04:00
Clinton Wolfe
970f583764 Tighten up tests
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-05-05 17:59:50 -04:00
Clinton Wolfe
c683c4d64d Failing test cases for 4963
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-05-05 17:37:23 -04:00
Clinton Wolfe
824018efa3 Failing test cases for #4977
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-05-05 17:37:23 -04:00
Clinton Wolfe
5a7a48bb62 Basics of a working reporter plugin system
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-05-05 16:51:31 +01:00
Nick Schwaderer
a1129f9efc Allows input and control to have the same name
In https://github.com/inspec/inspec/issues/4936 the issue was reported that naming an input the same as a control caused an unexpected failure.

In that particular case, the naming was a result of a pre-waivers workaround which is no longer necessary, but ultimately a breakage of that name clash is an unexpected occurrance.

Due to how inputs are named and registered, `__apply_waivers` thinks that an object is a waiver that is not a waiver and tries to process it. On the micro level, it breaks when trying to pass a variable to a string as if it were a Hash.

It is imperative that we preserve 100% of the current featureset, pass our tests, and fix this edge case along with new test coverage for the failure.

This PR updates the code to do a slightly more elegant and small ‘waiver check’ to stop the namespace clash from breaking our code.

Signed-off-by: Nick Schwaderer <nschwaderer@chef.io>
2020-05-05 10:00:19 +01:00
James Stocks
69fb6e0782 Move reporter option handling to base
They don't need to be json specific, they should apply to any reporter if the user has chosen these settings.

Signed-off-by: James Stocks <jstocks@chef.io>
2020-05-04 15:24:50 +01:00
James Stocks
ae66aee2b2 (WIP) Reporter options to truncate message and suppress stacktrace
TODO: Option names are not JSON specific but only json reporter has been implemented.

Signed-off-by: James Stocks <jstocks@chef.io>
2020-05-04 15:24:50 +01:00
Clinton Wolfe
58e8bc5167 Divide tests into undeclared and required groups
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-04-24 16:38:11 -04:00
Clinton Wolfe
a12dfcfdc0 Add a failing test case for 4769
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-04-24 13:57:28 -04:00
Clinton Wolfe
a38100a185 Update GCP and azure tests to reflect no-creds errors as seen on CI server
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-03-02 14:32:12 -05:00
Clinton Wolfe
2d9c443a04 Add functional tests that try each of the cloud resource packs with bad creds
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-02-26 14:41:38 -05:00
Miah Johnson
7bb0bb2188
Merge pull request #4865 from inspec/jh/schema-improvements
Jh/schema improvements
2020-02-10 18:38:28 -08:00
Miah Johnson
4f642e0942 Clean up schema PR.
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2020-02-05 17:06:55 -08:00
Jacob Henry
724f82237b Revision of schema to JSON Schema draft 7
Signed-off-by: Jacob Henry <jchenry@mitre.org>
2020-02-05 17:05:47 -08:00
Ryan Davis
99f86c8a0b These tests don't pass on a network cafe and just hang forever.
Changing to localhost resolves immediately but assumes you're NOT
running a git server on http locally.

This seems more valid to me than assuming you know how DNS is going to
resolve everywhere.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2020-02-03 13:18:56 -08:00
Ryan Davis
a3060c4ca8
Merge pull request #4860 from inspec/cw/win-func-input-tests
Remove skips from windows testing in 'inputs' and 'archive' functional tests
2020-01-31 17:51:36 -08:00
Ryan Davis
c70f73dc96
Merge pull request #4864 from inspec/zenspider/resource/inspect
Added --inspect option to inspect shell command.
2020-01-31 16:42:00 -08:00
Ryan Davis
8bd2528ef8 Added --inspect option to inspect shell command.
* Removed Resource#inspect (calling to_s) to make debugging a happy experience.
* Added ResourceBehavior.toggle_inspect to add/remove a basic inspect.
* Added `--inspect` flag to `shell` command. Call toggle_inspect unless --inspect used.
* Cleaned up matchers.rb and removed most explicit calls to inspect.
* Added ResourceInspector to rspec's INSPECTOR_CLASSES.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2020-01-28 14:52:04 -08:00
Clinton Wolfe
3d5226fb68 Q-quote the args to the train plugin
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-01-28 13:48:10 -05:00
Clinton Wolfe
28f8d6cc5f Removing skip in archive test just seems to work, too
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-01-28 12:24:29 -05:00
Clinton Wolfe
6290ee0190 Just remove skips, it seems to work
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-01-28 11:57:25 -05:00
Clinton Wolfe
ef9ef919fc Linting
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-01-03 14:15:05 -05:00
Clinton Wolfe
3e3398ff29 Switch to using tmpdir option during testing to avoid rm calls
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-01-03 14:15:05 -05:00
Clinton Wolfe
ba4fa9832c parallelize fetcher tests, conditionalize automate fetcher
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-01-03 14:15:05 -05:00
Clinton Wolfe
913c066be9 Test fixture and functional test for compliance fetcher
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-01-03 14:15:05 -05:00
Clinton Wolfe
82ae3b5fa1 Test fixtures and functional test for local fetcher
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-01-03 14:15:05 -05:00
Clinton Wolfe
ed209643f3 Test fixture for url fetcher
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-01-03 14:15:05 -05:00
Clinton Wolfe
928cf6f05e Functional test and fixtures for git fetcher fallback
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-01-03 14:15:04 -05:00
Ryan Davis
04581d2270
Merge pull request #4771 from inspec/zenspider/rspec-3.9
Bump rspec to 3.9 and fix broken tests.
2019-12-09 12:09:32 -08:00
Ryan Davis
f67171fa6b Bump rspec to 3.9 and fix broken tests.
Tests are STILL brittle, but this at least lets us drop old rspec.

Fixes #4575

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-12-06 16:52:35 -08:00
Clinton Wolfe
b34d489f5c Add .invalid TLD to test hostanmes
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-12-04 13:32:58 -05:00
Clinton Wolfe
6b0877591f Refactor functional test to DRY up
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-12-04 13:32:19 -05:00
Clinton Wolfe
8679443698 Functional test for git fetcher failure handling
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-12-04 13:32:19 -05:00
Clinton Wolfe
c1d1e6d12f functional test for URL fetcher
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-12-04 13:32:19 -05:00
Clinton Wolfe
0ddf1687f5 A functional test for the local fetcher
I hate to do this, but unit testing this reveals odd behavior
in the fetcher - fetching in a unit harness appears to always succeed.
I'd like to make this into a unit test, but for now I want to focus on
the fetchers.

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-12-04 13:30:08 -05:00
Ryan Davis
865e0d43c0 Fixed a race condition in the tests on windows.
Second test would always fail, resumably because the GC kicks in and
the tempfile gets obliterated before the subprocess can read it.

Don't do tempfiles via let. Do them via ivars so they can persist.
2019-11-12 14:51:56 -08:00
Ryan Davis
efc51c44d9 Fixes to get inspec_exec_test.rb green on Windows. 2019-11-12 14:51:56 -08:00
Ryan Davis
f8ea33de8f Added test command caching and refactored inspec helper to run_cmd.
Helps with some of the tests that want to run ruby directly.

Fixes #4416.
2019-11-12 14:51:56 -08:00
Ryan Davis
bb7e69d145 Fixes for some of the inspec exec tests under Windows. 2019-11-12 14:51:56 -08:00
Ryan Davis
4242937bea Changed a bunch of profiles to use / instead of /tmp for Windows compat. 2019-11-12 14:51:56 -08:00
Ryan Davis
d1f67c02d0 Get the license_tests passing
...mostly by skipping

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-11-12 14:51:56 -08:00
Ryan Davis
e60dc84188 Cleaned up inspec artifact testing.
Removed redundant test/functional/inspec_artifact_test.rb
Cleaned up lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb
Made an error on windows (install-profile fails) raise instead of just print.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-11-12 14:50:39 -08:00
Ryan Davis
c3fe1697bb Fix the way we determine (and clean) the repo_path in functionals.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-11-12 14:50:39 -08:00
Ryan Davis
ee327094fb Strip all ANSI color codes from output in inspec_shell_test.rb
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-11-12 14:50:39 -08:00
Ryan Davis
b3b8336620 Get inspec_exec_test.rb passing on windows w/o skips.
+ Clean up lockfiles in profiles. (we shouldn't be creating these!)
+ Fix some exit code assertions based on platform.
+ Had to skip 2 tests (with timebombs) because this is rebased off of my performance branch which has 2 failures.

signed-off-by: Ryan Davis <zenspider@chef.io>
2019-11-12 14:50:39 -08:00
Ryan Davis
bfc8b357bf Clean up testing in inspec exec by stripping ansi color codes from output.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-11-12 14:50:39 -08:00
Ryan Davis
b1c2af209b Corresponding fixes for the move from test/unit/mock to test/fixtures.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-11-08 19:20:12 -08:00
Ryan Davis
244c7bbed4
Merge pull request #4677 from inspec/zenspider/bump-chefstyle
Bump chefstyle and fix up flagged code.
2019-11-08 16:07:42 -08:00
Ryan Davis
bb49d58cd9 Switched chefstyle back to Layout/AlignArguments=with_first_argument.
Fixed the flags mostly with `chefstyle -a` but also refactored/cleaned
some stuff by hand.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-11-08 12:57:43 -08:00
Clinton Wolfe
c045de4399 Temporarily add functional test for input in describe.one in isolated commit
As there is a team desire to move away from functional tests,
this commit is intended to be easily reverted once a facility for
running test fixture policies as unit tests in a clear way.

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-11-01 16:52:21 -04:00
Ryan Davis
d201d1fbc2 Fixed the rest of the minitest deprecations by removing FuncTestRunResult.
Folded the json & other payloads into plain ivars on the test.
Found and removed some unused code while I was there.

Fixes #4533.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-10-22 12:15:28 -07:00
Ryan Davis
8d4e8c1d96
Merge pull request #4627 from inspec/zenspider/json-and-resource-cleanup
JSON processing and resource cleanup
2019-10-21 14:26:37 -07:00
Ryan Davis
e5e1a745cc Fixed run_inspec_with_plugin to merge run options properly.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-10-21 13:30:14 -07:00
Ryan Davis
b626c37386 Improve debugging of json parse failures in functional tests.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-10-21 13:30:14 -07:00
Ryan Davis
fdaea02427 Clean up testing in inspec exec by stripping ansi color codes from output.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-10-21 12:46:37 -07:00
Miah Johnson
23f31a0a72 Use a good profile with inspec check test
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-10-17 14:55:58 -07:00
Miah Johnson
6f460b9c3b Remove this. It slows things down.
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-10-16 20:57:31 -07:00
Miah Johnson
4ec9f302b0 example -> example.tmp
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-10-16 10:15:49 -07:00
Miah Johnson
c3eb686b51 Remove debug
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-10-16 10:15:49 -07:00
Miah Johnson
301905e8de b0rk b0rk
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-10-16 10:15:49 -07:00
Miah Johnson
41bc8fd7a0 Clean up some tests
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-10-16 10:15:49 -07:00
Miah Johnson
ae3ee6f657 Finish rename of example -> example-tmp.rb
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-10-16 10:13:24 -07:00
Miah Johnson
df7efefc9d mostly a search and replace for gordon -> example
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-10-16 10:13:24 -07:00
Clinton Wolfe
8f4ff8923e Add functional test to exercise waivers during profile inheritance
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-10-09 19:10:48 -07:00
Clinton Wolfe
3c266655ee Refactor exec-json functional tests to reduce subprocesses
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-10-08 21:04:58 -07:00
Clinton Wolfe
ba61cd3f45 Update JSON schema to reflect new waiver keys
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-10-08 21:01:19 -07:00
Clinton Wolfe
0f5fde9729 Modify waiver input file to use 'run' subfield instead of 'skip'
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-10-08 01:03:40 -07:00
Clinton Wolfe
7516f959d1 If there is no data, alwaya return an empty hash.
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-10-08 00:31:23 -07:00
Clinton Wolfe
56c2416c57 Move waiver JSON data from per-result to per-control
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-10-08 00:25:06 -07:00
Ryan Davis
07dc5e3192 First pass at cleaning deprecations for old minitest/spec-style tests.
3 files left to go, and they're behaving oddly so I'm leaving them out
in this pass. Looks like 21 deprecations left.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-10-03 13:45:19 -07:00
Ryan Davis
90c4904a55
Merge pull request #4490 from inspec/zenspider/split-long-functional
Split and parallelize some tests to make them faster
2019-09-24 17:45:57 -07:00
Ryan Davis
fc1ad67ffc More parallelization for functionals.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-17 11:50:31 -07:00
Ryan Davis
d3f81f1194 Turn on parallelism for inspec_shell_test.rb
Seems safe after several runs.

Takes the time down from ~180s to 22s.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-16 17:19:32 -07:00
Ryan Davis
ba462724db Turn on parallelism for inspec_exec_test.rb
Seems safe after several runs.

Takes the time down from ~275s to 35s.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-16 17:19:32 -07:00
Ryan Davis
1d3c9341ec Finished up the phase 3 waiver json output tests.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-16 16:39:34 -07:00
Miah Johnson
5d94b0d709 Add waiver_data to json output, update assertion to show where waiver_data lives.
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-09-16 14:49:05 -07:00
Miah Johnson
168c77e472 Refactor tests.
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-09-16 14:49:05 -07:00
Clinton Wolfe
5d94440823 Fix logic error for future expiring waivers
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-09-09 11:29:26 -04:00
Clinton Wolfe
43bc7e0343 Modify @__skip_rule to distinguish only_if and waiver, and force waiver to win
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-09-09 11:29:26 -04:00
Clinton Wolfe
0db0a2bfdc Don't assume waiver_ prefix in waiver files
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-09-09 11:29:26 -04:00
Clinton Wolfe
718e205cf2 Alter expiration_date behavior to match spec
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-09-09 11:29:26 -04:00
Clinton Wolfe
ff209b4bae Refactor control_id lookup in waiver test file
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-09-09 11:29:26 -04:00
Clinton Wolfe
eb1ec437d7 Linting and test number corrections
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-09-09 11:29:26 -04:00
Clinton Wolfe
5891c9aee9 A failing functional test to skip waivered controls
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-09-09 11:29:26 -04:00
kekaichinose
d33870b635
Merge pull request #4214 from inspec/zenspider/fix_nil_file
Fixed file resource raising UndefinedMethod on source_path
2019-08-30 13:19:54 -07:00
Clinton Wolfe
e346b16114 Tighten help listing assertion and adjust chomp
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-28 13:03:42 -04:00
Clinton Wolfe
296158c447 Implementation and functional tests for the --input CLI option
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-28 13:03:42 -04:00
Clinton Wolfe
512189a06b Add CLI option and check in help
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-28 12:53:27 -04:00
Clinton Wolfe
f90a4c633d
Merge pull request #4419 from inspec/cw/check-enforce-version
inspec check: warn if inspec_version is not supported by current inspec
2019-08-27 20:03:19 -04:00
Clinton Wolfe
c6f33b3526 Add functional test for inspec check with runtime constraint
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-26 23:19:18 -04:00
Clinton Wolfe
f59497d982 Don't open a new train connect, and make an issue for improving helper support
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-26 13:12:30 -04:00
Clinton Wolfe
d462ac3de5 Convert runner api script layout ot heredoc
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-22 21:51:50 -04:00
Ryan Davis
1dd1efa03f test change for bad resource/backend combo.
I think this is probably in contention with my other PR on resource
initialization. We definitely need to change that, so this might fall
to the side. Or maybe just the test needs to be redone. We'll discuss
and see.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-08-20 13:25:21 -07:00
Ryan Davis
7273a7380f Fixed file resource raising UndefinedMethod on source_path
This is a first pass at fixing the failure found by @scottvidmar where
file resource was raising undefined_method on nil. The problem was
that the initialize method for file was not being called at all
because Resource#initialize was returning early without reporting
anything.

This fix causes a failure in test/functional/inspec_exec_test.rb where
it is testing a similar scenario but for some reason the unsupported
resources get reported. We need to figure that part out, but in the
meantime this will at least report an error at the root cause rather
than down the road.

Fixes #4208

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-08-20 13:25:21 -07:00
Clinton Wolfe
1f49ae4046 Skip runner API tests on windows
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-19 18:15:50 -04:00
Clinton Wolfe
cc4aa16212 Add test framework to run Runner API input tests
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-19 13:51:51 -04:00
Ryan Davis
d295455df6 Fix license functional tests when run on buildkite.
BK currently runs our tests on ruby:X.Y-stretch docker images, which
use root. This puts license files it /etc/chef instead of the current
user's home and broke our tests.

This adds cleanup to /etc/chef AND checks both locations, so it should
continue to work even if we switch to docker images with non-root users.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-08-06 15:50:01 -07:00
Ryan Davis
55f2747ee1 Remove timebombs from 2 functional license tests.
These were put in place because they pass locally and fail on
buildkite. We didn't care at the time, but now we should investigate.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-08-06 15:02:37 -07:00
Ryan Davis
b570e0cc74 Bump skipped license tests until 8/16.
I've got this under debug in docker but this is a problem on the
license_acceptance gem on BK, not with inspec. And it is blocking a
release, so I'm bumping this out 2 weeks.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-31 16:44:49 -07:00
Clinton Wolfe
88898ce7a9 Linting
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:42:24 -04:00
Clinton Wolfe
f00e741999 PR feedback
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:38:02 -04:00
Clinton Wolfe
c03862fe7b Code climate updates
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:38:02 -04:00
Clinton Wolfe
4f6d296a22 The error case in which the path does not exist
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:38:02 -04:00
Clinton Wolfe
860d21a370 Test for ./
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:38:02 -04:00
Clinton Wolfe
31bedf7b37 Empty-string edge case
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:38:02 -04:00
Clinton Wolfe
fab58b590e Combo relative test in place
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:38:02 -04:00
Clinton Wolfe
e9ef8e25a3 Deep dependency works
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:38:02 -04:00
Clinton Wolfe
80241ec971 Passing basic test harness
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:38:02 -04:00
Clinton Wolfe
c257763de6 Linting
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:38:02 -04:00
Clinton Wolfe
aa81012013 Rework tests to be fixture-based, not generated per-run
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:38:02 -04:00
Clinton Wolfe
0e32d2429f Rename path_within_repo option to relative_path
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:36:20 -04:00
Clinton Wolfe
f1a892c857 Move existing git fixture profile to a directory for git-fetchers
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:36:20 -04:00
Clinton Wolfe
9c1fa967fd Rename profile_path to path_within_repo
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-30 13:36:20 -04:00
Jerry Aldrich
3e1d08cafe Add support for relative paths to the Git fetcher
This adds support for specifying a path to a profile in a Git repo.

For example, you could have a Git repo containing multiple profiles and
you want to specify a single one like below:

```yaml
depends:
  - name: profile-1
    git: https://github.com/myorg/all-my-profiles.git
    profile_path: profiles/my-specific-profile-1
  - name: profile-2
    git: https://github.com/myorg/all-my-profiles.git
    profile_path: profiles/my-specific-profile-2
```
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
2019-07-30 13:36:20 -04:00
Ryan Davis
3d6a4143a1 Removed lib/inspec/utils/latest_version.rb and associated code.
There is no reason why our tests should be failing because we deploy a
new version. That test shouldn't even be hitting the network for real.

Besides, the functionality has no place in our codebase. It's
functionality provided via `gem outdated` so why did we re-implement
it? And we expect most people to be running via omnibus, so they're
pinned to a specific version in the first place. Even if they updated,
they still couldn't run it and that would be more confusing.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-29 11:57:08 -07:00
Ryan Davis
bcf3aa841c Skip failures from BK run.
Not sure why these failures come up in a unified run (versus my
running all test files separately). Might be test infection. Might be
environmental.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-24 18:59:01 -07:00
Ryan Davis
917a531a92 Skipped all failing tests on windows AT the failures site.
This activates a BUNCH of tests but keeps us green.

Whether these tests are valid or not is not being addressed here.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-24 18:09:08 -07:00
Ryan Davis
bd16b766fa Renamed do_shell_c to assert_shell_c to make failures point to the right place.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-24 18:06:25 -07:00