mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
CFINSPEC-82: Add unit test and documentation for ppa resource
Signed-off-by: Sonu Saha <sonu.saha@progress.com>
This commit is contained in:
parent
dfb1ef817e
commit
5f3570ee7a
2 changed files with 108 additions and 0 deletions
66
docs-chef-io/content/inspec/resources/ppa.md
Normal file
66
docs-chef-io/content/inspec/resources/ppa.md
Normal file
|
@ -0,0 +1,66 @@
|
|||
+++
|
||||
title = "ppa resource"
|
||||
draft = false
|
||||
gh_repo = "inspec"
|
||||
platform = "linux"
|
||||
|
||||
[menu]
|
||||
[menu.inspec]
|
||||
title = "ppa"
|
||||
identifier = "inspec/resources/os/ppa.md ppa resource"
|
||||
parent = "inspec/resources/os"
|
||||
+++
|
||||
|
||||
Use the `ppa` Chef InSpec audit resource to verify PPA repositories on Debian-based linux distributions. Personal Package Archives (PPAs) are software repositories designed for Ubuntu users and are easier to install than other third-party repositories.
|
||||
|
||||
The following ppa formats are supported:
|
||||
- `ubuntu-wine/ppa`
|
||||
- `ppa:ubuntu-wine/ppa`
|
||||
- `http://ppa.launchpad.net/juju/stable/ubuntu`
|
||||
|
||||
## Availability
|
||||
|
||||
### Installation
|
||||
|
||||
This resource is distributed along with Chef InSpec itself. You can use it automatically.
|
||||
|
||||
## Syntax
|
||||
|
||||
A `ppa` Chef InSpec audit resource verifies PPA repositories on Debian-based linux distributions
|
||||
|
||||
describe ppa('path) do
|
||||
it { should exist }
|
||||
it { should be_enabled }
|
||||
end
|
||||
where
|
||||
|
||||
- `ppa('path')` must specify a PPA repository
|
||||
- `exist` and `be_enabled` are a valid matchers for this resource
|
||||
|
||||
## Matchers
|
||||
|
||||
For a full list of available matchers, please visit our [matchers page](https://docs.chef.io/inspec/matchers/).
|
||||
|
||||
The specific matchers of this resource are: `exist` and `be_enabled`
|
||||
|
||||
### exist
|
||||
|
||||
The `exist` matcher tests if a repository exists on the system:
|
||||
|
||||
it { should exist }
|
||||
|
||||
### be_enabled
|
||||
|
||||
The `be_enabled` matcher tests if a repository is enabled on the system:
|
||||
|
||||
it { should be_enabled }
|
||||
## Examples
|
||||
The following example shows how to use this Chef InSpec audit resource.
|
||||
|
||||
### Verify that a PPA repository exists and is enabled
|
||||
|
||||
describe ppa('ppa:nginx/stable') do
|
||||
it { should exist }
|
||||
it { should be_enabled }
|
||||
end
|
||||
|
42
test/unit/resources/ppa_test.rb
Normal file
42
test/unit/resources/ppa_test.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
require "inspec/globals"
|
||||
require "#{Inspec.src_root}/test/helper"
|
||||
require_relative "../../../lib/inspec/resources/ppa"
|
||||
|
||||
describe Inspec::Resources::PpaRepository do
|
||||
|
||||
it "checks on ubuntu as name/ppa" do
|
||||
resource = MockLoader.new(:ubuntu).load_resource("ppa", "ubuntu-wine/ppa")
|
||||
_(resource.exists?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
end
|
||||
|
||||
it "checks on ubuntu as ppa:name/ppa" do
|
||||
resource = MockLoader.new(:ubuntu).load_resource("ppa", "ppa:ubuntu-wine/ppa")
|
||||
_(resource.exists?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
end
|
||||
|
||||
it "checks on mint as name/ppa" do
|
||||
resource = MockLoader.new(:mint18).load_resource("ppa", "ubuntu-wine/ppa")
|
||||
_(resource.exists?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
end
|
||||
|
||||
it "checks on mint as ppa:name/ppa" do
|
||||
resource = MockLoader.new(:mint18).load_resource("ppa", "ppa:ubuntu-wine/ppa")
|
||||
_(resource.exists?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
end
|
||||
|
||||
it "checks on debian as http://name/" do
|
||||
resource = MockLoader.new(:debian8).load_resource("ppa", "http://archive.ubuntu.com/ubuntu/")
|
||||
_(resource.exists?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
end
|
||||
|
||||
it "checks on unknown os" do
|
||||
resource = MockLoader.new(:undefined).load_resource("ppa", "ubuntu-wine/ppa")
|
||||
_(resource.exists?).must_equal false
|
||||
_(resource.enabled?).must_equal false
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue