Commit graph

43 commits

Author SHA1 Message Date
mbaitelman
89cb81ca33 Update to return JSON, start writing tests
Signed-off-by: GitHub <noreply@github.com>
2020-10-16 18:01:38 +00:00
Raphael Geissert
b2e62b5b2f Run ps with an ulimited width on linux
On some systems the output of ps may be truncated, which may prevent
profiles from working as intended.

Some implementations specifically mention that the output width is
undefined "(it may be 80, unlimited, determined by the TERM variable,
and so on)".

This fixes #5226.

Signed-off-by: Raphael Geissert <atomo64@gmail.com>
2020-09-02 08:34:11 +02:00
Felipe Zipitria
d2ae7a7fbf
fix(osfamily): use corresponding family or name for bsd/freebsd
Signed-off-by: Felipe Zipitria <fzipitria@perceptyx.com>
2020-07-22 08:43:25 -03:00
Bryan McLellan
dada8ea074 Add the generic 'darwin' to the service resource
macOS 11 Big Sur will be released later this year. Current beta versions
return 10.16 as the version, but the product name has changed from 'Mac
OS X' to 'macOS'. Train probably needs to be modified to deprecate
'mac_os_x' as a platform in favor of 'macos' but that would be a
significant downstream change. Train does fall back to 'darwin' on macOS
10.16, so by adding darwin to the list of platform names for the service
resource we are able to work around this for the moment.

This is the only location where mac_os_x is currently being used in
InSpec. Because we're in a case statement on platform rather than the
more generic platform family, we can't simply remove mac_os_x in favor
of darwin.

Signed-off-by: Bryan McLellan <btm@loftninjas.org>
2020-07-02 09:36:27 -04:00
Clinton Wolfe
d9007588a6 Add an heuristic-based IP lookup property
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-06-18 15:37:19 -04:00
Clinton Wolfe
52468e470e Barebones plural interfaces resource
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-06-18 15:37:19 -04:00
Clinton Wolfe
a4000d6912 Adds support for interface on BSD and MacOS
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2020-06-18 15:37:19 -04:00
Ryan Davis
cc1393bb9a
Merge pull request #4822 from PiQuer/master
make command.exist? POSIX conform
2020-01-31 16:41:27 -08:00
Raimar Sandner
fa2f2c2caa make command.exist? POSIX conform
With the current implementation, on a Linux system without bash
command.exist? always returns false. 'sh -c' is guaranteed to exist on a
POSIX-conform system [1] whereas 'bash -c' only works if bash is
actually installed.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html

Obvious fix.
2020-01-19 00:05:33 +01:00
Michael Lihs
edd93eea81 Add support for yocto linux in service resource
Signed-off-by: Michael Lihs <michael.lihs@thoughtworks.com>
2020-01-18 01:26:16 +01:00
Ryan Davis
313f3462ca Cache MockLoader.connection.
Speeds up test/unit/profile/profile_context_test from 7-8s to 0.5s.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-12-31 15:27:12 -08:00
Felipe Zipitria
bff3fa960d
Add suport for freebsd package resource
Signed-off-by: Felipe Zipitria <fzipitria@perceptyx.com>
2019-12-17 08:39:43 -03:00
Mendy Baitelman
6baf0f8a1c Fix tests
Signed-off-by: Mendy Baitelman <mendy@baitelman.com>
2019-11-14 21:22:07 -08:00
Clinton Wolfe
1db2941a9e
Fix for invocation when calling npm under sudo (#4548)
Fix for invocation when calling npm under sudo
2019-11-12 16:01:07 -05: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
Clinton Wolfe
f85de31292 Update test mock file to match invocation
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-11-07 15:39:08 -05:00
Miah Johnson
de4139aff8
Merge pull request #4568 from ramereth/yum-el8-support
Improve testing for yum.repo in CentOS 8
2019-10-31 14:13:05 -07:00
Miah Johnson
44579ab4b3
Merge pull request #4637 from inspec/mj/3921
Fix filesystem resource when device has long name
2019-10-24 13:24:23 -07:00
Lance Albertson
dab91a321a Improve testing for yum.repo in CentOS 8
The output for ``yum -v repolist all`` changes slightly in CentOS 8. There are
two specific changes:

1. EL8 is no longer trailing the repo name with release version and arch (i.e.
   base instead of base/7/x86)
2. EL8 no longer adds a trailing newline on the last repo and instead has a line
   with ``Total packages:``. This means the repo listed last will never show up.

A fix was introduced in #4566 however the tests still use CentOS 7 yum output
instead of dnf repolist output. One issue was still discovered where it was
including the ``Total packages`` line in the last repository. This includes a
regex for to work around that and fixes for the tests.

Signed-off-by: Lance Albertson <lance@osuosl.org>
2019-10-24 08:22:42 -07:00
Miah Johnson
8e31367b51 Use new mock loader, update the command name
Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-10-23 21:42:10 -07:00
Ryan Davis
8d51d878f6 Fixed users resource when "Last password change" is "never".
Extended quick_resource to have platform methods and a new string
command mock. The named resource to mock may now be a symbol.

Added a new test that shows how to use quick_resource with multiple commands.

Fixes #4629.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-10-23 16:49:49 -07:00
Ryan Davis
fe34eb7869 Moved quick_resource and Fake helpers to test/helpers/resources.rb
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-10-16 16:54:07 -07:00
Ryan Davis
fc8ea79ad0 Fixed parsing yum output on centos8.
* Renamed and added extra test data to distinguish between centos 7 & centos 8.
* Renamed and added extra tests to cover centos 8.
* Fixed missing repo data by checking at the end if we were still in parse mode.

Fixes #4517

Signed-off-by: Ryan Davis <zenspider@chef.io>
Cc: Miah Johnson <miah@chia-pet.org>
2019-10-16 16:54:07 -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
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
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
Mendy Baitelman
4d990865a1 Add to mock_loader
Signed-off-by: Mendy Baitelman <mendy@baitelman.com>
2019-08-06 19:44:02 -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
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
b47cf6e80e
change from dmidecode to /sys/class/dmi/id/*
(kudos to Seife)

Signed-off-by: Eike Waldt <waldt@b1-systems.de>
2019-07-16 21:53:03 +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
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
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
Jerry Aldrich
80c595ba3d nginx_conf: Fix commented/empty file parsing
This fixes `nginx_conf.params` when:
  - Given an empty file
  - Given a file with only comments
  - Given a file that has an include for a file that:
    - Is empty
    - Has all lines commented out

This also fixes a test where a missing file is actually empty

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
2019-06-17 21:57:26 -08:00
Ryan Davis
fae4230a41 Removing inspec/profile_vendor from inspec/base_cli.
This was the next most expensive require in the analysis.

Also rearranged the way that ui handled tables to be lazy.

```
% SLOW=1 time rake test:functional

before: Finished in  681.514579s, 0.5136 runs/s, 2.9919 assertions/s.
after : Finished in  642.655918s, 0.5446 runs/s, 3.1728 assertions/s.
```

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-06-11 19:16:58 -07:00
Ryan Davis
a5309ea392 blindly applied chefstyle -a
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-06-11 18:52:03 -07:00
Ryan Davis
6bed51d69a Fixed up interactions between minitest & simplecov.
Sometime during the 2.x's, `at_exit` changed its ordering. As a result,
a lot of things that were stacking `at_exit`'s broke. This is one of
those since both simplecov and minitest do their thing via `at_exit`.
This switches to simplecov w/ no defaults on, then replicates their
simplecov/defaults.rb with our own.

I'm going to try to get that entire file back upstream but it can live
here for now.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-06-05 15:16:42 -07:00
Ryan Davis
ad12e601bf Minor cleanup on test/helper.rb
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-05-28 12:02:06 -07:00
Ryan Davis
09e892032b Extracting mock_loader to its own helper file.
Signed-off-by: Ryan Davis <zenspider@chef.io>
2019-05-25 02:59:31 -07:00