-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add documentation detailing new certificate resource changes incorporating the -T option * modify security library and certificate resource to accomodate -T option * Testing for new and improved certificate resource * Fix Chef Spec tests * bump version to 1.9.0 * hotfix for plist encoding type utf-8 * move plutil_format_map to libraries * using Chef::Application.fatal to enforce encoding types * add one second after each systemsetup call * Add support for more hypervisors in keep_awake - Leverage the node['virtualization']['systems'] ohai attribute to determine whether we are a guest or a host - Add appropriate chefspec tests * Add another context for empty virtualization hash * bump to 1.8.1 * ensure xcode-install gem is in Chef embedded even if ChefDK is present * adjust implementation of running_in_a_vm? * fix rspec shared context * re-arrange chefspec keep_awake unit tests
- Loading branch information
1 parent
df5457d
commit 0db7830
Showing
14 changed files
with
178 additions
and
31 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
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
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
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,13 +1,121 @@ | ||
require 'spec_helper' | ||
|
||
describe 'macos::keep_awake' do | ||
context 'When all attributes are default, on macOS High Sierra 10.13' do | ||
let(:chef_run) { ChefSpec::SoloRunner.new.converge(described_recipe) } | ||
include MacOS::SystemSetup | ||
|
||
shared_context 'when running on bare metal' do | ||
shared_examples 'setting metal-specific power preferences' do | ||
before(:each) do | ||
allow_any_instance_of(Chef::Resource).to receive(:power_button_model?).and_return(true) | ||
chef_run.node.normal['virtualization']['systems'] = { 'vbox' => 'host', 'parallels' => 'host' } | ||
stub_command('which git').and_return('/usr/bin/git') | ||
end | ||
|
||
it 'returns false' do | ||
expect(running_in_a_vm?).to be false | ||
end | ||
|
||
it 'sets wake on lan' do | ||
chef_run.converge(described_recipe) | ||
expect(chef_run).to set_system_preference('wake the computer when accessed using a network connection') | ||
end | ||
|
||
it 'disables power button sleep' do | ||
chef_run.converge(described_recipe) | ||
expect(chef_run).to set_system_preference('pressing power button does not sleep computer') | ||
end | ||
|
||
it 'sets restart after a power failure' do | ||
chef_run.converge(described_recipe) | ||
expect(chef_run).to set_system_preference('restart after a power failure') | ||
end | ||
|
||
it 'converges successfully on bare metal' do | ||
expect { chef_run }.to_not raise_error | ||
end | ||
end | ||
end | ||
|
||
shared_context 'running in a parallels virtual machine' do | ||
before(:each) do | ||
allow_any_instance_of(Chef::Resource).to receive(:power_button_model?).and_return(false) | ||
chef_run.node.normal['virtualization']['systems'] = { 'parallels' => 'guest' } | ||
stub_command('which git').and_return('/usr/bin/git') | ||
end | ||
|
||
shared_examples 'not setting metal-specific power prefs' do | ||
it 'confirms we are in a vm' do | ||
expect(running_in_a_vm?).to be true | ||
end | ||
|
||
it 'does not set wake on lan' do | ||
chef_run.converge(described_recipe) | ||
expect(chef_run).to_not set_system_preference('wake the computer when accessed using a network connection') | ||
end | ||
|
||
it 'skips disabling power button sleep' do | ||
chef_run.converge(described_recipe) | ||
expect(chef_run).to_not set_system_preference('pressing power button does not sleep computer') | ||
end | ||
|
||
it 'does not set restart after a power failure' do | ||
chef_run.converge(described_recipe) | ||
expect(chef_run).to_not set_system_preference('restart after a power failure') | ||
end | ||
|
||
it 'converges successfully' do | ||
allow_any_instance_of(Chef::Resource).to receive(:running_in_a_vm?).and_return(false) | ||
allow_any_instance_of(Chef::Resource).to receive(:power_button_model?).and_return(false) | ||
it 'converges successfully in a vm' do | ||
expect { chef_run }.to_not raise_error | ||
end | ||
end | ||
end | ||
|
||
shared_context 'running in an undetermined virtualization system' do | ||
before(:each) do | ||
allow_any_instance_of(Chef::Resource).to receive(:power_button_model?).and_return(false) | ||
chef_run.node.override['virtualization']['systems'] = {} | ||
stub_command('which git').and_return('/usr/bin/git') | ||
end | ||
|
||
shared_examples 'not setting metal-specific power prefs' do | ||
it 'assumes we are in a vm' do | ||
expect(running_in_a_vm?).to be true | ||
end | ||
|
||
it 'does not set wake on lan' do | ||
chef_run.converge(described_recipe) | ||
expect(chef_run).to_not set_system_preference('wake the computer when accessed using a network connection') | ||
end | ||
|
||
it 'skips disabling power button sleep' do | ||
chef_run.converge(described_recipe) | ||
expect(chef_run).to_not set_system_preference('pressing power button does not sleep computer') | ||
end | ||
|
||
it 'does not set restart after a power failure' do | ||
chef_run.converge(described_recipe) | ||
expect(chef_run).to_not set_system_preference('restart after a power failure') | ||
end | ||
|
||
it 'converges successfully in a vm' do | ||
expect { chef_run }.to_not raise_error | ||
end | ||
end | ||
end | ||
|
||
describe 'macos::keep_awake' do | ||
let(:chef_run) { ChefSpec::SoloRunner.new } | ||
|
||
describe 'keep_awake in a parallels vm' do | ||
include_context 'running in a parallels virtual machine' | ||
it_behaves_like 'not setting metal-specific power prefs' | ||
end | ||
|
||
describe 'keep_awake in an undetermined virtualization system' do | ||
include_context 'running in an undetermined virtualization system' | ||
it_behaves_like 'not setting metal-specific power prefs' | ||
end | ||
|
||
describe 'keep_awake on bare metal' do | ||
include_context 'when running on bare metal' | ||
it_behaves_like 'setting metal-specific power preferences' | ||
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
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