cheffish 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +8 -8
- data/Rakefile +24 -12
- data/cheffish.gemspec +15 -15
- data/lib/chef/resource/chef_acl.rb +63 -63
- data/lib/chef/resource/chef_client.rb +9 -9
- data/lib/chef/resource/chef_container.rb +9 -9
- data/lib/chef/resource/chef_data_bag.rb +9 -9
- data/lib/chef/resource/chef_data_bag_item.rb +27 -27
- data/lib/chef/resource/chef_environment.rb +21 -22
- data/lib/chef/resource/chef_group.rb +19 -19
- data/lib/chef/resource/chef_mirror.rb +32 -17
- data/lib/chef/resource/chef_node.rb +14 -14
- data/lib/chef/resource/chef_organization.rb +29 -30
- data/lib/chef/resource/chef_resolved_cookbooks.rb +7 -7
- data/lib/chef/resource/chef_role.rb +25 -22
- data/lib/chef/resource/chef_user.rb +13 -14
- data/lib/chef/resource/private_key.rb +24 -25
- data/lib/chef/resource/public_key.rb +6 -7
- data/lib/cheffish.rb +17 -17
- data/lib/cheffish/array_property.rb +2 -2
- data/lib/cheffish/base_properties.rb +3 -3
- data/lib/cheffish/base_resource.rb +8 -8
- data/lib/cheffish/basic_chef_client.rb +17 -17
- data/lib/cheffish/chef_actor_base.rb +8 -8
- data/lib/cheffish/chef_run.rb +7 -2
- data/lib/cheffish/chef_run_data.rb +2 -2
- data/lib/cheffish/chef_run_listener.rb +1 -1
- data/lib/cheffish/key_formatter.rb +16 -18
- data/lib/cheffish/merged_config.rb +5 -3
- data/lib/cheffish/node_properties.rb +11 -7
- data/lib/cheffish/recipe_dsl.rb +33 -34
- data/lib/cheffish/rspec.rb +3 -3
- data/lib/cheffish/rspec/chef_run_support.rb +13 -13
- data/lib/cheffish/rspec/matchers.rb +4 -4
- data/lib/cheffish/rspec/matchers/be_idempotent.rb +3 -3
- data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +3 -3
- data/lib/cheffish/rspec/matchers/have_updated.rb +3 -3
- data/lib/cheffish/rspec/recipe_run_wrapper.rb +8 -7
- data/lib/cheffish/rspec/repository_support.rb +6 -6
- data/lib/cheffish/server_api.rb +11 -11
- data/lib/cheffish/version.rb +1 -1
- data/spec/functional/fingerprint_spec.rb +12 -12
- data/spec/functional/merged_config_spec.rb +46 -6
- data/spec/functional/server_api_spec.rb +3 -3
- data/spec/integration/chef_acl_spec.rb +489 -489
- data/spec/integration/chef_client_spec.rb +39 -39
- data/spec/integration/chef_container_spec.rb +14 -14
- data/spec/integration/chef_data_bag_item_spec.rb +9 -9
- data/spec/integration/chef_group_spec.rb +219 -219
- data/spec/integration/chef_mirror_spec.rb +228 -228
- data/spec/integration/chef_node_spec.rb +511 -511
- data/spec/integration/chef_organization_spec.rb +126 -126
- data/spec/integration/chef_role_spec.rb +33 -33
- data/spec/integration/chef_user_spec.rb +37 -37
- data/spec/integration/private_key_spec.rb +154 -154
- data/spec/integration/recipe_dsl_spec.rb +10 -10
- data/spec/integration/rspec/converge_spec.rb +49 -49
- data/spec/support/key_support.rb +6 -6
- data/spec/support/spec_support.rb +3 -3
- data/spec/unit/get_private_key_spec.rb +19 -19
- data/spec/unit/recipe_run_wrapper_spec.rb +4 -4
- metadata +3 -3
@@ -1,50 +1,50 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "support/spec_support"
|
2
|
+
require "cheffish/rspec/chef_run_support"
|
3
|
+
require "support/key_support"
|
4
|
+
require "chef/resource/chef_client"
|
5
5
|
|
6
|
-
repo_path = Dir.mktmpdir(
|
6
|
+
repo_path = Dir.mktmpdir("chef_repo")
|
7
7
|
|
8
8
|
describe Chef::Resource::ChefClient do
|
9
9
|
extend Cheffish::RSpec::ChefRunSupport
|
10
10
|
|
11
|
-
when_the_chef_12_server
|
12
|
-
organization
|
11
|
+
when_the_chef_12_server "is in multi-org mode" do
|
12
|
+
organization "foo"
|
13
13
|
|
14
14
|
before :each do
|
15
|
-
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url,
|
15
|
+
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo").to_s
|
16
16
|
end
|
17
17
|
|
18
|
-
context
|
19
|
-
context
|
18
|
+
context "and is empty" do
|
19
|
+
context "and we have a private key with a path" do
|
20
20
|
with_converge do
|
21
21
|
private_key "#{repo_path}/blah.pem"
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'and we run a recipe that creates client "blah"' do
|
25
|
-
it
|
26
|
-
expect_recipe
|
27
|
-
chef_client
|
25
|
+
it "the client gets created" do
|
26
|
+
expect_recipe do
|
27
|
+
chef_client "blah" do
|
28
28
|
source_key_path "#{repo_path}/blah.pem"
|
29
29
|
end
|
30
|
-
|
31
|
-
client = get(
|
32
|
-
expect(client[
|
33
|
-
key, format = Cheffish::KeyFormatter.decode(client[
|
30
|
+
end.to have_updated "chef_client[blah]", :create
|
31
|
+
client = get("clients/blah")
|
32
|
+
expect(client["name"]).to eq("blah")
|
33
|
+
key, format = Cheffish::KeyFormatter.decode(client["public_key"])
|
34
34
|
expect(key).to be_public_key_for("#{repo_path}/blah.pem")
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
context 'and we run a recipe that creates client "blah" with output_key_path' do
|
39
39
|
with_converge do
|
40
|
-
chef_client
|
40
|
+
chef_client "blah" do
|
41
41
|
source_key_path "#{repo_path}/blah.pem"
|
42
42
|
output_key_path "#{repo_path}/blah.pub"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
47
|
-
expect(IO.read("#{repo_path}/blah.pub")).to start_with(
|
46
|
+
it "the output public key gets created" do
|
47
|
+
expect(IO.read("#{repo_path}/blah.pub")).to start_with("ssh-rsa ")
|
48
48
|
expect("#{repo_path}/blah.pub").to be_public_key_for("#{repo_path}/blah.pem")
|
49
49
|
end
|
50
50
|
end
|
@@ -56,21 +56,21 @@ describe Chef::Resource::ChefClient do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
with_converge do
|
59
|
-
private_key
|
59
|
+
private_key "blah"
|
60
60
|
end
|
61
61
|
|
62
62
|
context "and a chef_client 'foobar' resource with source_key_path 'blah'" do
|
63
|
-
it
|
64
|
-
expect_recipe
|
65
|
-
chef_client
|
66
|
-
source_key_path
|
63
|
+
it "the client is accessible via the given private key" do
|
64
|
+
expect_recipe do
|
65
|
+
chef_client "foobar" do
|
66
|
+
source_key_path "blah"
|
67
67
|
end
|
68
|
-
|
69
|
-
client = get(
|
70
|
-
key, format = Cheffish::KeyFormatter.decode(client[
|
68
|
+
end.to have_updated "chef_client[foobar]", :create
|
69
|
+
client = get("clients/foobar")
|
70
|
+
key, format = Cheffish::KeyFormatter.decode(client["public_key"])
|
71
71
|
expect(key).to be_public_key_for("#{repo_path}/blah.pem")
|
72
72
|
|
73
|
-
private_key = Cheffish::KeyFormatter.decode(Cheffish.get_private_key(
|
73
|
+
private_key = Cheffish::KeyFormatter.decode(Cheffish.get_private_key("blah"))
|
74
74
|
expect(key).to be_public_key_for(private_key)
|
75
75
|
end
|
76
76
|
end
|
@@ -78,23 +78,23 @@ describe Chef::Resource::ChefClient do
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
when_the_chef_server
|
82
|
-
context
|
83
|
-
context
|
81
|
+
when_the_chef_server "is in OSC mode" do
|
82
|
+
context "and is empty" do
|
83
|
+
context "and we have a private key with a path" do
|
84
84
|
with_converge do
|
85
85
|
private_key "#{repo_path}/blah.pem"
|
86
86
|
end
|
87
87
|
|
88
88
|
context 'and we run a recipe that creates client "blah"' do
|
89
|
-
it
|
90
|
-
expect_recipe
|
91
|
-
chef_client
|
89
|
+
it "the client gets created" do
|
90
|
+
expect_recipe do
|
91
|
+
chef_client "blah" do
|
92
92
|
source_key_path "#{repo_path}/blah.pem"
|
93
93
|
end
|
94
|
-
|
95
|
-
client = get(
|
96
|
-
expect(client[
|
97
|
-
key, format = Cheffish::KeyFormatter.decode(client[
|
94
|
+
end.to have_updated "chef_client[blah]", :create
|
95
|
+
client = get("clients/blah")
|
96
|
+
expect(client["name"]).to eq("blah")
|
97
|
+
key, format = Cheffish::KeyFormatter.decode(client["public_key"])
|
98
98
|
expect(key).to be_public_key_for("#{repo_path}/blah.pem")
|
99
99
|
end
|
100
100
|
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "support/spec_support"
|
2
|
+
require "cheffish/rspec/chef_run_support"
|
3
3
|
|
4
4
|
describe Chef::Resource::ChefContainer do
|
5
5
|
extend Cheffish::RSpec::ChefRunSupport
|
6
6
|
|
7
|
-
when_the_chef_12_server
|
8
|
-
organization
|
7
|
+
when_the_chef_12_server "is in multi-org mode" do
|
8
|
+
organization "foo"
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url,
|
11
|
+
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo").to_s
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'Converging chef_container "x" creates the container' do
|
15
|
-
expect_recipe
|
16
|
-
chef_container
|
17
|
-
|
18
|
-
expect { get(
|
15
|
+
expect_recipe do
|
16
|
+
chef_container "x"
|
17
|
+
end.to have_updated("chef_container[x]", :create)
|
18
|
+
expect { get("containers/x") }.not_to raise_error
|
19
19
|
end
|
20
20
|
|
21
|
-
context
|
22
|
-
container
|
21
|
+
context "and already has a container named x" do
|
22
|
+
container "x", {}
|
23
23
|
|
24
24
|
it 'Converging chef_container "x" changes nothing' do
|
25
|
-
expect_recipe
|
26
|
-
chef_container
|
27
|
-
|
25
|
+
expect_recipe do
|
26
|
+
chef_container "x"
|
27
|
+
end.not_to have_updated("chef_container[x]", :create)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "support/spec_support"
|
2
|
+
require "cheffish/rspec/chef_run_support"
|
3
3
|
|
4
4
|
describe Chef::Resource::ChefDataBagItem do
|
5
5
|
extend Cheffish::RSpec::ChefRunSupport
|
6
6
|
|
7
|
-
when_the_chef_12_server
|
8
|
-
organization
|
7
|
+
when_the_chef_12_server "foo" do
|
8
|
+
organization "foo"
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url,
|
11
|
+
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo").to_s
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'when data bag "bag" exists' do
|
15
|
-
with_converge { chef_data_bag
|
15
|
+
with_converge { chef_data_bag "bag" }
|
16
16
|
|
17
17
|
it 'runs a recipe that creates a chef_data_bag_item "bag/item"' do
|
18
|
-
expect_recipe
|
19
|
-
chef_data_bag_item
|
20
|
-
|
18
|
+
expect_recipe do
|
19
|
+
chef_data_bag_item "bag/item"
|
20
|
+
end.to have_updated "chef_data_bag_item[bag/item]", :create
|
21
21
|
# expect(get('data_bags/bag')['name']).to eq('bag')
|
22
22
|
# expect(get('data_bags/bag/item')['id']).to eq('item')
|
23
23
|
end
|
@@ -1,305 +1,305 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "support/spec_support"
|
2
|
+
require "cheffish/rspec/chef_run_support"
|
3
3
|
|
4
4
|
describe Chef::Resource::ChefGroup do
|
5
5
|
extend Cheffish::RSpec::ChefRunSupport
|
6
6
|
|
7
|
-
when_the_chef_12_server
|
8
|
-
organization
|
7
|
+
when_the_chef_12_server "is in multi-org mode" do
|
8
|
+
organization "foo"
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url,
|
11
|
+
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo").to_s
|
12
12
|
end
|
13
13
|
|
14
|
-
context
|
15
|
-
group
|
16
|
-
user
|
17
|
-
client
|
14
|
+
context "and is empty" do
|
15
|
+
group "g", {}
|
16
|
+
user "u", {}
|
17
|
+
client "c", {}
|
18
18
|
|
19
19
|
it 'Converging chef_group "x" creates the group with no members' do
|
20
|
-
expect_recipe
|
21
|
-
chef_group
|
22
|
-
|
23
|
-
expect(get(
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
20
|
+
expect_recipe do
|
21
|
+
chef_group "x"
|
22
|
+
end.to have_updated("chef_group[x]", :create)
|
23
|
+
expect(get("groups/x")).to eq({
|
24
|
+
"name" => "x",
|
25
|
+
"groupname" => "x",
|
26
|
+
"orgname" => "foo",
|
27
|
+
"actors" => [],
|
28
|
+
"groups" => [],
|
29
|
+
"users" => [],
|
30
|
+
"clients" => [],
|
31
31
|
})
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'chef_group "x" action :delete does nothing' do
|
35
|
-
expect_recipe
|
36
|
-
chef_group
|
35
|
+
expect_recipe do
|
36
|
+
chef_group "x" do
|
37
37
|
action :delete
|
38
38
|
end
|
39
|
-
|
40
|
-
expect { get(
|
39
|
+
end.to not_have_updated("chef_group[x]", :delete).and not_have_updated("chef_group[x]", :create)
|
40
|
+
expect { get("groups/x") }.to raise_error(Net::HTTPServerException)
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'Converging chef_group "x" creates the group with the given members' do
|
44
|
-
expect_recipe
|
45
|
-
chef_group
|
46
|
-
groups
|
47
|
-
users
|
48
|
-
clients
|
44
|
+
expect_recipe do
|
45
|
+
chef_group "x" do
|
46
|
+
groups "g"
|
47
|
+
users "u"
|
48
|
+
clients "c"
|
49
49
|
end
|
50
|
-
|
51
|
-
expect(get(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
end.to have_updated("chef_group[x]", :create)
|
51
|
+
expect(get("groups/x")).to eq({
|
52
|
+
"name" => "x",
|
53
|
+
"groupname" => "x",
|
54
|
+
"orgname" => "foo",
|
55
|
+
"actors" => %w{c u},
|
56
|
+
"groups" => %w{g},
|
57
|
+
"users" => %w{u},
|
58
|
+
"clients" => %w{c},
|
59
59
|
})
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
context
|
64
|
-
group
|
65
|
-
group
|
66
|
-
group
|
67
|
-
group
|
68
|
-
user
|
69
|
-
user
|
70
|
-
user
|
71
|
-
user
|
72
|
-
client
|
73
|
-
client
|
74
|
-
client
|
75
|
-
client
|
63
|
+
context "and has a group named x" do
|
64
|
+
group "g", {}
|
65
|
+
group "g2", {}
|
66
|
+
group "g3", {}
|
67
|
+
group "g4", {}
|
68
|
+
user "u", {}
|
69
|
+
user "u2", {}
|
70
|
+
user "u3", {}
|
71
|
+
user "u4", {}
|
72
|
+
client "c", {}
|
73
|
+
client "c2", {}
|
74
|
+
client "c3", {}
|
75
|
+
client "c4", {}
|
76
76
|
|
77
|
-
group
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
group "x", {
|
78
|
+
"users" => %w{u u2},
|
79
|
+
"clients" => %w{c c2},
|
80
|
+
"groups" => %w{g g2},
|
81
81
|
}
|
82
82
|
|
83
83
|
it 'Converging chef_group "x" changes nothing' do
|
84
|
-
expect_recipe
|
85
|
-
chef_group
|
86
|
-
|
87
|
-
expect(get(
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
84
|
+
expect_recipe do
|
85
|
+
chef_group "x"
|
86
|
+
end.not_to have_updated("chef_group[x]", :create)
|
87
|
+
expect(get("groups/x")).to eq({
|
88
|
+
"name" => "x",
|
89
|
+
"groupname" => "x",
|
90
|
+
"orgname" => "foo",
|
91
|
+
"actors" => %w{c c2 u u2},
|
92
|
+
"groups" => %w{g g2},
|
93
|
+
"users" => %w{u u2},
|
94
|
+
"clients" => %w{c c2},
|
95
95
|
})
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'chef_group "x" action :delete deletes the group' do
|
99
|
-
expect_recipe
|
100
|
-
chef_group
|
99
|
+
expect_recipe do
|
100
|
+
chef_group "x" do
|
101
101
|
action :delete
|
102
102
|
end
|
103
|
-
|
104
|
-
expect { get(
|
103
|
+
end.to have_updated("chef_group[x]", :delete)
|
104
|
+
expect { get("groups/x") }.to raise_error(Net::HTTPServerException)
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'Converging chef_group "x" with existing users changes nothing' do
|
108
|
-
expect_recipe
|
109
|
-
chef_group
|
110
|
-
users
|
111
|
-
clients
|
112
|
-
groups
|
108
|
+
expect_recipe do
|
109
|
+
chef_group "x" do
|
110
|
+
users "u"
|
111
|
+
clients "c"
|
112
|
+
groups "g"
|
113
113
|
end
|
114
|
-
|
115
|
-
expect(get(
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
114
|
+
end.not_to have_updated("chef_group[x]", :create)
|
115
|
+
expect(get("groups/x")).to eq({
|
116
|
+
"name" => "x",
|
117
|
+
"groupname" => "x",
|
118
|
+
"orgname" => "foo",
|
119
|
+
"actors" => %w{c c2 u u2},
|
120
|
+
"groups" => %w{g g2},
|
121
|
+
"users" => %w{u u2},
|
122
|
+
"clients" => %w{c c2},
|
123
123
|
})
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'Converging chef_group "x" adds new users' do
|
127
|
-
expect_recipe
|
128
|
-
chef_group
|
129
|
-
users
|
130
|
-
clients
|
131
|
-
groups
|
127
|
+
expect_recipe do
|
128
|
+
chef_group "x" do
|
129
|
+
users "u3"
|
130
|
+
clients "c3"
|
131
|
+
groups "g3"
|
132
132
|
end
|
133
|
-
|
134
|
-
expect(get(
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
133
|
+
end.to have_updated("chef_group[x]", :create)
|
134
|
+
expect(get("groups/x")).to eq({
|
135
|
+
"name" => "x",
|
136
|
+
"groupname" => "x",
|
137
|
+
"orgname" => "foo",
|
138
|
+
"actors" => %w{c c2 c3 u u2 u3},
|
139
|
+
"groups" => %w{g g2 g3},
|
140
|
+
"users" => %w{u u2 u3},
|
141
|
+
"clients" => %w{c c2 c3},
|
142
142
|
})
|
143
143
|
end
|
144
144
|
|
145
145
|
it 'Converging chef_group "x" with multiple users adds new users' do
|
146
|
-
expect_recipe
|
147
|
-
chef_group
|
148
|
-
users
|
149
|
-
clients
|
150
|
-
groups
|
146
|
+
expect_recipe do
|
147
|
+
chef_group "x" do
|
148
|
+
users "u3", "u4"
|
149
|
+
clients "c3", "c4"
|
150
|
+
groups "g3", "g4"
|
151
151
|
end
|
152
|
-
|
153
|
-
expect(get(
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
152
|
+
end.to have_updated("chef_group[x]", :create)
|
153
|
+
expect(get("groups/x")).to eq({
|
154
|
+
"name" => "x",
|
155
|
+
"groupname" => "x",
|
156
|
+
"orgname" => "foo",
|
157
|
+
"actors" => %w{c c2 c3 c4 u u2 u3 u4},
|
158
|
+
"groups" => %w{g g2 g3 g4},
|
159
|
+
"users" => %w{u u2 u3 u4},
|
160
|
+
"clients" => %w{c c2 c3 c4},
|
161
161
|
})
|
162
162
|
end
|
163
163
|
|
164
164
|
it 'Converging chef_group "x" with multiple users in an array adds new users' do
|
165
|
-
expect_recipe
|
166
|
-
chef_group
|
167
|
-
users
|
168
|
-
clients
|
169
|
-
groups
|
165
|
+
expect_recipe do
|
166
|
+
chef_group "x" do
|
167
|
+
users %w{u3 u4}
|
168
|
+
clients %w{c3 c4}
|
169
|
+
groups %w{g3 g4}
|
170
170
|
end
|
171
|
-
|
172
|
-
expect(get(
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
171
|
+
end.to have_updated("chef_group[x]", :create)
|
172
|
+
expect(get("groups/x")).to eq({
|
173
|
+
"name" => "x",
|
174
|
+
"groupname" => "x",
|
175
|
+
"orgname" => "foo",
|
176
|
+
"actors" => %w{c c2 c3 c4 u u2 u3 u4},
|
177
|
+
"groups" => %w{g g2 g3 g4},
|
178
|
+
"users" => %w{u u2 u3 u4},
|
179
|
+
"clients" => %w{c c2 c3 c4},
|
180
180
|
})
|
181
181
|
end
|
182
182
|
|
183
183
|
it 'Converging chef_group "x" with multiple users declarations adds new users' do
|
184
|
-
expect_recipe
|
185
|
-
chef_group
|
186
|
-
users
|
187
|
-
users
|
188
|
-
clients
|
189
|
-
clients
|
190
|
-
groups
|
191
|
-
groups
|
184
|
+
expect_recipe do
|
185
|
+
chef_group "x" do
|
186
|
+
users "u3"
|
187
|
+
users "u4"
|
188
|
+
clients "c3"
|
189
|
+
clients "c4"
|
190
|
+
groups "g3"
|
191
|
+
groups "g4"
|
192
192
|
end
|
193
|
-
|
194
|
-
expect(get(
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
193
|
+
end.to have_updated("chef_group[x]", :create)
|
194
|
+
expect(get("groups/x")).to eq({
|
195
|
+
"name" => "x",
|
196
|
+
"groupname" => "x",
|
197
|
+
"orgname" => "foo",
|
198
|
+
"actors" => %w{c c2 c3 c4 u u2 u3 u4},
|
199
|
+
"groups" => %w{g g2 g3 g4},
|
200
|
+
"users" => %w{u u2 u3 u4},
|
201
|
+
"clients" => %w{c c2 c3 c4},
|
202
202
|
})
|
203
203
|
end
|
204
204
|
|
205
205
|
it 'Converging chef_group "x" removes desired users' do
|
206
|
-
expect_recipe
|
207
|
-
chef_group
|
208
|
-
remove_users
|
209
|
-
remove_clients
|
210
|
-
remove_groups
|
206
|
+
expect_recipe do
|
207
|
+
chef_group "x" do
|
208
|
+
remove_users "u2"
|
209
|
+
remove_clients "c2"
|
210
|
+
remove_groups "g2"
|
211
211
|
end
|
212
|
-
|
213
|
-
expect(get(
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
212
|
+
end.to have_updated("chef_group[x]", :create)
|
213
|
+
expect(get("groups/x")).to eq({
|
214
|
+
"name" => "x",
|
215
|
+
"groupname" => "x",
|
216
|
+
"orgname" => "foo",
|
217
|
+
"actors" => %w{c u},
|
218
|
+
"groups" => %w{g},
|
219
|
+
"users" => %w{u},
|
220
|
+
"clients" => %w{c},
|
221
221
|
})
|
222
222
|
end
|
223
223
|
|
224
224
|
it 'Converging chef_group "x" with multiple users removes desired users' do
|
225
|
-
expect_recipe
|
226
|
-
chef_group
|
227
|
-
remove_users
|
228
|
-
remove_clients
|
229
|
-
remove_groups
|
225
|
+
expect_recipe do
|
226
|
+
chef_group "x" do
|
227
|
+
remove_users "u", "u2"
|
228
|
+
remove_clients "c", "c2"
|
229
|
+
remove_groups "g", "g2"
|
230
230
|
end
|
231
|
-
|
232
|
-
expect(get(
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
231
|
+
end.to have_updated("chef_group[x]", :create)
|
232
|
+
expect(get("groups/x")).to eq({
|
233
|
+
"name" => "x",
|
234
|
+
"groupname" => "x",
|
235
|
+
"orgname" => "foo",
|
236
|
+
"actors" => [],
|
237
|
+
"groups" => [],
|
238
|
+
"users" => [],
|
239
|
+
"clients" => [],
|
240
240
|
})
|
241
241
|
end
|
242
242
|
|
243
243
|
it 'Converging chef_group "x" with multiple users in an array removes desired users' do
|
244
|
-
expect_recipe
|
245
|
-
chef_group
|
246
|
-
remove_users
|
247
|
-
remove_clients
|
248
|
-
remove_groups
|
244
|
+
expect_recipe do
|
245
|
+
chef_group "x" do
|
246
|
+
remove_users %w{u u2}
|
247
|
+
remove_clients %w{c c2}
|
248
|
+
remove_groups %w{g g2}
|
249
249
|
end
|
250
|
-
|
251
|
-
expect(get(
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
250
|
+
end.to have_updated("chef_group[x]", :create)
|
251
|
+
expect(get("groups/x")).to eq({
|
252
|
+
"name" => "x",
|
253
|
+
"groupname" => "x",
|
254
|
+
"orgname" => "foo",
|
255
|
+
"actors" => [],
|
256
|
+
"groups" => [],
|
257
|
+
"users" => [],
|
258
|
+
"clients" => [],
|
259
259
|
})
|
260
260
|
end
|
261
261
|
|
262
262
|
it 'Converging chef_group "x" with multiple remove_ declarations removes desired users' do
|
263
|
-
expect_recipe
|
264
|
-
chef_group
|
265
|
-
remove_users
|
266
|
-
remove_users
|
267
|
-
remove_clients
|
268
|
-
remove_clients
|
269
|
-
remove_groups
|
270
|
-
remove_groups
|
263
|
+
expect_recipe do
|
264
|
+
chef_group "x" do
|
265
|
+
remove_users "u"
|
266
|
+
remove_users "u2"
|
267
|
+
remove_clients "c"
|
268
|
+
remove_clients "c2"
|
269
|
+
remove_groups "g"
|
270
|
+
remove_groups "g2"
|
271
271
|
end
|
272
|
-
|
273
|
-
expect(get(
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
272
|
+
end.to have_updated("chef_group[x]", :create)
|
273
|
+
expect(get("groups/x")).to eq({
|
274
|
+
"name" => "x",
|
275
|
+
"groupname" => "x",
|
276
|
+
"orgname" => "foo",
|
277
|
+
"actors" => [],
|
278
|
+
"groups" => [],
|
279
|
+
"users" => [],
|
280
|
+
"clients" => [],
|
281
281
|
})
|
282
282
|
end
|
283
283
|
|
284
284
|
it 'Converging chef_group "x" adds and removes desired users' do
|
285
|
-
expect_recipe
|
286
|
-
chef_group
|
287
|
-
users
|
288
|
-
clients
|
289
|
-
groups
|
290
|
-
remove_users
|
291
|
-
remove_clients
|
292
|
-
remove_groups
|
285
|
+
expect_recipe do
|
286
|
+
chef_group "x" do
|
287
|
+
users "u3"
|
288
|
+
clients "c3"
|
289
|
+
groups "g3"
|
290
|
+
remove_users "u"
|
291
|
+
remove_clients "c"
|
292
|
+
remove_groups "g"
|
293
293
|
end
|
294
|
-
|
295
|
-
expect(get(
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
294
|
+
end.to have_updated("chef_group[x]", :create)
|
295
|
+
expect(get("groups/x")).to eq({
|
296
|
+
"name" => "x",
|
297
|
+
"groupname" => "x",
|
298
|
+
"orgname" => "foo",
|
299
|
+
"actors" => %w{c2 c3 u2 u3},
|
300
|
+
"groups" => %w{g2 g3},
|
301
|
+
"users" => %w{u2 u3},
|
302
|
+
"clients" => %w{c2 c3},
|
303
303
|
})
|
304
304
|
end
|
305
305
|
end
|