-
-
Notifications
You must be signed in to change notification settings - Fork 244
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 #368 from paybyphone/rspec_fix
Fixed service user specs
- Loading branch information
Showing
2 changed files
with
44 additions
and
17 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 |
---|---|---|
@@ -1,34 +1,59 @@ | ||
require 'spec_helper' | ||
|
||
describe "consul::default" do | ||
|
||
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) } | ||
let(:service_user) { } | ||
let(:create_service_user) { true } | ||
let(:platform) { { :platform => 'ubuntu', :version => '14.04' } } | ||
|
||
let(:chef_run) do | ||
runner = ChefSpec::SoloRunner.new(platform) do |node| | ||
node.normal['consul']['service_user'] = service_user | ||
node.normal['consul']['create_service_user'] = create_service_user | ||
end | ||
runner.converge(described_recipe) | ||
end | ||
|
||
context "with default service_user" do | ||
it 'creates the user without a login shell' do | ||
expect(chef_run).to create_poise_service_user('consul') | ||
end | ||
end | ||
|
||
context "with root service_user" do | ||
before do | ||
default_attributes['consul'] ||= {} | ||
default_attributes['consul']['service_user'] = 'root' | ||
context "with johnny5 service_user" do | ||
let(:service_user) { 'johnny5' } | ||
|
||
it 'creates the requested user' do | ||
expect(chef_run).to create_poise_service_user('johnny5') | ||
end | ||
it 'does not try to create the default user' do | ||
expect(chef_run).to_not create_poise_service_user('consul') | ||
end | ||
end | ||
|
||
context "with root service_user" do | ||
let(:service_user) { 'root' } | ||
|
||
it 'does not try to create the root user' do | ||
expect(chef_run).to_not create_poise_service_user('root') | ||
end | ||
it 'does not try to create the default user' do | ||
expect(chef_run).to_not create_poise_service_user('consul') | ||
end | ||
end | ||
|
||
context "with create_service_user disabled" do | ||
before do | ||
default_attributes['consul'] ||= {} | ||
default_attributes['consul']['create_service_user'] = false | ||
end | ||
let(:create_service_user) { false } | ||
|
||
it 'does not try to create the user' do | ||
expect(chef_run).to_not create_poise_service_user('consul') | ||
end | ||
end | ||
|
||
context 'on Windows' do | ||
let(:platform) { { :platform => 'windows', :version => '2012R2' } } | ||
|
||
it 'does not try to create the user' do | ||
expect(chef_run).to_not create_poise_service_user('consul') | ||
end | ||
end | ||
end |