-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from Microsoft/feature/inspec-profile
Restructured Integration Testing Suite using InSpec Profile
- Loading branch information
Showing
23 changed files
with
419 additions
and
235 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
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
name 'macos_test' | ||
maintainer 'Microsoft' | ||
maintainer_email '[email protected]' | ||
description 'The testing/example cookbook for the macOS cookbook recipes and custom resources.' | ||
chef_version '~> 13.0' if respond_to?(:chef_version) | ||
version '1.0.1' | ||
|
||
depends 'macos' |
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,6 @@ | ||
# macOS Cookbook InSpec Profile | ||
|
||
The macOS Cookbook InSpec profile tests the custom resources and the recipes | ||
that utilize them to ascertain their full functionality and dependability. We | ||
are always looking for better and more creative ways to test the code, and | ||
all types of contributions are welcomed. |
35 changes: 35 additions & 0 deletions
35
test/integration/default/controls/desktop_and_screensaver.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,35 @@ | ||
title 'desktop and screen saver' | ||
|
||
user_home = os_env('HOME').content | ||
test_user = 'vagrant' | ||
|
||
control 'screensaver-disabled' do | ||
title 'idletime is set to zero' | ||
desc 'Verify that when the computer is not in use, moving images or patterns do not appear' | ||
|
||
def hardware_uuid | ||
system_profiler_command = command('/usr/sbin/system_profiler SPHardwareDataType') | ||
hardware_data = ::Psych.load(system_profiler_command.stdout) | ||
hardware_data['Hardware']['Hardware Overview']['Hardware UUID'] | ||
end | ||
|
||
describe command('/usr/sbin/system_profiler SPHardwareDataType') do | ||
its('stdout') { should_not be nil } | ||
end | ||
|
||
describe command("/usr/libexec/PlistBuddy -c 'Print :idleTime' #{user_home}/Library/Preferences/ByHost/com.apple.screensaver.#{hardware_uuid}.plist") do | ||
its('stdout') { should match(/0/) } | ||
end | ||
|
||
describe command("su #{test_user} -c 'defaults -currentHost read com.apple.screensaver idleTime'") do | ||
its('stdout') { should match(/0/) } | ||
end | ||
|
||
describe command("su #{test_user} -c 'defaults -currentHost read-type com.apple.screensaver idleTime'") do | ||
its('stdout') { should match(/integer/) } | ||
end | ||
|
||
describe command("file --brief --mime #{user_home}/Library/Preferences/ByHost/com.apple.screensaver.#{hardware_uuid}.plist") do | ||
its('stdout') { should match(/binary/) } | ||
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,16 @@ | ||
user_home = os_env('HOME').content | ||
|
||
title 'dock' | ||
|
||
control 'dock-appearance' do | ||
title 'how the dock looks' | ||
desc 'Verify changes are made to the dock by modifying the plist' | ||
|
||
describe command("/usr/libexec/PlistBuddy -c 'Print :orientation' #{user_home}/Library/Preferences/com.apple.dock.plist") do | ||
its('stdout') { should match 'left' } | ||
end | ||
|
||
describe command("/usr/libexec/PlistBuddy -c 'Print :DisableAllAnimations' #{user_home}/Library/Preferences/com.apple.dock.plist") do | ||
its('stdout') { should match 'true' } | ||
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,67 @@ | ||
title 'energy saver' | ||
|
||
control 'remote-administration' do | ||
title 'power management settings for managed macs' | ||
desc ' | ||
Verify all sleep is disabled the machine automatically | ||
restarts after a freeze or power outage using the systemsetup and | ||
pmset commands | ||
' | ||
|
||
describe command('systemsetup -getremoteappleevents') do | ||
its('stdout') { should include 'Remote Apple Events: On' } | ||
end | ||
|
||
describe command('systemsetup -getwaitforstartupafterpowerfailure') do | ||
its('stdout') { should match(/getwaitforstartupafterpowerfailure: 0 seconds/) } | ||
end | ||
|
||
describe command('systemsetup -getremotelogin') do | ||
its('stdout') { should match(/On/) } | ||
end | ||
|
||
describe command('pmset -g') do | ||
its('stdout') { should match(/hibernatemode\s+0/) } | ||
end | ||
|
||
describe command('pmset -g') do | ||
its('stdout') { should match %r{hibernatefile\s+/var/vm/sleepimage} } | ||
end | ||
|
||
describe command('pmset -g') do | ||
its('stdout') { should match(/ttyskeepawake\s+1/) } | ||
end | ||
end | ||
|
||
control 'no-sleep' do | ||
title 'macOS never goes to sleep' | ||
desc 'Verify that the system will not fall asleep using the pmset and systemsetup commands' | ||
|
||
describe command('systemsetup -getcomputersleep') do | ||
its('stdout') { should match(/Never/) } | ||
end | ||
|
||
describe command('systemsetup -getdisplaysleep') do | ||
its('stdout') { should match(/Never/) } | ||
end | ||
|
||
describe command('systemsetup -getharddisksleep') do | ||
its('stdout') { should match(/after 10 minutes/) } | ||
end | ||
|
||
describe command('systemsetup -getrestartfreeze') do | ||
its('stdout') { should match(/On/) } | ||
end | ||
|
||
describe command('pmset -g') do | ||
its('stdout') { should match(/sleep\s+0/) } | ||
end | ||
|
||
describe command('pmset -g') do | ||
its('stdout') { should match(/disksleep\s+10/) } | ||
end | ||
|
||
describe command('pmset -g') do | ||
its('stdout') { should match(/displaysleep\s+0/) } | ||
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,13 @@ | ||
user_home = os_env('HOME').content | ||
|
||
title 'general' | ||
|
||
control 'show-all-files' do | ||
title 'enable visibility of invisble files and folders' | ||
desc 'Verify changes to the finder plist show hidden files using PlistBuddy' | ||
|
||
finder_plist = "#{user_home}/Library/Preferences/com.apple.finder.plist" | ||
describe command("/usr/libexec/PlistBuddy -c 'Print :AppleShowAllFiles' #{finder_plist}") do | ||
its('stdout') { should match 'true' } | ||
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,17 @@ | ||
title 'security' | ||
|
||
control 'certificate-install' do | ||
title 'installation and discovery of a certificate' | ||
desc ' | ||
Verify that a test certificate is able to be installed and can also | ||
be discovered via the security-find-certificate command | ||
' | ||
|
||
describe file('/Users/vagrant/Test.p12') do | ||
it { should exist } | ||
end | ||
|
||
describe command('/usr/bin/security find-certificate /Users/vagrant/Library/Keychains/login.keychain') do | ||
its('stdout') { should include 'Test' } | ||
end | ||
end |
Oops, something went wrong.