cheffish 1.1.2 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cheffish/chef_run.rb +13 -0
- data/lib/cheffish/rspec.rb +8 -0
- data/lib/cheffish/rspec/chef_run_support.rb +19 -52
- data/lib/cheffish/rspec/matchers.rb +4 -81
- data/lib/cheffish/rspec/matchers/be_idempotent.rb +16 -0
- data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +15 -0
- data/lib/cheffish/rspec/matchers/have_updated.rb +37 -0
- data/lib/cheffish/rspec/matchers/partially_match.rb +63 -0
- data/lib/cheffish/rspec/recipe_run_wrapper.rb +2 -2
- data/lib/cheffish/rspec/repository_support.rb +1 -1
- data/lib/cheffish/version.rb +1 -1
- data/spec/integration/chef_acl_spec.rb +384 -420
- data/spec/integration/chef_client_spec.rb +18 -24
- data/spec/integration/chef_container_spec.rb +4 -6
- data/spec/integration/chef_group_spec.rb +30 -46
- data/spec/integration/chef_mirror_spec.rb +60 -89
- data/spec/integration/chef_node_spec.rb +96 -124
- data/spec/integration/chef_organization_spec.rb +38 -57
- data/spec/integration/chef_user_spec.rb +16 -22
- data/spec/integration/private_key_spec.rb +120 -168
- data/spec/integration/recipe_dsl_spec.rb +4 -6
- data/spec/support/spec_support.rb +1 -2
- metadata +13 -8
- data/lib/cheffish/rspec/chef_run_wrapper.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6069dfb9d003c9835d32584227f0db27ead80ffe
|
4
|
+
data.tar.gz: 76efdfb5364249fcb021c569c2ef5c6b07d4c1a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efffb6621cd8b3d4993a587bc099949b2bb7e8f19aaf66fb37d18a60c96149bf68d9ba829e7ec4a831ad917497c112403ee4797c1d4db50a8d740ca1ccdafc4b
|
7
|
+
data.tar.gz: 1b0e4bbf57b84a4f98eb223f8dd3993a733808a22ccb88bc553ad7e1d780265dc3563c8d71c5242bc9346e6af4bb4e7954bd645831fb102f071e7846f8f5fe3f
|
data/lib/cheffish/chef_run.rb
CHANGED
@@ -62,11 +62,24 @@ module Cheffish
|
|
62
62
|
def logs
|
63
63
|
@client ? client.chef_config[:log_location].string : nil
|
64
64
|
end
|
65
|
+
def logged_warnings
|
66
|
+
logs.lines.select { |l| l =~ /^\[[^\]]*\] WARN:/ }.join("\n")
|
67
|
+
end
|
68
|
+
def logged_errors
|
69
|
+
logs.lines.select { |l| l =~ /^\[[^\]]*\] ERROR:/ }.join("\n")
|
70
|
+
end
|
71
|
+
def logged_info
|
72
|
+
logs.lines.select { |l| l =~ /^\[[^\]]*\] INFO:/ }.join("\n")
|
73
|
+
end
|
65
74
|
|
66
75
|
def resources
|
67
76
|
client.resource_collection
|
68
77
|
end
|
69
78
|
|
79
|
+
def compile_recipe(&recipe)
|
80
|
+
client.load_block(&recipe)
|
81
|
+
end
|
82
|
+
|
70
83
|
def converge
|
71
84
|
begin
|
72
85
|
client.converge
|
@@ -2,9 +2,9 @@ require 'chef_zero/rspec'
|
|
2
2
|
require 'chef/server_api'
|
3
3
|
require 'cheffish/rspec/repository_support'
|
4
4
|
require 'uri'
|
5
|
-
require 'cheffish/
|
6
|
-
require 'cheffish/rspec/chef_run_wrapper'
|
5
|
+
require 'cheffish/chef_run'
|
7
6
|
require 'cheffish/rspec/recipe_run_wrapper'
|
7
|
+
require 'cheffish/rspec/matchers'
|
8
8
|
|
9
9
|
module Cheffish
|
10
10
|
module RSpec
|
@@ -24,22 +24,10 @@ module Cheffish
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def with_converge(&recipe)
|
28
28
|
before :each do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
after :each do
|
33
|
-
if !chef_client.converge_failed? && !chef_client.converged?
|
34
|
-
raise "Never tried to converge!"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def with_converge(&block)
|
40
|
-
before :each do
|
41
|
-
load_recipe(&block) if block_given?
|
42
|
-
converge
|
29
|
+
r = recipe(&recipe)
|
30
|
+
r.converge
|
43
31
|
end
|
44
32
|
end
|
45
33
|
|
@@ -60,49 +48,28 @@ module Cheffish
|
|
60
48
|
end
|
61
49
|
|
62
50
|
def expect_recipe(&recipe)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
def recipe(&recipe)
|
67
|
-
RecipeRunWrapper.new(chef_config, &recipe)
|
68
|
-
end
|
69
|
-
|
70
|
-
def chef_client
|
71
|
-
@chef_client ||= ChefRunWrapper.new(chef_config)
|
72
|
-
end
|
73
|
-
|
74
|
-
def chef_run
|
75
|
-
converge if !chef_client.converged?
|
76
|
-
event_sink.events
|
77
|
-
end
|
78
|
-
|
79
|
-
def event_sink
|
80
|
-
chef_client.event_sink
|
51
|
+
r = recipe(&recipe)
|
52
|
+
r.converge
|
53
|
+
expect(r)
|
81
54
|
end
|
82
55
|
|
83
|
-
def
|
84
|
-
|
56
|
+
def expect_converge(&recipe)
|
57
|
+
r = recipe(&recipe)
|
58
|
+
expect { r.converge }
|
85
59
|
end
|
86
60
|
|
87
|
-
def
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
def run_recipe(&recipe)
|
92
|
-
load_recipe(&recipe)
|
93
|
-
converge
|
61
|
+
def recipe(&recipe)
|
62
|
+
RecipeRunWrapper.new(chef_config, &recipe)
|
94
63
|
end
|
95
64
|
|
96
|
-
def
|
97
|
-
|
98
|
-
|
65
|
+
def converge(&recipe)
|
66
|
+
r = RecipeRunWrapper.new(chef_config, &recipe)
|
67
|
+
r.converge
|
68
|
+
r
|
99
69
|
end
|
100
70
|
|
101
|
-
def
|
102
|
-
|
103
|
-
raise "Already converged! Cannot converge twice, that's bad mojo."
|
104
|
-
end
|
105
|
-
chef_client.converge
|
71
|
+
def chef_client
|
72
|
+
@chef_client ||= ChefRun.new(chef_config)
|
106
73
|
end
|
107
74
|
end
|
108
75
|
end
|
@@ -1,81 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
6
|
-
failure_message do |actual|
|
7
|
-
updates = actual.select { |event, resource, action| event == :resource_updated }.to_a
|
8
|
-
result = "expected that the chef_run would #{expected_actions.join(',')} #{resource_name}."
|
9
|
-
if updates.size > 0
|
10
|
-
result << " Actual updates were #{updates.map { |event, resource, action| "#{resource.to_s} => #{action.inspect}" }.join(', ')}"
|
11
|
-
else
|
12
|
-
result << " Nothing was updated."
|
13
|
-
end
|
14
|
-
result
|
15
|
-
end
|
16
|
-
failure_message_when_negated do |actual|
|
17
|
-
updates = actual.select { |event, resource, action| event == :resource_updated }.to_a
|
18
|
-
result = "expected that the chef_run would not #{expected_actions.join(',')} #{resource_name}."
|
19
|
-
if updates.size > 0
|
20
|
-
result << " Actual updates were #{updates.map { |event, resource, action| "#{resource.to_s} => #{action.inspect}" }.join(', ')}"
|
21
|
-
else
|
22
|
-
result << " Nothing was updated."
|
23
|
-
end
|
24
|
-
result
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
RSpec::Matchers.define :be_idempotent do
|
29
|
-
match do |recipe|
|
30
|
-
@recipe = recipe
|
31
|
-
recipe.reset
|
32
|
-
recipe.converge
|
33
|
-
recipe.up_to_date?
|
34
|
-
end
|
35
|
-
|
36
|
-
failure_message {
|
37
|
-
"#{@recipe} is not idempotent! Converging it a second time caused updates.\n#{@recipe.output_for_failure_message}"
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
RSpec::Matchers.define :update_acls do |acl_paths, expected_acls|
|
43
|
-
|
44
|
-
errors = []
|
45
|
-
|
46
|
-
match do |block|
|
47
|
-
orig_json = {}
|
48
|
-
Array(acl_paths).each do |acl_path|
|
49
|
-
orig_json[acl_path] = get(acl_path)
|
50
|
-
end
|
51
|
-
|
52
|
-
block.call
|
53
|
-
|
54
|
-
orig_json.each_pair do |acl_path, orig|
|
55
|
-
changed = get(acl_path)
|
56
|
-
expected_acls.each do |permission, hash|
|
57
|
-
hash.each do |type, actors|
|
58
|
-
actors.each do |actor|
|
59
|
-
if actor[0] == '-'
|
60
|
-
actor = actor[1..-1]
|
61
|
-
errors << "#{acl_path} expected to remove #{type} #{actor} from #{permission} permissions" if changed[permission][type].include?(actor)
|
62
|
-
orig[permission][type].delete(actor)
|
63
|
-
else
|
64
|
-
errors << "#{acl_path} expected to add #{type} #{actor} to #{permission} permissions" if !changed[permission][type].include?(actor)
|
65
|
-
changed[permission][type].delete(actor)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
# After checking everything, see if the remaining acl is the same as before
|
71
|
-
errors << "#{acl_path} updated more than expected!\nActual:\n#{changed}\nExpected:\n#{orig}" if changed != orig
|
72
|
-
end
|
73
|
-
errors.size == 0
|
74
|
-
end
|
75
|
-
|
76
|
-
failure_message do |block|
|
77
|
-
errors.join("\n")
|
78
|
-
end
|
79
|
-
|
80
|
-
supports_block_expectations
|
81
|
-
end
|
1
|
+
require 'cheffish/rspec/matchers/have_updated'
|
2
|
+
require 'cheffish/rspec/matchers/be_idempotent'
|
3
|
+
require 'cheffish/rspec/matchers/partially_match'
|
4
|
+
require 'cheffish/rspec/matchers/emit_no_warnings_or_errors'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rspec/matchers'
|
2
|
+
|
3
|
+
RSpec::Matchers.define :be_idempotent do
|
4
|
+
match do |recipe|
|
5
|
+
@recipe = recipe
|
6
|
+
recipe.reset
|
7
|
+
recipe.converge
|
8
|
+
recipe.up_to_date?
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message {
|
12
|
+
"#{@recipe} is not idempotent! Converging it a second time caused updates.\n#{@recipe.output_for_failure_message}"
|
13
|
+
}
|
14
|
+
|
15
|
+
supports_block_expectations
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rspec/matchers'
|
2
|
+
|
3
|
+
RSpec::Matchers.define :emit_no_warnings_or_errors do
|
4
|
+
match do |recipe|
|
5
|
+
@recipe = recipe
|
6
|
+
@warn_err = recipe.logs.lines.select { |l| l =~ /warn|err/i }.join("\n")
|
7
|
+
@warn_err.empty?
|
8
|
+
end
|
9
|
+
|
10
|
+
failure_message {
|
11
|
+
"#{@recipe} emitted warnings and errors!\n#{@warn_err}"
|
12
|
+
}
|
13
|
+
|
14
|
+
supports_block_expectations
|
15
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rspec/matchers'
|
2
|
+
|
3
|
+
RSpec::Matchers.define :have_updated do |resource_name, *expected_actions|
|
4
|
+
match do |recipe|
|
5
|
+
@recipe = recipe
|
6
|
+
actual = @recipe.event_sink.events
|
7
|
+
actual_actions = actual.select { |event, resource, action| event == :resource_updated && resource.to_s == resource_name }.
|
8
|
+
map { |event, resource, action| action }
|
9
|
+
expect(actual_actions).to eq(expected_actions)
|
10
|
+
end
|
11
|
+
|
12
|
+
failure_message do
|
13
|
+
actual = @recipe.event_sink.events
|
14
|
+
updates = actual.select { |event, resource, action| event == :resource_updated }.to_a
|
15
|
+
result = "expected that the chef_run would #{expected_actions.join(',')} #{resource_name}."
|
16
|
+
if updates.size > 0
|
17
|
+
result << " Actual updates were #{updates.map { |event, resource, action| "#{resource.to_s} => #{action.inspect}" }.join(', ')}"
|
18
|
+
else
|
19
|
+
result << " Nothing was updated."
|
20
|
+
end
|
21
|
+
result
|
22
|
+
end
|
23
|
+
|
24
|
+
failure_message_when_negated do
|
25
|
+
actual = @recipe.event_sink.events
|
26
|
+
updates = actual.select { |event, resource, action| event == :resource_updated }.to_a
|
27
|
+
result = "expected that the chef_run would not #{expected_actions.join(',')} #{resource_name}."
|
28
|
+
if updates.size > 0
|
29
|
+
result << " Actual updates were #{updates.map { |event, resource, action| "#{resource.to_s} => #{action.inspect}" }.join(', ')}"
|
30
|
+
else
|
31
|
+
result << " Nothing was updated."
|
32
|
+
end
|
33
|
+
result
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec::Matchers.define_negated_matcher :not_have_updated, :have_updated
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Cheffish
|
2
|
+
module RSpec
|
3
|
+
module Matchers
|
4
|
+
class PartiallyMatch
|
5
|
+
include ::RSpec::Matchers::Composable
|
6
|
+
|
7
|
+
def initialize(example, expected)
|
8
|
+
@example = example
|
9
|
+
@expected = expected
|
10
|
+
end
|
11
|
+
|
12
|
+
def matches?(actual)
|
13
|
+
@actual = actual
|
14
|
+
partially_matches_values(@expected, actual)
|
15
|
+
end
|
16
|
+
|
17
|
+
def failure_message
|
18
|
+
"expected #{@actual} to match #{@expected}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def failure_message_when_negated
|
22
|
+
"expected #{@actual} not to match #{@expected}"
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def partially_matches_values(expected, actual)
|
28
|
+
if Hash === actual
|
29
|
+
return partially_matches_hashes(expected, actual) if Hash === expected || Array === expected
|
30
|
+
elsif Array === expected && Enumerable === actual && !(Struct === actual)
|
31
|
+
return partially_matches_arrays(expected, actual)
|
32
|
+
end
|
33
|
+
|
34
|
+
return true if actual == expected
|
35
|
+
|
36
|
+
begin
|
37
|
+
expected === actual
|
38
|
+
rescue ArgumentError
|
39
|
+
# Some objects, like 0-arg lambdas on 1.9+, raise
|
40
|
+
# ArgumentError for `expected === actual`.
|
41
|
+
false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def partially_matches_hashes(expected, actual)
|
46
|
+
expected.all? { |key, value| partially_matches_values(value, actual[key]) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def partially_matches_arrays(expected, actual)
|
50
|
+
expected.all? { |e| actual.any? { |a| partially_matches_values(e, a) } }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
module RSpec
|
58
|
+
module Matchers
|
59
|
+
def partially_match(expected)
|
60
|
+
Cheffish::RSpec::Matchers::PartiallyMatch.new(self, expected)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'cheffish/
|
1
|
+
require 'cheffish/chef_run'
|
2
2
|
|
3
3
|
module Cheffish
|
4
4
|
module RSpec
|
5
|
-
class RecipeRunWrapper <
|
5
|
+
class RecipeRunWrapper < ChefRun
|
6
6
|
def initialize(chef_config, &recipe)
|
7
7
|
super(chef_config)
|
8
8
|
@recipe = recipe
|
data/lib/cheffish/version.rb
CHANGED
@@ -9,34 +9,31 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
9
9
|
describe Chef::Resource::ChefAcl do
|
10
10
|
extend Cheffish::RSpec::ChefRunSupport
|
11
11
|
|
12
|
+
# let(:chef_config) { super().merge(log_level: :debug, stdout: STDOUT, stderr: STDERR, log_location: STDOUT) }
|
13
|
+
|
12
14
|
context "Rights attributes" do
|
13
15
|
when_the_chef_server 'has a node named x', :osc_compat => false do
|
14
16
|
node 'x', {}
|
15
17
|
|
16
18
|
it 'Converging chef_acl "nodes/x" changes nothing' do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}.to update_acls('nodes/x/_acl', {})
|
19
|
+
expect_recipe {
|
20
|
+
chef_acl 'nodes/x'
|
21
|
+
}.to be_up_to_date
|
22
|
+
expect(get('nodes/x/_acl')).to partially_match({})
|
22
23
|
end
|
23
24
|
|
24
25
|
it 'Converging chef_acl "nodes/x" with "complete true" and no rights raises an error' do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
complete true
|
29
|
-
end
|
26
|
+
expect_converge {
|
27
|
+
chef_acl 'nodes/x' do
|
28
|
+
complete true
|
30
29
|
end
|
31
30
|
}.to raise_error(RuntimeError)
|
32
31
|
end
|
33
32
|
|
34
33
|
it 'Removing all :grant rights from a node raises an error' do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
remove_rights :grant, :users => 'pivotal', :groups => %w(admins users clients)
|
39
|
-
end
|
34
|
+
expect_converge {
|
35
|
+
chef_acl 'nodes/x' do
|
36
|
+
remove_rights :grant, users: %w(pivotal), groups: %w(admins users clients)
|
40
37
|
end
|
41
38
|
}.to raise_error(RuntimeError)
|
42
39
|
end
|
@@ -45,61 +42,57 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
45
42
|
user 'blarghle', {}
|
46
43
|
|
47
44
|
it 'Converging chef_acl "nodes/x" with user "blarghle" adds the user' do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
rights :read, :users => 'blarghle'
|
52
|
-
end
|
45
|
+
expect_recipe {
|
46
|
+
chef_acl 'nodes/x' do
|
47
|
+
rights :read, users: %w(blarghle)
|
53
48
|
end
|
54
|
-
}.to
|
49
|
+
}.to be_updated
|
50
|
+
expect(get('nodes/x/_acl')).to partially_match('read' => { 'actors' => %w(blarghle) })
|
55
51
|
end
|
56
52
|
|
57
53
|
it 'Converging chef_acl "nodes/x" with "complete true" removes all ACLs except those specified' do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
complete true
|
63
|
-
end
|
54
|
+
expect_recipe {
|
55
|
+
chef_acl 'nodes/x' do
|
56
|
+
rights :grant, users: %w(blarghle)
|
57
|
+
complete true
|
64
58
|
end
|
65
|
-
}.to
|
66
|
-
|
67
|
-
"
|
68
|
-
"
|
69
|
-
"
|
70
|
-
"
|
71
|
-
|
59
|
+
}.to be_updated
|
60
|
+
expect(get('nodes/x/_acl')).to eq(
|
61
|
+
"create"=>{"actors"=>[], "groups"=>[]},
|
62
|
+
"read" =>{"actors"=>[], "groups"=>[]},
|
63
|
+
"update"=>{"actors"=>[], "groups"=>[]},
|
64
|
+
"delete"=>{"actors"=>[], "groups"=>[]},
|
65
|
+
"grant" =>{"actors"=>["blarghle"], "groups"=>[]}
|
66
|
+
)
|
72
67
|
end
|
73
68
|
end
|
74
69
|
|
75
70
|
it 'Converging chef_acl "nodes/x" with "complete true" removes all ACLs except those specified in :all' do
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
"
|
85
|
-
"
|
86
|
-
"
|
87
|
-
"
|
88
|
-
|
89
|
-
})
|
71
|
+
expect_recipe {
|
72
|
+
chef_acl 'nodes/x' do
|
73
|
+
rights :all, users: %w(blarghle)
|
74
|
+
complete true
|
75
|
+
end
|
76
|
+
}.to be_updated
|
77
|
+
expect(get('nodes/x/_acl')).to eq(
|
78
|
+
"create"=>{"actors"=>["blarghle"], "groups"=>[]},
|
79
|
+
"read" =>{"actors"=>["blarghle"], "groups"=>[]},
|
80
|
+
"update"=>{"actors"=>["blarghle"], "groups"=>[]},
|
81
|
+
"delete"=>{"actors"=>["blarghle"], "groups"=>[]},
|
82
|
+
"grant" =>{"actors"=>["blarghle"], "groups"=>[]}
|
83
|
+
)
|
90
84
|
end
|
91
85
|
|
92
86
|
context 'and a client "blarghle"' do
|
93
87
|
user 'blarghle', {}
|
94
88
|
|
95
89
|
it 'Converging chef_acl "nodes/x" with client "blarghle" adds the client' do
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
rights :read, :clients => 'blarghle'
|
100
|
-
end
|
90
|
+
expect_recipe {
|
91
|
+
chef_acl 'nodes/x' do
|
92
|
+
rights :read, clients: %w(blarghle)
|
101
93
|
end
|
102
|
-
}.to
|
94
|
+
}.to be_updated
|
95
|
+
expect(get('nodes/x/_acl')).to partially_match('read' => { 'actors' => %w(blarghle) })
|
103
96
|
end
|
104
97
|
end
|
105
98
|
|
@@ -107,13 +100,12 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
107
100
|
group 'blarghle', {}
|
108
101
|
|
109
102
|
it 'Converging chef_acl "nodes/x" with group "blarghle" adds the group' do
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
rights :read, :groups => 'blarghle'
|
114
|
-
end
|
103
|
+
expect_recipe {
|
104
|
+
chef_acl 'nodes/x' do
|
105
|
+
rights :read, groups: %w(blarghle)
|
115
106
|
end
|
116
|
-
}.to
|
107
|
+
}.to be_updated
|
108
|
+
expect(get('nodes/x/_acl')).to partially_match('read' => { 'groups' => %w(blarghle) })
|
117
109
|
end
|
118
110
|
end
|
119
111
|
|
@@ -129,41 +121,38 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
129
121
|
group 'g3', {}
|
130
122
|
|
131
123
|
it 'Converging chef_acl "nodes/x" with multiple groups, users and clients in an acl makes the appropriate changes' do
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
rights :create, :users => [ 'u1', 'u2', 'u3' ], :clients => [ 'c1', 'c2', 'c3' ], :groups => [ 'g1', 'g2', 'g3' ]
|
136
|
-
end
|
124
|
+
expect_recipe {
|
125
|
+
chef_acl 'nodes/x' do
|
126
|
+
rights :create, users: [ 'u1', 'u2', 'u3' ], clients: [ 'c1', 'c2', 'c3' ], groups: [ 'g1', 'g2', 'g3' ]
|
137
127
|
end
|
138
|
-
}.to
|
128
|
+
}.to be_updated
|
129
|
+
expect(get('nodes/x/_acl')).to partially_match(
|
139
130
|
'create' => { 'groups' => %w(g1 g2 g3), 'actors' => %w(u1 u2 u3 c1 c2 c3) }
|
140
131
|
)
|
141
132
|
end
|
142
133
|
|
143
134
|
it 'Converging chef_acl "nodes/x" with multiple groups, users and clients across multiple "rights" groups makes the appropriate changes' do
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
rights :read, :groups => 'g1'
|
151
|
-
end
|
135
|
+
expect_recipe {
|
136
|
+
chef_acl 'nodes/x' do
|
137
|
+
rights :create, users: %w(u1), clients: %w(c1), groups: %w(g1)
|
138
|
+
rights :create, users: %w(u2 u3), clients: %w(c2 c3), groups: %w(g2)
|
139
|
+
rights :read, users: %w(u1)
|
140
|
+
rights :read, groups: %w(g1)
|
152
141
|
end
|
153
|
-
}.to
|
142
|
+
}.to be_updated
|
143
|
+
expect(get('nodes/x/_acl')).to partially_match(
|
154
144
|
'create' => { 'groups' => %w(g1 g2), 'actors' => %w(u1 u2 u3 c1 c2 c3) },
|
155
145
|
'read' => { 'groups' => %w(g1), 'actors' => %w(u1) }
|
156
146
|
)
|
157
147
|
end
|
158
148
|
|
159
149
|
it 'Converging chef_acl "nodes/x" with rights [ :read, :create, :update, :delete, :grant ] modifies all rights' do
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
rights [ :create, :read, :update, :delete, :grant ], :users => %w(u1 u2), :clients => 'c1', :groups => 'g1'
|
164
|
-
end
|
150
|
+
expect_recipe {
|
151
|
+
chef_acl 'nodes/x' do
|
152
|
+
rights [ :create, :read, :update, :delete, :grant ], users: %w(u1 u2), clients: %w(c1), groups: %w(g1)
|
165
153
|
end
|
166
|
-
}.to
|
154
|
+
}.to be_updated
|
155
|
+
expect(get('nodes/x/_acl')).to partially_match(
|
167
156
|
'create' => { 'groups' => %w(g1), 'actors' => %w(u1 u2 c1) },
|
168
157
|
'read' => { 'groups' => %w(g1), 'actors' => %w(u1 u2 c1) },
|
169
158
|
'update' => { 'groups' => %w(g1), 'actors' => %w(u1 u2 c1) },
|
@@ -173,13 +162,12 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
173
162
|
end
|
174
163
|
|
175
164
|
it 'Converging chef_acl "nodes/x" with rights :all modifies all rights' do
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
rights :all, :users => %w(u1 u2), :clients => 'c1', :groups => 'g1'
|
180
|
-
end
|
165
|
+
expect_recipe {
|
166
|
+
chef_acl 'nodes/x' do
|
167
|
+
rights :all, users: %w(u1 u2), clients: %w(c1), groups: %w(g1)
|
181
168
|
end
|
182
|
-
}.to
|
169
|
+
}.to be_updated
|
170
|
+
expect(get('nodes/x/_acl')).to partially_match(
|
183
171
|
'create' => { 'groups' => %w(g1), 'actors' => %w(u1 u2 c1) },
|
184
172
|
'read' => { 'groups' => %w(g1), 'actors' => %w(u1 u2 c1) },
|
185
173
|
'update' => { 'groups' => %w(g1), 'actors' => %w(u1 u2 c1) },
|
@@ -190,10 +178,8 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
190
178
|
end
|
191
179
|
|
192
180
|
it 'Converging chef_acl "nodes/y" throws a 404' do
|
193
|
-
|
194
|
-
|
195
|
-
chef_acl 'nodes/y'
|
196
|
-
end
|
181
|
+
expect_converge {
|
182
|
+
chef_acl 'nodes/y'
|
197
183
|
}.to raise_error(Net::HTTPServerException)
|
198
184
|
end
|
199
185
|
end
|
@@ -205,13 +191,12 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
205
191
|
end
|
206
192
|
|
207
193
|
it 'Converging chef_acl "nodes/x" with that user changes nothing' do
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
rights :read, :users => 'blarghle'
|
212
|
-
end
|
194
|
+
expect_recipe {
|
195
|
+
chef_acl 'nodes/x' do
|
196
|
+
rights :read, users: %w(blarghle)
|
213
197
|
end
|
214
|
-
}.to
|
198
|
+
}.to be_up_to_date
|
199
|
+
expect(get('nodes/x/_acl')).to partially_match({})
|
215
200
|
end
|
216
201
|
end
|
217
202
|
|
@@ -227,22 +212,23 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
227
212
|
end
|
228
213
|
|
229
214
|
it 'Converging chef_acl "nodes/x" with remove_rights :all removes foo from everything' do
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
'
|
238
|
-
'
|
239
|
-
'
|
240
|
-
'
|
241
|
-
'grant' => { 'actors' => %w(-foo) },
|
215
|
+
expect_recipe {
|
216
|
+
chef_acl 'nodes/x' do
|
217
|
+
remove_rights :all, users: %w(foo)
|
218
|
+
end
|
219
|
+
}.to be_updated
|
220
|
+
expect(get('nodes/x/_acl')).to partially_match(
|
221
|
+
'create' => { 'actors' => exclude('foo') },
|
222
|
+
'read' => { 'actors' => exclude('foo') },
|
223
|
+
'update' => { 'actors' => exclude('foo') },
|
224
|
+
'delete' => { 'actors' => exclude('foo') },
|
225
|
+
'grant' => { 'actors' => exclude('foo') },
|
242
226
|
)
|
243
227
|
end
|
244
228
|
end
|
245
229
|
|
230
|
+
::RSpec::Matchers.define_negated_matcher :exclude, :include
|
231
|
+
|
246
232
|
context 'recursive' do
|
247
233
|
when_the_chef_server 'has a nodes container with user blarghle in its acl', :osc_compat => false do
|
248
234
|
user 'blarghle', {}
|
@@ -253,67 +239,70 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
253
239
|
|
254
240
|
it 'Converging chef_acl "nodes" makes no changes' do
|
255
241
|
expect {
|
256
|
-
|
242
|
+
expect_recipe {
|
257
243
|
chef_acl 'nodes' do
|
258
|
-
rights :read, :
|
244
|
+
rights :read, users: %w(blarghle)
|
259
245
|
end
|
260
|
-
|
261
|
-
|
246
|
+
}.to be_up_to_date
|
247
|
+
}.to not_change { get('containers/nodes/_acl') }.
|
248
|
+
and not_change { get('nodes/x/_acl') }
|
262
249
|
end
|
263
250
|
|
251
|
+
RSpec::Matchers.define_negated_matcher :not_change, :change
|
252
|
+
|
264
253
|
it 'Converging chef_acl "nodes" with recursive :on_change makes no changes' do
|
265
254
|
expect {
|
266
|
-
|
255
|
+
expect_recipe {
|
267
256
|
chef_acl 'nodes' do
|
268
|
-
rights :read, :
|
257
|
+
rights :read, users: %w(blarghle)
|
269
258
|
recursive :on_change
|
270
259
|
end
|
271
|
-
|
272
|
-
|
260
|
+
}.to be_up_to_date
|
261
|
+
}.to not_change { get('containers/nodes/_acl') }.
|
262
|
+
and not_change { get('nodes/x/_acl') }
|
273
263
|
end
|
274
264
|
|
275
265
|
it 'Converging chef_acl "nodes" with recursive true changes nodes/x\'s acls' do
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
recursive true
|
281
|
-
end
|
266
|
+
expect_recipe {
|
267
|
+
chef_acl 'nodes' do
|
268
|
+
rights :read, users: %w(blarghle)
|
269
|
+
recursive true
|
282
270
|
end
|
283
|
-
}.to
|
271
|
+
}.to be_updated
|
272
|
+
expect(get('nodes/x/_acl')).to partially_match('read' => { 'actors' => %w(blarghle) })
|
284
273
|
end
|
285
274
|
|
286
275
|
it 'Converging chef_acl "" with recursive false does not change nodes/x\'s acls' do
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
recursive false
|
292
|
-
end
|
276
|
+
expect_recipe {
|
277
|
+
chef_acl '' do
|
278
|
+
rights :read, users: %w(blarghle)
|
279
|
+
recursive false
|
293
280
|
end
|
294
|
-
}.to
|
281
|
+
}.to be_updated
|
282
|
+
expect(get('containers/nodes/_acl')).to partially_match({})
|
283
|
+
expect(get('nodes/x/_acl')).to partially_match({})
|
295
284
|
end
|
296
285
|
|
297
286
|
it 'Converging chef_acl "" with recursive :on_change does not change nodes/x\'s acls' do
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
recursive :on_change
|
303
|
-
end
|
287
|
+
expect_recipe {
|
288
|
+
chef_acl '' do
|
289
|
+
rights :read, users: %w(blarghle)
|
290
|
+
recursive :on_change
|
304
291
|
end
|
305
|
-
}.to
|
292
|
+
}.to be_updated
|
293
|
+
expect(get('containers/nodes/_acl')).to partially_match({})
|
294
|
+
expect(get('nodes/x/_acl')).to partially_match({})
|
306
295
|
end
|
307
296
|
|
308
297
|
it 'Converging chef_acl "" with recursive true changes nodes/x\'s acls' do
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
recursive true
|
314
|
-
end
|
298
|
+
expect_recipe {
|
299
|
+
chef_acl '' do
|
300
|
+
rights :read, users: %w(blarghle)
|
301
|
+
recursive true
|
315
302
|
end
|
316
|
-
}.to
|
303
|
+
}.to be_updated
|
304
|
+
expect(get('/organizations/_acl')).to partially_match('read' => { 'actors' => %w(blarghle) })
|
305
|
+
expect(get('nodes/x/_acl')).to partially_match('read' => { 'actors' => %w(blarghle) })
|
317
306
|
end
|
318
307
|
end
|
319
308
|
end
|
@@ -347,207 +336,192 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
347
336
|
|
348
337
|
context 'relative paths' do
|
349
338
|
it "chef_acl 'nodes/x' changes the acls" do
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
rights :read, :users => 'u'
|
354
|
-
end
|
339
|
+
expect_recipe {
|
340
|
+
chef_acl "nodes/x" do
|
341
|
+
rights :read, users: %w(u)
|
355
342
|
end
|
356
|
-
}.to
|
343
|
+
}.to be_updated
|
344
|
+
expect(get("nodes/x/_acl")).to partially_match('read' => { 'actors' => %w(u) })
|
357
345
|
end
|
358
346
|
|
359
347
|
it "chef_acl '*/*' changes the acls" do
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
rights :read, :users => 'u'
|
364
|
-
end
|
348
|
+
expect_recipe {
|
349
|
+
chef_acl "*/*" do
|
350
|
+
rights :read, users: %w(u)
|
365
351
|
end
|
366
|
-
}.to
|
367
|
-
|
352
|
+
}.to be_updated
|
353
|
+
%w(clients containers cookbooks data environments groups nodes roles).each do |type|
|
354
|
+
expect(get("/organizations/foo/#{type}/x/_acl")).to partially_match(
|
355
|
+
'read' => { 'actors' => %w(u) })
|
356
|
+
end
|
368
357
|
end
|
369
358
|
end
|
370
359
|
|
371
360
|
context 'absolute paths' do
|
372
361
|
%w(clients containers cookbooks data environments groups nodes roles sandboxes).each do |type|
|
373
362
|
it "chef_acl '/organizations/foo/#{type}/x' changes the acl" do
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
rights :read, :users => 'u'
|
378
|
-
end
|
363
|
+
expect_recipe {
|
364
|
+
chef_acl "/organizations/foo/#{type}/x" do
|
365
|
+
rights :read, users: %w(u)
|
379
366
|
end
|
380
|
-
}.to
|
367
|
+
}.to be_updated
|
368
|
+
expect(get("/organizations/foo/#{type}/x/_acl")).to partially_match('read' => { 'actors' => %w(u) })
|
381
369
|
end
|
382
370
|
end
|
383
371
|
|
384
372
|
%w(clients containers cookbooks data environments groups nodes roles sandboxes).each do |type|
|
385
373
|
it "chef_acl '/organizations/foo/#{type}/x' changes the acl" do
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
rights :read, :users => 'u'
|
390
|
-
end
|
374
|
+
expect_recipe {
|
375
|
+
chef_acl "/organizations/foo/#{type}/x" do
|
376
|
+
rights :read, users: %w(u)
|
391
377
|
end
|
392
|
-
}.to
|
378
|
+
}.to be_updated
|
379
|
+
expect(get("/organizations/foo/#{type}/x/_acl")).to partially_match('read' => { 'actors' => %w(u) })
|
393
380
|
end
|
394
381
|
end
|
395
382
|
|
396
383
|
%w(clients containers cookbooks data environments groups nodes roles).each do |type|
|
397
384
|
it "chef_acl '/*/*/#{type}/*' changes the acl" do
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
rights :read, :users => 'u'
|
402
|
-
end
|
385
|
+
expect_recipe {
|
386
|
+
chef_acl "/*/*/#{type}/*" do
|
387
|
+
rights :read, users: %w(u)
|
403
388
|
end
|
404
|
-
}.to
|
389
|
+
}.to be_updated
|
390
|
+
expect(get("/organizations/foo/#{type}/x/_acl")).to partially_match('read' => { 'actors' => %w(u) })
|
405
391
|
end
|
406
392
|
end
|
407
393
|
|
408
394
|
it "chef_acl '/*/*/*/x' changes the acls" do
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
rights :read, :users => 'u'
|
413
|
-
end
|
395
|
+
expect_recipe {
|
396
|
+
chef_acl "/*/*/*/x" do
|
397
|
+
rights :read, users: %w(u)
|
414
398
|
end
|
415
|
-
}.to
|
416
|
-
|
399
|
+
}.to be_updated
|
400
|
+
%w(clients containers cookbooks data environments groups nodes roles sandboxes).each do |type|
|
401
|
+
expect(get("/organizations/foo/#{type}/x/_acl")).to partially_match(
|
402
|
+
'read' => { 'actors' => %w(u) })
|
403
|
+
end
|
417
404
|
end
|
418
405
|
|
419
406
|
it "chef_acl '/*/*/*/*' changes the acls" do
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
rights :read, :users => 'u'
|
424
|
-
end
|
407
|
+
expect_recipe {
|
408
|
+
chef_acl "/*/*/*/*" do
|
409
|
+
rights :read, users: %w(u)
|
425
410
|
end
|
426
|
-
}.to
|
427
|
-
|
411
|
+
}.to be_updated
|
412
|
+
%w(clients containers cookbooks data environments groups nodes roles).each do |type|
|
413
|
+
expect(get("/organizations/foo/#{type}/x/_acl")).to partially_match(
|
414
|
+
'read' => { 'actors' => %w(u) })
|
415
|
+
end
|
428
416
|
end
|
429
417
|
|
430
418
|
it 'chef_acl "/organizations/foo/data_bags/x" changes the acl' do
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
rights :read, :users => 'u'
|
435
|
-
end
|
419
|
+
expect_recipe {
|
420
|
+
chef_acl '/organizations/foo/data_bags/x' do
|
421
|
+
rights :read, users: %w(u)
|
436
422
|
end
|
437
|
-
}.to
|
423
|
+
}.to be_updated
|
424
|
+
expect(get('/organizations/foo/data/x/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
438
425
|
end
|
439
426
|
|
440
427
|
it 'chef_acl "/*/*/data_bags/*" changes the acl' do
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
rights :read, :users => 'u'
|
445
|
-
end
|
428
|
+
expect_recipe {
|
429
|
+
chef_acl '/*/*/data_bags/*' do
|
430
|
+
rights :read, users: %w(u)
|
446
431
|
end
|
447
|
-
}.to
|
432
|
+
}.to be_updated
|
433
|
+
expect(get('/organizations/foo/data/x/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
448
434
|
end
|
449
435
|
|
450
436
|
it "chef_acl '/organizations/foo/cookbooks/x/1.0.0' raises an error" do
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
rights :read, :users => 'u'
|
455
|
-
end
|
437
|
+
expect_converge {
|
438
|
+
chef_acl "/organizations/foo/cookbooks/x/1.0.0" do
|
439
|
+
rights :read, users: %w(u)
|
456
440
|
end
|
457
441
|
}.to raise_error(/ACLs cannot be set on children of \/organizations\/foo\/cookbooks\/x/)
|
458
442
|
end
|
459
443
|
|
460
444
|
it "chef_acl '/organizations/foo/cookbooks/*/*' raises an error" do
|
461
445
|
pending
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
rights :read, :users => 'u'
|
466
|
-
end
|
446
|
+
expect_converge {
|
447
|
+
chef_acl "/organizations/foo/cookbooks/*/*" do
|
448
|
+
rights :read, users: %w(u)
|
467
449
|
end
|
468
450
|
}.to raise_error(/ACLs cannot be set on children of \/organizations\/foo\/cookbooks\/*/)
|
469
451
|
end
|
470
452
|
|
471
453
|
it 'chef_acl "/organizations/foo/data/x/y" raises an error' do
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
rights :read, :users => 'u'
|
476
|
-
end
|
454
|
+
expect_converge {
|
455
|
+
chef_acl '/organizations/foo/data/x/y' do
|
456
|
+
rights :read, users: %w(u)
|
477
457
|
end
|
478
458
|
}.to raise_error(/ACLs cannot be set on children of \/organizations\/foo\/data\/x/)
|
479
459
|
end
|
480
460
|
|
481
461
|
it 'chef_acl "/organizations/foo/data/*/*" raises an error' do
|
482
462
|
pending
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
rights :read, :users => 'u'
|
487
|
-
end
|
463
|
+
expect_converge {
|
464
|
+
chef_acl '/organizations/foo/data/*/*' do
|
465
|
+
rights :read, users: %w(u)
|
488
466
|
end
|
489
467
|
}.to raise_error(/ACLs cannot be set on children of \/organizations\/foo\/data\/*/)
|
490
468
|
end
|
491
469
|
|
492
470
|
it 'chef_acl "/organizations/foo" changes the acl' do
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
rights :read, :users => 'u'
|
497
|
-
end
|
471
|
+
expect_recipe {
|
472
|
+
chef_acl '/organizations/foo' do
|
473
|
+
rights :read, users: %w(u)
|
498
474
|
end
|
499
|
-
}.to
|
475
|
+
}.to be_updated
|
476
|
+
expect(get('/organizations/foo/organizations/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
477
|
+
expect(get('/organizations/foo/nodes/x/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
500
478
|
end
|
501
479
|
|
502
480
|
it 'chef_acl "/organizations/*" changes the acl' do
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
rights :read, :users => 'u'
|
507
|
-
end
|
481
|
+
expect_recipe {
|
482
|
+
chef_acl '/organizations/*' do
|
483
|
+
rights :read, users: %w(u)
|
508
484
|
end
|
509
|
-
}.to
|
485
|
+
}.to be_updated
|
486
|
+
expect(get('/organizations/foo/organizations/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
487
|
+
expect(get('/organizations/foo/nodes/x/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
510
488
|
end
|
511
489
|
|
512
490
|
it 'chef_acl "/users/x" changes the acl' do
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
rights :read, :users => 'u'
|
517
|
-
end
|
491
|
+
expect_recipe {
|
492
|
+
chef_acl '/users/x' do
|
493
|
+
rights :read, users: %w(u)
|
518
494
|
end
|
519
|
-
}.to
|
495
|
+
}.to be_updated
|
496
|
+
expect(get('/users/x/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
520
497
|
end
|
521
498
|
|
522
499
|
it 'chef_acl "/users/*" changes the acl' do
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
rights :read, :users => 'u'
|
527
|
-
end
|
500
|
+
expect_recipe {
|
501
|
+
chef_acl '/users/*' do
|
502
|
+
rights :read, users: %w(u)
|
528
503
|
end
|
529
|
-
}.to
|
504
|
+
}.to be_updated
|
505
|
+
expect(get('/users/x/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
530
506
|
end
|
531
507
|
|
532
508
|
it 'chef_acl "/*/x" changes the acl' do
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
rights :read, :users => 'u'
|
537
|
-
end
|
509
|
+
expect_recipe {
|
510
|
+
chef_acl '/*/x' do
|
511
|
+
rights :read, users: %w(u)
|
538
512
|
end
|
539
|
-
}.to
|
513
|
+
}.to be_updated
|
514
|
+
expect(get('/users/x/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
540
515
|
end
|
541
516
|
|
542
517
|
it 'chef_acl "/*/*" changes the acl' do
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
rights :read, :users => 'u'
|
547
|
-
end
|
518
|
+
expect_recipe {
|
519
|
+
chef_acl '/*/*' do
|
520
|
+
rights :read, users: %w(u)
|
548
521
|
end
|
549
|
-
}.to
|
550
|
-
|
522
|
+
}.to be_updated
|
523
|
+
expect(get('/organizations/foo/organizations/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
524
|
+
expect(get('/users/x/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
551
525
|
end
|
552
526
|
end
|
553
527
|
end
|
@@ -558,14 +532,12 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
558
532
|
end
|
559
533
|
|
560
534
|
it "chef_acl '/organizations/foo/nodes/*' changes the acl" do
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
rights :read, :users => 'u'
|
565
|
-
end
|
535
|
+
expect_recipe {
|
536
|
+
chef_acl "/organizations/foo/nodes/*" do
|
537
|
+
rights :read, users: %w(u)
|
566
538
|
end
|
567
|
-
}.to
|
568
|
-
expect
|
539
|
+
}.to be_updated
|
540
|
+
expect(get("/organizations/foo/nodes/x/_acl")).to partially_match('read' => { 'actors' => %w(u) })
|
569
541
|
end
|
570
542
|
end
|
571
543
|
|
@@ -575,14 +547,12 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
575
547
|
end
|
576
548
|
|
577
549
|
it "chef_acl '/organizations/foo/nodes/*' changes the acl" do
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
rights :read, :users => 'u'
|
582
|
-
end
|
550
|
+
expect_recipe {
|
551
|
+
chef_acl "/organizations/foo/nodes/*" do
|
552
|
+
rights :read, users: %w(u)
|
583
553
|
end
|
584
|
-
}.to
|
585
|
-
expect
|
554
|
+
}.to be_updated
|
555
|
+
expect(get("/organizations/foo/nodes/x/_acl")).to partially_match('read' => { 'actors' => %w(u) })
|
586
556
|
end
|
587
557
|
end
|
588
558
|
end
|
@@ -602,89 +572,88 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
602
572
|
|
603
573
|
%w(clients containers cookbooks data environments groups nodes roles sandboxes).each do |type|
|
604
574
|
it "chef_acl #{type}/x' changes the acl" do
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
rights :read, :users => 'u'
|
609
|
-
end
|
575
|
+
expect_recipe {
|
576
|
+
chef_acl "#{type}/x" do
|
577
|
+
rights :read, users: %w(u)
|
610
578
|
end
|
611
|
-
}.to
|
579
|
+
}.to be_updated
|
580
|
+
expect(get("#{type}/x/_acl")).to partially_match('read' => { 'actors' => %w(u) })
|
612
581
|
end
|
613
582
|
end
|
614
583
|
|
615
584
|
%w(clients containers cookbooks data environments groups nodes roles).each do |type|
|
616
585
|
it "chef_acl '#{type}/*' changes the acl" do
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
rights :read, :users => 'u'
|
621
|
-
end
|
586
|
+
expect_recipe {
|
587
|
+
chef_acl "#{type}/*" do
|
588
|
+
rights :read, users: %w(u)
|
622
589
|
end
|
623
|
-
}.to
|
590
|
+
}.to be_updated
|
591
|
+
expect(get("#{type}/x/_acl")).to partially_match('read' => { 'actors' => %w(u) })
|
624
592
|
end
|
625
593
|
end
|
626
594
|
|
627
595
|
it "chef_acl '*/x' changes the acls" do
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
596
|
+
expect_recipe {
|
597
|
+
chef_acl "*/x" do
|
598
|
+
rights :read, users: %w(u)
|
599
|
+
end
|
600
|
+
}.to be_updated
|
601
|
+
%w(clients containers cookbooks data environments groups nodes roles sandboxes).each do |type|
|
602
|
+
expect(get("#{type}/x/_acl")).to partially_match(
|
603
|
+
'read' => { 'actors' => %w(u) })
|
604
|
+
end
|
636
605
|
end
|
637
606
|
|
638
607
|
it "chef_acl '*/*' changes the acls" do
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
608
|
+
expect_recipe {
|
609
|
+
chef_acl "*/*" do
|
610
|
+
rights :read, users: %w(u)
|
611
|
+
end
|
612
|
+
}.to be_updated
|
613
|
+
%w(clients containers cookbooks data environments groups nodes roles).each do |type|
|
614
|
+
expect(get("#{type}/x/_acl")).to partially_match(
|
615
|
+
'read' => { 'actors' => %w(u) })
|
616
|
+
end
|
647
617
|
end
|
648
618
|
|
649
619
|
it "chef_acl 'groups/*' changes the acl" do
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
620
|
+
expect_recipe {
|
621
|
+
chef_acl "groups/*" do
|
622
|
+
rights :read, users: %w(u)
|
623
|
+
end
|
624
|
+
}.to be_updated
|
625
|
+
%w(admins billing-admins clients users x).each do |n|
|
626
|
+
expect(get("groups/#{n}/_acl")).to partially_match(
|
627
|
+
'read' => { 'actors' => %w(u) })
|
628
|
+
end
|
658
629
|
end
|
659
630
|
|
660
631
|
it 'chef_acl "data_bags/x" changes the acl' do
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
rights :read, :users => 'u'
|
665
|
-
end
|
632
|
+
expect_recipe {
|
633
|
+
chef_acl 'data_bags/x' do
|
634
|
+
rights :read, users: %w(u)
|
666
635
|
end
|
667
|
-
}.to
|
636
|
+
}.to be_updated
|
637
|
+
expect(get('data/x/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
668
638
|
end
|
669
639
|
|
670
640
|
it 'chef_acl "data_bags/*" changes the acl' do
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
rights :read, :users => 'u'
|
675
|
-
end
|
641
|
+
expect_recipe {
|
642
|
+
chef_acl 'data_bags/*' do
|
643
|
+
rights :read, users: %w(u)
|
676
644
|
end
|
677
|
-
}.to
|
645
|
+
}.to be_updated
|
646
|
+
expect(get('data/x/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
678
647
|
end
|
679
648
|
|
680
649
|
it 'chef_acl "" changes the organization acl' do
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
rights :read, :users => 'u'
|
685
|
-
end
|
650
|
+
expect_recipe {
|
651
|
+
chef_acl '' do
|
652
|
+
rights :read, users: %w(u)
|
686
653
|
end
|
687
|
-
}.to
|
654
|
+
}.to be_updated
|
655
|
+
expect(get('/organizations/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
656
|
+
expect(get('nodes/x/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
688
657
|
end
|
689
658
|
end
|
690
659
|
end
|
@@ -707,57 +676,54 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
707
676
|
|
708
677
|
%w(clients containers cookbooks data environments groups nodes roles sandboxes).each do |type|
|
709
678
|
it "chef_acl '/organizations/foo/#{type}' changes the acl" do
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
rights :read, :users => 'u'
|
714
|
-
end
|
679
|
+
expect_recipe {
|
680
|
+
chef_acl "/organizations/foo/#{type}" do
|
681
|
+
rights :read, users: %w(u)
|
715
682
|
end
|
716
|
-
}.to
|
683
|
+
}.to be_updated
|
684
|
+
expect(get("/organizations/foo/containers/#{type}/_acl")).to partially_match('read' => { 'actors' => %w(u) })
|
717
685
|
end
|
718
686
|
end
|
719
687
|
|
720
688
|
%w(clients containers cookbooks data environments groups nodes roles).each do |type|
|
721
689
|
it "chef_acl '/*/*/#{type}' changes the acl" do
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
rights :read, :users => 'u'
|
726
|
-
end
|
690
|
+
expect_recipe {
|
691
|
+
chef_acl "/*/*/#{type}" do
|
692
|
+
rights :read, users: %w(u)
|
727
693
|
end
|
728
|
-
}.to
|
694
|
+
}.to be_updated
|
695
|
+
expect(get("/organizations/foo/containers/#{type}/_acl")).to partially_match('read' => { 'actors' => %w(u) })
|
729
696
|
end
|
730
697
|
end
|
731
698
|
|
732
699
|
it "chef_acl '/*/*/*' changes the acls" do
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
700
|
+
expect_recipe {
|
701
|
+
chef_acl "/*/*/*" do
|
702
|
+
rights :read, users: %w(u)
|
703
|
+
end
|
704
|
+
}.to be_updated
|
705
|
+
%w(clients containers cookbooks data environments groups nodes roles sandboxes).each do |type|
|
706
|
+
expect(get("/organizations/foo/containers/#{type}/_acl")).to partially_match(
|
707
|
+
'read' => { 'actors' => %w(u) })
|
708
|
+
end
|
741
709
|
end
|
742
710
|
|
743
711
|
it 'chef_acl "/organizations/foo/data_bags" changes the acl' do
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
rights :read, :users => 'u'
|
748
|
-
end
|
712
|
+
expect_recipe {
|
713
|
+
chef_acl '/organizations/foo/data_bags' do
|
714
|
+
rights :read, users: %w(u)
|
749
715
|
end
|
750
|
-
}.to
|
716
|
+
}.to be_updated
|
717
|
+
expect(get('/organizations/foo/containers/data/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
751
718
|
end
|
752
719
|
|
753
720
|
it 'chef_acl "/*/*/data_bags" changes the acl' do
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
rights :read, :users => 'u'
|
758
|
-
end
|
721
|
+
expect_recipe {
|
722
|
+
chef_acl '/*/*/data_bags' do
|
723
|
+
rights :read, users: %w(u)
|
759
724
|
end
|
760
|
-
}.to
|
725
|
+
}.to be_updated
|
726
|
+
expect(get('/organizations/foo/containers/data/_acl')).to partially_match('read' => { 'actors' => %w(u) })
|
761
727
|
end
|
762
728
|
end
|
763
729
|
|
@@ -776,25 +742,25 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
776
742
|
|
777
743
|
%w(clients containers cookbooks data environments groups nodes roles sandboxes).each do |type|
|
778
744
|
it "chef_acl #{type}' changes the acl" do
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
rights :read, :users => 'u'
|
783
|
-
end
|
745
|
+
expect_recipe {
|
746
|
+
chef_acl "#{type}" do
|
747
|
+
rights :read, users: %w(u)
|
784
748
|
end
|
785
|
-
}.to
|
749
|
+
}.to be_updated
|
750
|
+
expect(get("containers/#{type}/_acl")).to partially_match('read' => { 'actors' => %w(u) })
|
786
751
|
end
|
787
752
|
end
|
788
753
|
|
789
754
|
it "chef_acl '*' changes the acls" do
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
755
|
+
expect_recipe {
|
756
|
+
chef_acl "*" do
|
757
|
+
rights :read, users: %w(u)
|
758
|
+
end
|
759
|
+
}.to be_updated
|
760
|
+
%w(clients containers cookbooks data environments groups nodes roles sandboxes).each do |type|
|
761
|
+
expect(get("containers/#{type}/_acl")).to partially_match(
|
762
|
+
'read' => { 'actors' => %w(u) })
|
763
|
+
end
|
798
764
|
end
|
799
765
|
end
|
800
766
|
end
|
@@ -814,53 +780,54 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
814
780
|
end
|
815
781
|
|
816
782
|
it 'chef_acl with remove_rights "u" removes the user\'s rights' do
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
remove_rights :read, :users => 'u'
|
821
|
-
end
|
783
|
+
expect_recipe {
|
784
|
+
chef_acl "nodes/x" do
|
785
|
+
remove_rights :read, users: %w(u)
|
822
786
|
end
|
823
|
-
}.to
|
787
|
+
}.to be_updated
|
788
|
+
expect(get("nodes/x/_acl")).to partially_match('read' => { 'actors' => exclude('u') })
|
824
789
|
end
|
825
790
|
|
826
791
|
it 'chef_acl with remove_rights "c" removes the client\'s rights' do
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
remove_rights :read, :clients => 'c'
|
831
|
-
end
|
792
|
+
expect_recipe {
|
793
|
+
chef_acl "nodes/x" do
|
794
|
+
remove_rights :read, clients: %w(c)
|
832
795
|
end
|
833
|
-
}.to
|
796
|
+
}.to be_updated
|
797
|
+
expect(get("nodes/x/_acl")).to partially_match('read' => { 'actors' => exclude('c') })
|
834
798
|
end
|
835
799
|
|
836
800
|
it 'chef_acl with remove_rights "g" removes the group\'s rights' do
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
remove_rights :read, :groups => 'g'
|
841
|
-
end
|
801
|
+
expect_recipe {
|
802
|
+
chef_acl "nodes/x" do
|
803
|
+
remove_rights :read, groups: %w(g)
|
842
804
|
end
|
843
|
-
}.to
|
805
|
+
}.to be_updated
|
806
|
+
expect(get("nodes/x/_acl")).to partially_match(
|
807
|
+
'read' => { 'groups' => exclude('g') }
|
808
|
+
)
|
844
809
|
end
|
845
810
|
|
846
811
|
it 'chef_acl with remove_rights [ :create, :read ], "u", "c", "g" removes all three' do
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
812
|
+
expect_recipe {
|
813
|
+
chef_acl "nodes/x" do
|
814
|
+
remove_rights [ :create, :read ], users: %w(u), clients: %w(c), groups: %w(g)
|
815
|
+
end
|
816
|
+
}.to be_updated
|
817
|
+
expect(get("nodes/x/_acl")).to partially_match(
|
818
|
+
'create' => { 'actors' => exclude('u').and(exclude('c')), 'groups' => exclude('g') },
|
819
|
+
'read' => { 'actors' => exclude('u').and(exclude('c')), 'groups' => exclude('g') }
|
820
|
+
)
|
854
821
|
end
|
855
822
|
|
856
823
|
it 'chef_acl with remove_rights "u2", "c2", "g2" has no effect' do
|
857
824
|
expect {
|
858
|
-
|
825
|
+
expect_recipe {
|
859
826
|
chef_acl "nodes/x" do
|
860
|
-
remove_rights :read, :
|
827
|
+
remove_rights :read, users: %w(u2), clients: %w(c2), groups: %w(g2)
|
861
828
|
end
|
862
|
-
|
863
|
-
}.
|
829
|
+
}.to be_up_to_date
|
830
|
+
}.not_to change { get("nodes/x/_acl") }
|
864
831
|
end
|
865
832
|
end
|
866
833
|
end
|
@@ -870,13 +837,12 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
870
837
|
node 'data_bags', {}
|
871
838
|
|
872
839
|
it 'Converging chef_acl "nodes/data_bags" with user "blarghle" adds the user' do
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
rights :read, :users => 'blarghle'
|
877
|
-
end
|
840
|
+
expect_recipe {
|
841
|
+
chef_acl 'nodes/data_bags' do
|
842
|
+
rights :read, users: %w(blarghle)
|
878
843
|
end
|
879
|
-
}.to
|
844
|
+
}.to be_updated
|
845
|
+
expect(get('nodes/data_bags/_acl')).to partially_match('read' => { 'actors' => %w(blarghle) })
|
880
846
|
end
|
881
847
|
end
|
882
848
|
|
@@ -887,13 +853,12 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
887
853
|
end
|
888
854
|
|
889
855
|
it 'Converging chef_acl "/organizations/foo/nodes/data_bags" with user "blarghle" adds the user' do
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
rights :read, :users => 'blarghle'
|
894
|
-
end
|
856
|
+
expect_recipe {
|
857
|
+
chef_acl '/organizations/foo/nodes/data_bags' do
|
858
|
+
rights :read, users: %w(blarghle)
|
895
859
|
end
|
896
|
-
}.to
|
860
|
+
}.to be_updated
|
861
|
+
expect(get('/organizations/foo/nodes/data_bags/_acl')).to partially_match('read' => { 'actors' => %w(blarghle) })
|
897
862
|
end
|
898
863
|
end
|
899
864
|
|
@@ -902,13 +867,12 @@ if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
|
902
867
|
user 'blarghle', {}
|
903
868
|
|
904
869
|
it 'Converging chef_acl "/users/data_bags" with user "blarghle" adds the user' do
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
rights :read, :users => 'blarghle'
|
909
|
-
end
|
870
|
+
expect_recipe {
|
871
|
+
chef_acl '/users/data_bags' do
|
872
|
+
rights :read, users: %w(blarghle)
|
910
873
|
end
|
911
|
-
}.to
|
874
|
+
}.to be_updated
|
875
|
+
expect(get('/users/data_bags/_acl')).to partially_match('read' => { 'actors' => %w(blarghle) })
|
912
876
|
end
|
913
877
|
end
|
914
878
|
end
|