forked from jackscott/golang-formula
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(inspec): add golang archive unittests
- Loading branch information
1 parent
c76d7cd
commit 6feafa9
Showing
7 changed files
with
161 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Default InSpec Profile | ||
|
||
This shows the implementation of the Default InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md). | ||
|
||
## Verify a profile | ||
|
||
InSpec ships with built-in features to verify a profile structure. | ||
|
||
```bash | ||
$ inspec check default | ||
Summary | ||
------- | ||
Location: default | ||
Profile: profile | ||
Controls: 4 | ||
Timestamp: 2019-06-24T23:09:01+00:00 | ||
Valid: true | ||
|
||
Errors | ||
------ | ||
|
||
Warnings | ||
-------- | ||
``` | ||
|
||
## Execute a profile | ||
|
||
To run all **supported** controls on a local machine use `inspec exec /path/to/profile`. | ||
|
||
```bash | ||
$ inspec exec default | ||
.. | ||
|
||
Finished in 0.0025 seconds (files took 0.12449 seconds to load) | ||
8 examples, 0 failures | ||
``` | ||
|
||
## Execute a specific control from a profile | ||
|
||
To run one control from the profile use `inspec exec /path/to/profile --controls name`. | ||
|
||
```bash | ||
$ inspec exec default --controls package | ||
. | ||
|
||
Finished in 0.0025 seconds (files took 0.12449 seconds to load) | ||
1 examples, 0 failures | ||
``` | ||
|
||
See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
title 'linux alternatives profile' | ||
|
||
control 'golang linux alternatives' do | ||
impact 1.0 | ||
title 'should be installed' | ||
desc "Ensure golang linux alternatives are correct" | ||
tag: package: "tarball archive" | ||
|
||
describe file('/usr/local/go') do # golang-home alternative | ||
it { should be_symlink } | ||
it { should_not be_file } | ||
it { should_not be_directory } | ||
it { should be_owned_by 'root' } | ||
it { should be_grouped_into 'root' } | ||
its('shallow_link_path') { should eq '/etc/alternatives/golang-home' } | ||
end | ||
|
||
describe file('/usr/bin/go') do # go alternative | ||
it { should be_symlink } | ||
it { should_not be_file } | ||
it { should_not be_directory } | ||
it { should be_owned_by 'root' } | ||
it { should be_grouped_into 'root' } | ||
its('shallow_link_path') { should eq '/etc/alternatives/link-go' } | ||
end | ||
|
||
describe file('/usr/bin/godoc') do # godoc alternative | ||
it { should be_symlink } | ||
it { should_not be_file } | ||
it { should_not be_directory } | ||
it { should be_owned_by 'root' } | ||
it { should be_grouped_into 'root' } | ||
its('shallow_link_path') { should eq '/etc/alternatives/link-godoc' } | ||
end | ||
|
||
describe file('/usr/bin/gofmt') do # gofmt alternative | ||
it { should be_symlink } | ||
it { should_not be_file } | ||
it { should_not be_directory } | ||
it { should be_owned_by 'root' } | ||
it { should be_grouped_into 'root' } | ||
its('shallow_link_path') { should eq '/etc/alternatives/link-gofmt' } | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
title 'archives profile' | ||
|
||
control 'golang tarball archive' do | ||
impact 1.0 | ||
title 'should be installed' | ||
desc "Ensure golang tarball archive was extracted correctly" | ||
tag: package: "tarball archive" | ||
|
||
describe file('/usr/local/go1.10.1.linux-amd64/go') do # another test | ||
it { should be_directory } | ||
it { should be_owned_by 'root' } | ||
it { should be_grouped_into 'root' } | ||
its('mode') { should cmp '0755' } | ||
end | ||
|
||
require 'digest' | ||
binary = file('/usr/local/go1.10.1.linux-amd64/go/bin/go').content | ||
sha256sum = Digest::SHA256.hexdigest(binary) | ||
describe file('/usr/local/go1.10.1.linux-amd64/go/bin/go') do | ||
its('sha256sum') { should eq '11438a2d41e257519e8c0ad098c287f9f73f1b8382a012a0c10e1dee5fb1e8ae' } | ||
end | ||
|
||
binary = file('/usr/local/go1.10.1.linux-amd64/go/bin/godoc').content | ||
sha256sum = Digest::SHA256.hexdigest(binary) | ||
describe file('/usr/local/go1.10.1.linux-amd64/go/bin/godoc') do | ||
its('sha256sum') { should eq '4076bb73349f253c04e5ef214934938760eefb26529f22d2e6fdbd61b99bb4b5' } | ||
end | ||
|
||
|
||
binary = file('/usr/local/go1.10.1.linux-amd64/go/bin/gofmt').content | ||
sha256sum = Digest::SHA256.hexdigest(binary) | ||
describe file('/usr/local/go1.10.1.linux-amd64/go/bin/go') do | ||
its('sha256sum') { should eq '5673f5914f195331322b20aee026f1882dac7c92b61c41bae23a04fb803b3e2c' } | ||
end | ||
|
||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
control 'template configuration environment' do | ||
title 'should match desired lines' | ||
|
||
describe file('/etc/default/golang.sh') do | ||
it { should be_file } | ||
it { should be_owned_by 'root' } | ||
it { should be_grouped_into 'root' } | ||
its('mode') { should cmp '0644' } | ||
its('content') { should include 'Your changes may be overwritten' } | ||
its('content') { should include 'export GOROOT=/usr/local/go' } | ||
its('content') { should include 'export GOPATH=/usr/local/golang/packages' } | ||
its('content') { should include 'export PATH=$PATH:$GOROOT/bin:$GOBASE/bin' } | ||
its('content') { should include 'export PATH=${PATH}:/usr/local/go1.10.1.linux-amd64' } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters