Commit graph

1180 commits

Author SHA1 Message Date
Clinton Wolfe
88ed1794cb Revert to a small amount of duplicating to_hash in inspec/input.rb
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-10-06 19:30:37 -04:00
Miah Johnson
e48d08343b
Merge pull request #4452 from mhackethal/user-windows-fix
User windows fix
2019-10-04 15:30:37 -07:00
Clinton Wolfe
11074bb7ce Adjust indentation
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-10-04 14:06:49 -04:00
Clinton Wolfe
36db8b9a7b Rely on copy of to_hash in objects/input.rb to avoid duplication
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-10-04 14:05:19 -04:00
Clinton Wolfe
51812a9e4e Replace to_hsh method, and add unit test for it
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-10-04 14:05:19 -04:00
Miah Johnson
416c33e056 Add name property to interface resource
Also some general cleanup.

Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-10-03 14:53:43 -07:00
Ryan Davis
6fd2db256d
Merge pull request #4560 from inspec/zenspider/apt
Fixed apt resource incorrectly parsing deb files w/ quoted URIs.
2019-10-03 14:50:48 -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
09392943f5 Fixed apt resource incorrectly parsing deb files w/ quoted URIs.
Fixes #4559.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-10-03 12:55:15 -07:00
Ryan Davis
708a319ce8 Fixed tests to work with rspec-expectations 3.8.5+.
We were using a "private" method in our tests and they changed the
signature.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-10-02 18:08:19 -07:00
Ryan Davis
866efdf141
Merge pull request #4531 from inspec/mj/wtf_rake
Remove maintainers task from require
2019-09-27 14:45:21 -07:00
Ryan Davis
984e02e312 Quick fix for faraday_middleware bug introduced when bumping to faraday 0.16.0.
Namespacing changed in faraday from Faraday::Error::* to Faraday::*
but was not reflected in faraday_middleware (which hasn't released
since February). I will file an issue and/or PR with them later.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-27 14:19:45 -07:00
Ryan Davis
ca4844210d Fixed Inspec::Plugin::V2::Registry#detect_system_plugins
+ Falls back to checking for inspec-core if inspec not found.
+ Fails gracefully if neither are found.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-25 16:10:00 -07:00
Mendy Baitelman
d44f9edc55 Merge remote-tracking branch 'upstream/master' into add-startuser-systemd-service
Signed-off-by: Mendy Baitelman <mendy@baitelman.com>
2019-09-24 22:30:51 -07:00
Mendy Baitelman
d45963cd91 Fix spacing
Signed-off-by: Mendy Baitelman <mendy@baitelman.com>
2019-09-24 21:58:55 -07:00
Mendy Baitelman
76cd799c92 Add to params for tests
Signed-off-by: Mendy Baitelman <mendy@baitelman.com>
2019-09-24 21:49:29 -07:00
Irving Popovetsky
bbb927e3dd Remove invalid test cases for tags
Signed-off-by: Irving Popovetsky <irving@chef.io>
2019-09-17 15:58:12 -07:00
Irving Popovetsky
4aebe87c2e Update unit tests to match
Signed-off-by: Irving Popovetsky <irving@chef.io>
2019-09-17 15:58:12 -07:00
Ryan Davis
a0a7917faa
Merge pull request #4485 from inspec/zenspider/objects-inputs
Split out Inspec::Input functional code from the code generation code.
2019-09-16 17:03:49 -07:00
Ryan Davis
e375ea30c8 Split out Inspec::Input functional code from the code generation code.
Includes moving errors into Inspec::Input and Inspec::InputRegistry.

Fixes #4456.
Fixes #4473.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-13 17:12:20 -07:00
mhackethal
c3270b537a update user_test.rb
Signed-off-by: mhackethal <mh@it31.de>
2019-09-13 21:19:20 +02:00
mhackethal
0b76859728 adjust user_test.rb 2019-09-13 20:45:54 +02:00
mhackethal
9e06f02e27
Update user_test.rb
adjust expectation of methods to be "nil" on windows
2019-09-13 13:14:34 +02:00
Miah Johnson
008ac9705b
Merge pull request #4484 from timgates42/feature/typo_becuase
Fix simple typo: becuase -> because
2019-09-12 17:25:37 -07:00
Tim Gates
f1e88ca65f
Fix simple typo: becuase -> because
Obvious Fix.
2019-09-13 09:30:00 +10:00
Clinton Wolfe
8132aaf85c
Merge pull request #3844 from inspec/ja/add-error-output-to-json-command
json resource: Add handling for `command:` error
2019-09-11 11:12:26 -04:00
Ryan Davis
a2b6517f9a skip a test when on windows
(and make it more compatible for when it does work)

Blocked by #4465.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-10 14:19:42 -07:00
Ryan Davis
fcfcc354fe Reworked test cases and impl to only respond to output, not exit code.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-10 14:19:42 -07:00
Ryan Davis
dfce5e722f
Merge pull request #4427 from inspec/cw/waivers-overlay
waivers: functional test fixture and eval-time skipping
2019-09-09 18:41:37 -07:00
Ryan Davis
f5bbfe5fac
Merge pull request #4365 from inspec/zenspider/the-need-for-speed
Make inspec much faster for most commands.
2019-09-09 18:02:10 -07:00
Jerry Aldrich
0e1b3fa65a json resource: Add handling for command: error
This provides the user with messages if `json(command: 'command_that_errors')`
exits non-zero and/or has STDERR.

Without this the resource will report "No output from command" when really the
output is contained in STDERR.

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
2019-09-09 15:16:34 -07:00
Ryan Davis
79b9c3cbad
Merge pull request #4451 from inspec/zenspider/fix-tarball-decoding
Try to decode archive contents to UTF-8 to avoid encoding corruption.
2019-09-09 11:13:48 -07: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
eb1ec437d7 Linting and test number corrections
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-09-09 11:29:26 -04:00
Clinton Wolfe
77b4e45175 Test fixture profile and input file for waivers
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-09-09 11:29:26 -04:00
mhackethal
6772f0b301
Update user_test.rb 2019-09-06 11:42:51 +02:00
Ryan Davis
d19d0bfd7c Refactor tests for TarProvider and ZipProvider a bit.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-06 00:42:36 -07:00
Ryan Davis
6e821e787e Save off supports[:os] and restore it after each test.
This fixes some other tests that require supports[:os] to be correct.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-04 15:44:26 -07:00
Ryan Davis
6296fdc688 Replace backticks in test descriptions with single-quotes.
Backticks means you can't selectively run one of these tests w/o
subshelling out to `brew`, or having to edit first.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-04 15:44:26 -07:00
Ryan Davis
3b69967cc8 Fixed a bug in checking supports (strings vs symbols)
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-09-04 15:44:26 -07:00
Ryan Davis
b6bfeffd9e Make inspec much faster for most commands.
Removes pre-loading and registration of resources by adding
method_missing to a couple key areas.

This still drops the ball in some areas, but it is a start.
2019-09-04 15:44:26 -07:00
Lance Albertson
1e94e3503e Fix for postfix_conf when using a non-standard config location
Pass the first argument of the opts array instead of the whole array which
confuses the SimpleConfig parser. Also added a test which verifies this fixes
the issue.

In addition, change the base_name to something that matches other resource base
names.

Signed-off-by: Lance Albertson <lance@osuosl.org>
2019-09-03 15:28:44 -07:00
mhackethal
204c41bfd1 Update users.rb to include new attributes 2019-08-30 22:07:36 +02:00
Clinton Wolfe
a6bd7ec4b5
Merge pull request #4401 from inspec/cw/input-from-cli
inputs: Accept bare input from the command line
2019-08-28 15:41:21 -04:00
Clinton Wolfe
51de566d93 Assert adjustments
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-28 13:25:49 -04:00
Clinton Wolfe
82acec957e Add API for fetching plugin vconfig values.
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-28 13:25:49 -04:00
Clinton Wolfe
38f3469ee3 Validation for the plugins area of the config file
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-28 13:25:49 -04:00
Clinton Wolfe
c6d355e4f7 Accept version 1.2 for config file format
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-28 13:25:49 -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
777f1a1bff Adjust checking for version when installing latest in unit test
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-27 21:29:42 -04:00
Clinton Wolfe
18640dd70c We do now include the version in the float fixture, for one thing
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-27 21:29:42 -04:00
Clinton Wolfe
16fecbefb5 Return version number when listing plugins; correct UX coloration
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-27 21:29:42 -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
714dc26006 Add unit test and include runtime version check in metadata.valid
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-26 23:05:49 -04:00
Clinton Wolfe
424318defa Stringify expected test outcomes for inputs
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-26 14:56:39 -04:00
Clinton Wolfe
fffb776982 Add newline
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-08-22 21:53:02 -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
David Gasper
ee2806a342 Fix RuboCop issues
Signed-off-by: David Gasper <dmgasper@osuosl.org>
2019-08-08 14:32:19 -07:00
David Gasper
52ae5e434b Add docs and unit tests, remove .travis.yml
Signed-off-by: David Gasper <dmgasper@osuosl.org>
2019-08-08 13:54:35 -07:00
Clinton Wolfe
95e6bcb317
Modified DarwinGroup to collect all users properly. (#4343)
group resource: Modified DarwinGroup to collect all users properly on macos
2019-08-08 11:55:48 -04:00
Ryan Davis
374e365c02 Modified DarwinGroup to collect all users properly.
I noticed that my profile targeting group "staff" on OSX wasn't
returning *me*. I'm awesome! So that seemed wrong. And it turns out it
is wrong. We were not collecting any users whose primary group was
that group. (almost all regular users are in group staff and they're
all missing).

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-08-07 20:27:13 -07:00
Mendy Baitelman
b2c29da936 Use dbus for testing
Signed-off-by: Mendy Baitelman <mendy@baitelman.com>
2019-08-06 21:34:46 -07:00
Mendy Baitelman
db58322d41 Add startname to systemd server
Signed-off-by: Mendy Baitelman <mendy@baitelman.com>
2019-08-06 21:04:52 -07:00
Mendy Baitelman
988357aad1 Fix tests
Signed-off-by: Mendy Baitelman <mendy@baitelman.com>
2019-08-06 18:58:03 -07: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
12fcb24932 Experiment with git subrepo storage
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
Ryan Davis
1e2da6acc2 Moved another non-test to test/unit/mock/files
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-29 11:42:30 -07:00
Ryan Davis
4df8072665 These tests probably never passed.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-29 11:42:30 -07:00
Ryan Davis
be11d8898d Found more tests that we've probably never actually run.
*sigh*

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-29 11:42:30 -07:00
Clinton Wolfe
be91550343
windows_task: Fix handling of multiple triggers (#4242)
windows_task: Fix handling of multiple triggers
2019-07-29 13:00:16 -04: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
c6837a3915 Moved skip_windows! to top helper and extended date to end of next month.
Fixed up requires in v2/installer_test.rb so it sees the top helper.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-24 18:06:25 -07:00
Ryan Davis
6dfa1d8310 Um. No.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-24 18:06:25 -07:00
Ryan Davis
bd79e9c895
Merge pull request #4316 from inspec/zenspider/fix-file-aws
Fix exceptions when resources are used with incompatible transports
2019-07-23 11:47:13 -07:00
Ryan Davis
7a1e1bb775
Merge pull request #4230 from yeoldegrove/sys_info
add resource sys_info.manufacturer and sys_info.model
2019-07-22 14:39:28 -07:00
Ryan Davis
7de549577c Return keys are really nice.
They make code more readable by visually separating different sections
of text.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-22 14:19:15 -07:00
Ryan Davis
d3df69213b Fix handling using resources with incompatible resources (eg file + aws).
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-07-22 14:19:15 -07:00
Clinton Wolfe
12b577fccd linting
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-22 15:17:30 -04:00
Clinton Wolfe
b37d165878 Unit test for suppressing doc install
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-22 15:17:30 -04:00
Eike Waldt
da4168f83d
add darwin/OSX tests
Signed-off-by: Eike Waldt <waldt@b1-systems.de>
2019-07-16 21:53:19 +02:00
Eike Waldt
9c06a0c8e2
refactor tests for resource sys_info.manufacturer and sys_info.model
Signed-off-by: Eike Waldt <waldt@b1-systems.de>
2019-07-16 21:02:52 +02:00
Eike Waldt
9278d8109d
add tests for resource sys_info.manufacturer and sys_info.model
Signed-off-by: Eike Waldt <waldt@b1-systems.de>
2019-07-16 21:02:45 +02:00
Eike Waldt
474d70b78d
fix description on sys_info.hostname tests
Signed-off-by: Eike Waldt <waldt@b1-systems.de>
2019-07-16 20:39:38 +02:00
Clinton Wolfe
f4b9bc4b0b rework filtertable call and add rubocop exception
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-11 15:04:38 -04:00
Miah Johnson
a4f4fe5231 chefstyle -a; https://github.com/chef/chefstyle/pull/74
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-07-08 17:22:50 -07:00
Miah Johnson
8272d0184b
Merge pull request #4236 from ramereth/ip6tables
Add ip6tables resource
2019-07-08 11:45:33 -07:00
Clinton Wolfe
e4e7c255de Automated chefstyle application for rubocop 0.72 compatibility
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-07-03 17:24:41 -04:00
Jerry Aldrich
5e93c4b12e Appease RuboCop
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
2019-07-01 22:45:04 -07:00
Jerry Aldrich
dafa4f4165 Try to appease Code Climate
I...I don't know how to make it better.

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
2019-07-01 22:39:12 -07:00
Jerry Aldrich
668b8d82bf windows_task: Fix handling of multiple triggers
When using `schtasks` a list is returned if the task has multiple
triggers. This merges that list with the last item taking precedence.
This is how `Get-ScheduledTask` behaves.

Initially, I was going to rewrite this resource to use
`Get-ScheduledTask` but the original author purposely did not do this
so that PowerShell v3 would be supported. We only support PowerShell
v5, but I don't want to break any current users and this change didn't
seem to controversial to me.

If it gives us trouble, I recommend rewriting it to use
`Get-ScheduledTask`.

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
2019-06-28 00:27:53 -07:00
Lance Albertson
3263d76627 Add ip6tables resource
This should resolve #1011 which provides an ip6tables resource to test IPv6
iptables rules. This is essentially a copy of the iptables resource with a few
renames.

In addition, I've pulled in the integration tests for iptables into ip6tables
and enabled it on docker so that it properly gets tested regularly. The test
cookbook recipe has been updated to support all of the current platforms that
are being tested.

Signed-off-by: Lance Albertson <lance@osuosl.org>
2019-06-24 17:01:34 -07:00
Jared Ledvina
45713b2627
Service add Debian 10 test
Signed-off-by: Jared Ledvina <jared@techsmix.net>
2019-06-22 13:23:32 -04:00