cheffish 1.4.1 → 1.4.2
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/LICENSE +201 -201
- data/README.md +120 -120
- data/Rakefile +23 -23
- data/lib/chef/provider/chef_acl.rb +439 -439
- data/lib/chef/provider/chef_client.rb +53 -53
- data/lib/chef/provider/chef_container.rb +55 -55
- data/lib/chef/provider/chef_data_bag.rb +55 -55
- data/lib/chef/provider/chef_data_bag_item.rb +278 -278
- data/lib/chef/provider/chef_environment.rb +83 -83
- data/lib/chef/provider/chef_group.rb +83 -83
- data/lib/chef/provider/chef_mirror.rb +169 -169
- data/lib/chef/provider/chef_node.rb +87 -87
- data/lib/chef/provider/chef_organization.rb +155 -155
- data/lib/chef/provider/chef_resolved_cookbooks.rb +46 -46
- data/lib/chef/provider/chef_role.rb +84 -84
- data/lib/chef/provider/chef_user.rb +59 -59
- data/lib/chef/provider/private_key.rb +225 -225
- data/lib/chef/provider/public_key.rb +88 -88
- data/lib/chef/resource/chef_acl.rb +69 -69
- data/lib/chef/resource/chef_client.rb +48 -48
- data/lib/chef/resource/chef_container.rb +22 -22
- data/lib/chef/resource/chef_data_bag.rb +22 -22
- data/lib/chef/resource/chef_data_bag_item.rb +121 -121
- data/lib/chef/resource/chef_environment.rb +77 -77
- data/lib/chef/resource/chef_group.rb +53 -53
- data/lib/chef/resource/chef_mirror.rb +52 -52
- data/lib/chef/resource/chef_node.rb +22 -22
- data/lib/chef/resource/chef_organization.rb +69 -69
- data/lib/chef/resource/chef_resolved_cookbooks.rb +35 -35
- data/lib/chef/resource/chef_role.rb +110 -110
- data/lib/chef/resource/chef_user.rb +56 -56
- data/lib/chef/resource/private_key.rb +48 -48
- data/lib/chef/resource/public_key.rb +25 -25
- data/lib/cheffish/actor_provider_base.rb +131 -131
- data/lib/cheffish/basic_chef_client.rb +184 -184
- data/lib/cheffish/chef_provider_base.rb +246 -246
- data/lib/cheffish/chef_run.rb +162 -162
- data/lib/cheffish/chef_run_data.rb +19 -19
- data/lib/cheffish/chef_run_listener.rb +30 -30
- data/lib/cheffish/key_formatter.rb +113 -113
- data/lib/cheffish/merged_config.rb +94 -94
- data/lib/cheffish/recipe_dsl.rb +157 -157
- data/lib/cheffish/rspec/chef_run_support.rb +83 -83
- data/lib/cheffish/rspec/matchers/be_idempotent.rb +16 -16
- data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +15 -15
- data/lib/cheffish/rspec/matchers/have_updated.rb +37 -37
- data/lib/cheffish/rspec/matchers/partially_match.rb +63 -63
- data/lib/cheffish/rspec/matchers.rb +4 -4
- data/lib/cheffish/rspec/recipe_run_wrapper.rb +78 -59
- data/lib/cheffish/rspec/repository_support.rb +108 -108
- data/lib/cheffish/rspec.rb +8 -8
- data/lib/cheffish/server_api.rb +52 -52
- data/lib/cheffish/version.rb +3 -3
- data/lib/cheffish/with_pattern.rb +21 -21
- data/lib/cheffish.rb +235 -235
- data/spec/functional/fingerprint_spec.rb +64 -64
- data/spec/functional/merged_config_spec.rb +19 -19
- data/spec/functional/server_api_spec.rb +13 -13
- data/spec/integration/chef_acl_spec.rb +879 -879
- data/spec/integration/chef_client_spec.rb +105 -105
- data/spec/integration/chef_container_spec.rb +33 -33
- data/spec/integration/chef_group_spec.rb +309 -309
- data/spec/integration/chef_mirror_spec.rb +491 -491
- data/spec/integration/chef_node_spec.rb +786 -786
- data/spec/integration/chef_organization_spec.rb +226 -226
- data/spec/integration/chef_role_spec.rb +78 -78
- data/spec/integration/chef_user_spec.rb +85 -85
- data/spec/integration/private_key_spec.rb +399 -399
- data/spec/integration/recipe_dsl_spec.rb +28 -28
- data/spec/integration/rspec/converge_spec.rb +183 -183
- data/spec/support/key_support.rb +29 -29
- data/spec/support/spec_support.rb +15 -15
- data/spec/unit/get_private_key_spec.rb +131 -131
- data/spec/unit/recipe_run_wrapper_spec.rb +37 -37
- metadata +3 -2
@@ -1,105 +1,105 @@
|
|
1
|
-
require 'support/spec_support'
|
2
|
-
require 'cheffish/rspec/chef_run_support'
|
3
|
-
require 'support/key_support'
|
4
|
-
require 'chef/resource/chef_client'
|
5
|
-
require 'chef/provider/chef_client'
|
6
|
-
|
7
|
-
repo_path = Dir.mktmpdir('chef_repo')
|
8
|
-
|
9
|
-
describe Chef::Resource::ChefClient do
|
10
|
-
extend Cheffish::RSpec::ChefRunSupport
|
11
|
-
|
12
|
-
when_the_chef_12_server 'is in multi-org mode' do
|
13
|
-
organization 'foo'
|
14
|
-
|
15
|
-
before :each do
|
16
|
-
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'and is empty' do
|
20
|
-
context 'and we have a private key with a path' do
|
21
|
-
with_converge do
|
22
|
-
private_key "#{repo_path}/blah.pem"
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'and we run a recipe that creates client "blah"' do
|
26
|
-
it 'the client gets created' do
|
27
|
-
expect_recipe {
|
28
|
-
chef_client 'blah' do
|
29
|
-
source_key_path "#{repo_path}/blah.pem"
|
30
|
-
end
|
31
|
-
}.to have_updated 'chef_client[blah]', :create
|
32
|
-
client = get('clients/blah')
|
33
|
-
expect(client['name']).to eq('blah')
|
34
|
-
key, format = Cheffish::KeyFormatter.decode(client['public_key'])
|
35
|
-
expect(key).to be_public_key_for("#{repo_path}/blah.pem")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'and we run a recipe that creates client "blah" with output_key_path' do
|
40
|
-
with_converge do
|
41
|
-
chef_client 'blah' do
|
42
|
-
source_key_path "#{repo_path}/blah.pem"
|
43
|
-
output_key_path "#{repo_path}/blah.pub"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'the output public key gets created' do
|
48
|
-
expect(IO.read("#{repo_path}/blah.pub")).to start_with('ssh-rsa ')
|
49
|
-
expect("#{repo_path}/blah.pub").to be_public_key_for("#{repo_path}/blah.pem")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "and a private_key 'blah' resource" do
|
55
|
-
before :each do
|
56
|
-
Chef::Config.private_key_paths = [ repo_path ]
|
57
|
-
end
|
58
|
-
|
59
|
-
with_converge do
|
60
|
-
private_key 'blah'
|
61
|
-
end
|
62
|
-
|
63
|
-
context "and a chef_client 'foobar' resource with source_key_path 'blah'" do
|
64
|
-
it 'the client is accessible via the given private key' do
|
65
|
-
expect_recipe {
|
66
|
-
chef_client 'foobar' do
|
67
|
-
source_key_path 'blah'
|
68
|
-
end
|
69
|
-
}.to have_updated 'chef_client[foobar]', :create
|
70
|
-
client = get('clients/foobar')
|
71
|
-
key, format = Cheffish::KeyFormatter.decode(client['public_key'])
|
72
|
-
expect(key).to be_public_key_for("#{repo_path}/blah.pem")
|
73
|
-
|
74
|
-
private_key = Cheffish::KeyFormatter.decode(Cheffish.get_private_key('blah'))
|
75
|
-
expect(key).to be_public_key_for(private_key)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
when_the_chef_server 'is in OSC mode' do
|
83
|
-
context 'and is empty' do
|
84
|
-
context 'and we have a private key with a path' do
|
85
|
-
with_converge do
|
86
|
-
private_key "#{repo_path}/blah.pem"
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'and we run a recipe that creates client "blah"' do
|
90
|
-
it 'the client gets created' do
|
91
|
-
expect_recipe {
|
92
|
-
chef_client 'blah' do
|
93
|
-
source_key_path "#{repo_path}/blah.pem"
|
94
|
-
end
|
95
|
-
}.to have_updated 'chef_client[blah]', :create
|
96
|
-
client = get('clients/blah')
|
97
|
-
expect(client['name']).to eq('blah')
|
98
|
-
key, format = Cheffish::KeyFormatter.decode(client['public_key'])
|
99
|
-
expect(key).to be_public_key_for("#{repo_path}/blah.pem")
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
1
|
+
require 'support/spec_support'
|
2
|
+
require 'cheffish/rspec/chef_run_support'
|
3
|
+
require 'support/key_support'
|
4
|
+
require 'chef/resource/chef_client'
|
5
|
+
require 'chef/provider/chef_client'
|
6
|
+
|
7
|
+
repo_path = Dir.mktmpdir('chef_repo')
|
8
|
+
|
9
|
+
describe Chef::Resource::ChefClient do
|
10
|
+
extend Cheffish::RSpec::ChefRunSupport
|
11
|
+
|
12
|
+
when_the_chef_12_server 'is in multi-org mode' do
|
13
|
+
organization 'foo'
|
14
|
+
|
15
|
+
before :each do
|
16
|
+
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'and is empty' do
|
20
|
+
context 'and we have a private key with a path' do
|
21
|
+
with_converge do
|
22
|
+
private_key "#{repo_path}/blah.pem"
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'and we run a recipe that creates client "blah"' do
|
26
|
+
it 'the client gets created' do
|
27
|
+
expect_recipe {
|
28
|
+
chef_client 'blah' do
|
29
|
+
source_key_path "#{repo_path}/blah.pem"
|
30
|
+
end
|
31
|
+
}.to have_updated 'chef_client[blah]', :create
|
32
|
+
client = get('clients/blah')
|
33
|
+
expect(client['name']).to eq('blah')
|
34
|
+
key, format = Cheffish::KeyFormatter.decode(client['public_key'])
|
35
|
+
expect(key).to be_public_key_for("#{repo_path}/blah.pem")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'and we run a recipe that creates client "blah" with output_key_path' do
|
40
|
+
with_converge do
|
41
|
+
chef_client 'blah' do
|
42
|
+
source_key_path "#{repo_path}/blah.pem"
|
43
|
+
output_key_path "#{repo_path}/blah.pub"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'the output public key gets created' do
|
48
|
+
expect(IO.read("#{repo_path}/blah.pub")).to start_with('ssh-rsa ')
|
49
|
+
expect("#{repo_path}/blah.pub").to be_public_key_for("#{repo_path}/blah.pem")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "and a private_key 'blah' resource" do
|
55
|
+
before :each do
|
56
|
+
Chef::Config.private_key_paths = [ repo_path ]
|
57
|
+
end
|
58
|
+
|
59
|
+
with_converge do
|
60
|
+
private_key 'blah'
|
61
|
+
end
|
62
|
+
|
63
|
+
context "and a chef_client 'foobar' resource with source_key_path 'blah'" do
|
64
|
+
it 'the client is accessible via the given private key' do
|
65
|
+
expect_recipe {
|
66
|
+
chef_client 'foobar' do
|
67
|
+
source_key_path 'blah'
|
68
|
+
end
|
69
|
+
}.to have_updated 'chef_client[foobar]', :create
|
70
|
+
client = get('clients/foobar')
|
71
|
+
key, format = Cheffish::KeyFormatter.decode(client['public_key'])
|
72
|
+
expect(key).to be_public_key_for("#{repo_path}/blah.pem")
|
73
|
+
|
74
|
+
private_key = Cheffish::KeyFormatter.decode(Cheffish.get_private_key('blah'))
|
75
|
+
expect(key).to be_public_key_for(private_key)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
when_the_chef_server 'is in OSC mode' do
|
83
|
+
context 'and is empty' do
|
84
|
+
context 'and we have a private key with a path' do
|
85
|
+
with_converge do
|
86
|
+
private_key "#{repo_path}/blah.pem"
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'and we run a recipe that creates client "blah"' do
|
90
|
+
it 'the client gets created' do
|
91
|
+
expect_recipe {
|
92
|
+
chef_client 'blah' do
|
93
|
+
source_key_path "#{repo_path}/blah.pem"
|
94
|
+
end
|
95
|
+
}.to have_updated 'chef_client[blah]', :create
|
96
|
+
client = get('clients/blah')
|
97
|
+
expect(client['name']).to eq('blah')
|
98
|
+
key, format = Cheffish::KeyFormatter.decode(client['public_key'])
|
99
|
+
expect(key).to be_public_key_for("#{repo_path}/blah.pem")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -1,33 +1,33 @@
|
|
1
|
-
require 'support/spec_support'
|
2
|
-
require 'cheffish/rspec/chef_run_support'
|
3
|
-
require 'chef/resource/chef_container'
|
4
|
-
require 'chef/provider/chef_container'
|
5
|
-
|
6
|
-
describe Chef::Resource::ChefContainer do
|
7
|
-
extend Cheffish::RSpec::ChefRunSupport
|
8
|
-
|
9
|
-
when_the_chef_12_server 'is in multi-org mode' do
|
10
|
-
organization 'foo'
|
11
|
-
|
12
|
-
before :each do
|
13
|
-
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'Converging chef_container "x" creates the container' do
|
17
|
-
expect_recipe {
|
18
|
-
chef_container 'x'
|
19
|
-
}.to have_updated('chef_container[x]', :create)
|
20
|
-
expect { get('containers/x') }.not_to raise_error
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'and already has a container named x' do
|
24
|
-
container 'x', {}
|
25
|
-
|
26
|
-
it 'Converging chef_container "x" changes nothing' do
|
27
|
-
expect_recipe {
|
28
|
-
chef_container 'x'
|
29
|
-
}.not_to have_updated('chef_container[x]', :create)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
1
|
+
require 'support/spec_support'
|
2
|
+
require 'cheffish/rspec/chef_run_support'
|
3
|
+
require 'chef/resource/chef_container'
|
4
|
+
require 'chef/provider/chef_container'
|
5
|
+
|
6
|
+
describe Chef::Resource::ChefContainer do
|
7
|
+
extend Cheffish::RSpec::ChefRunSupport
|
8
|
+
|
9
|
+
when_the_chef_12_server 'is in multi-org mode' do
|
10
|
+
organization 'foo'
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'Converging chef_container "x" creates the container' do
|
17
|
+
expect_recipe {
|
18
|
+
chef_container 'x'
|
19
|
+
}.to have_updated('chef_container[x]', :create)
|
20
|
+
expect { get('containers/x') }.not_to raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'and already has a container named x' do
|
24
|
+
container 'x', {}
|
25
|
+
|
26
|
+
it 'Converging chef_container "x" changes nothing' do
|
27
|
+
expect_recipe {
|
28
|
+
chef_container 'x'
|
29
|
+
}.not_to have_updated('chef_container[x]', :create)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|