cheffish 1.5.0 → 1.6.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 +10 -0
- data/LICENSE +201 -201
- data/README.md +120 -120
- data/Rakefile +23 -23
- data/cheffish.gemspec +26 -0
- data/lib/chef/provider/chef_acl.rb +446 -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.rb +235 -235
- 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 +98 -94
- data/lib/cheffish/recipe_dsl.rb +157 -157
- data/lib/cheffish/rspec.rb +8 -8
- data/lib/cheffish/rspec/chef_run_support.rb +83 -83
- data/lib/cheffish/rspec/matchers.rb +4 -4
- 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/recipe_run_wrapper.rb +78 -78
- data/lib/cheffish/rspec/repository_support.rb +108 -108
- data/lib/cheffish/server_api.rb +52 -52
- data/lib/cheffish/version.rb +3 -3
- data/lib/cheffish/with_pattern.rb +21 -21
- 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 +892 -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 +7 -5
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'cheffish/rspec'
|
2
|
-
|
3
|
-
require 'cheffish'
|
4
|
-
require 'chef/provider/chef_acl'
|
5
|
-
|
6
|
-
RSpec.configure do |config|
|
7
|
-
config.filter_run :focus => true
|
8
|
-
config.run_all_when_everything_filtered = true
|
9
|
-
|
10
|
-
config.before :each do
|
11
|
-
Chef::Config.reset
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
require 'chef/providers'
|
1
|
+
require 'cheffish/rspec'
|
2
|
+
|
3
|
+
require 'cheffish'
|
4
|
+
require 'chef/provider/chef_acl'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.filter_run :focus => true
|
8
|
+
config.run_all_when_everything_filtered = true
|
9
|
+
|
10
|
+
config.before :each do
|
11
|
+
Chef::Config.reset
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'chef/providers'
|
@@ -1,131 +1,131 @@
|
|
1
|
-
require 'support/spec_support'
|
2
|
-
require 'cheffish/rspec/chef_run_support'
|
3
|
-
|
4
|
-
describe Cheffish do
|
5
|
-
let(:directory_that_exists) {
|
6
|
-
Dir.mktmpdir("cheffish-rspec")
|
7
|
-
}
|
8
|
-
|
9
|
-
let(:directory_that_does_not_exist) {
|
10
|
-
dir = Dir.mktmpdir("cheffish-rspec")
|
11
|
-
FileUtils.remove_entry dir
|
12
|
-
dir
|
13
|
-
}
|
14
|
-
|
15
|
-
let(:private_key_contents) { "contents of private key" }
|
16
|
-
|
17
|
-
let(:private_key_pem_contents) { "contents of private key pem" }
|
18
|
-
|
19
|
-
let(:private_key_garbage_contents) { "da vinci virus" }
|
20
|
-
|
21
|
-
def setup_key
|
22
|
-
key_file = File.expand_path("ned_stark", directory_that_exists)
|
23
|
-
File.open(key_file, "w+") do |f|
|
24
|
-
f.write private_key_contents
|
25
|
-
end
|
26
|
-
key_file
|
27
|
-
end
|
28
|
-
|
29
|
-
def setup_pem_key
|
30
|
-
key_file = File.expand_path("ned_stark.pem", directory_that_exists)
|
31
|
-
File.open(key_file, "w+") do |f|
|
32
|
-
f.write private_key_pem_contents
|
33
|
-
end
|
34
|
-
key_file
|
35
|
-
end
|
36
|
-
|
37
|
-
def setup_garbage_key
|
38
|
-
key_file = File.expand_path("ned_stark.pem.bak", directory_that_exists)
|
39
|
-
File.open(key_file, "w+") do |f|
|
40
|
-
f.write private_key_garbage_contents
|
41
|
-
end
|
42
|
-
key_file
|
43
|
-
end
|
44
|
-
|
45
|
-
shared_examples_for "returning the contents of the key file if it finds one" do
|
46
|
-
it "returns nil if it cannot find the private key file" do
|
47
|
-
expect(Cheffish.get_private_key("ned_stark", config)).to be_nil
|
48
|
-
end
|
49
|
-
|
50
|
-
it "returns the contents of the key if it doesn't have an extension" do
|
51
|
-
setup_key
|
52
|
-
expect(Cheffish.get_private_key("ned_stark", config)).to eq(private_key_contents)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "returns the contents of the key if it has an extension" do
|
56
|
-
setup_pem_key
|
57
|
-
expect(Cheffish.get_private_key("ned_stark", config)).to eq(private_key_pem_contents)
|
58
|
-
end
|
59
|
-
|
60
|
-
# we arbitrarily prefer "ned_stark" over "ned_stark.pem" for deterministic behavior
|
61
|
-
it "returns the contents of the key that does not have an extension if both exist" do
|
62
|
-
setup_key
|
63
|
-
setup_pem_key
|
64
|
-
expect(Cheffish.get_private_key("ned_stark", config)).to eq(private_key_contents)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "#get_private_key" do
|
69
|
-
context "when private_key_paths has a directory which is empty" do
|
70
|
-
let(:config) {
|
71
|
-
{ :private_key_paths => [ directory_that_exists ] }
|
72
|
-
}
|
73
|
-
|
74
|
-
it_behaves_like "returning the contents of the key file if it finds one"
|
75
|
-
|
76
|
-
context "when it also has a garbage file" do
|
77
|
-
before { setup_garbage_key }
|
78
|
-
|
79
|
-
it "does not return the da vinci virus if we find only the garbage file" do
|
80
|
-
setup_garbage_key
|
81
|
-
expect(Cheffish.get_private_key("ned_stark", config)).to be_nil
|
82
|
-
end
|
83
|
-
|
84
|
-
it_behaves_like "returning the contents of the key file if it finds one"
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
context "when private_key_paths leads with a directory that does not exist and then an empty directory" do
|
90
|
-
let(:config) {
|
91
|
-
{ :private_key_paths => [ directory_that_does_not_exist, directory_that_exists ] }
|
92
|
-
}
|
93
|
-
|
94
|
-
it_behaves_like "returning the contents of the key file if it finds one"
|
95
|
-
end
|
96
|
-
|
97
|
-
context "when private_keys is empty" do
|
98
|
-
let(:config) {
|
99
|
-
{ :private_keys => {} }
|
100
|
-
}
|
101
|
-
|
102
|
-
it "returns nil" do
|
103
|
-
expect(Cheffish.get_private_key("ned_stark", config)).to be_nil
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context "when private_keys contains the path to a key" do
|
108
|
-
let(:name) { "ned_stark" }
|
109
|
-
let(:config) {
|
110
|
-
{ :private_keys => {name => setup_key} }
|
111
|
-
}
|
112
|
-
|
113
|
-
it "returns the contents of the key file" do
|
114
|
-
setup_key
|
115
|
-
expect(Cheffish.get_private_key(name, config)).to eq(private_key_contents)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
context "when private_keys contains the path to a key" do
|
120
|
-
let(:name) { "ned_stark" }
|
121
|
-
let(:key) {double("key", :to_pem => private_key_contents)}
|
122
|
-
let(:config) {
|
123
|
-
{ :private_keys => {name => key} }
|
124
|
-
}
|
125
|
-
|
126
|
-
it "returns the contents of the key file" do
|
127
|
-
expect(Cheffish.get_private_key(name, config)).to eq(private_key_contents)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
1
|
+
require 'support/spec_support'
|
2
|
+
require 'cheffish/rspec/chef_run_support'
|
3
|
+
|
4
|
+
describe Cheffish do
|
5
|
+
let(:directory_that_exists) {
|
6
|
+
Dir.mktmpdir("cheffish-rspec")
|
7
|
+
}
|
8
|
+
|
9
|
+
let(:directory_that_does_not_exist) {
|
10
|
+
dir = Dir.mktmpdir("cheffish-rspec")
|
11
|
+
FileUtils.remove_entry dir
|
12
|
+
dir
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:private_key_contents) { "contents of private key" }
|
16
|
+
|
17
|
+
let(:private_key_pem_contents) { "contents of private key pem" }
|
18
|
+
|
19
|
+
let(:private_key_garbage_contents) { "da vinci virus" }
|
20
|
+
|
21
|
+
def setup_key
|
22
|
+
key_file = File.expand_path("ned_stark", directory_that_exists)
|
23
|
+
File.open(key_file, "w+") do |f|
|
24
|
+
f.write private_key_contents
|
25
|
+
end
|
26
|
+
key_file
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup_pem_key
|
30
|
+
key_file = File.expand_path("ned_stark.pem", directory_that_exists)
|
31
|
+
File.open(key_file, "w+") do |f|
|
32
|
+
f.write private_key_pem_contents
|
33
|
+
end
|
34
|
+
key_file
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup_garbage_key
|
38
|
+
key_file = File.expand_path("ned_stark.pem.bak", directory_that_exists)
|
39
|
+
File.open(key_file, "w+") do |f|
|
40
|
+
f.write private_key_garbage_contents
|
41
|
+
end
|
42
|
+
key_file
|
43
|
+
end
|
44
|
+
|
45
|
+
shared_examples_for "returning the contents of the key file if it finds one" do
|
46
|
+
it "returns nil if it cannot find the private key file" do
|
47
|
+
expect(Cheffish.get_private_key("ned_stark", config)).to be_nil
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns the contents of the key if it doesn't have an extension" do
|
51
|
+
setup_key
|
52
|
+
expect(Cheffish.get_private_key("ned_stark", config)).to eq(private_key_contents)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns the contents of the key if it has an extension" do
|
56
|
+
setup_pem_key
|
57
|
+
expect(Cheffish.get_private_key("ned_stark", config)).to eq(private_key_pem_contents)
|
58
|
+
end
|
59
|
+
|
60
|
+
# we arbitrarily prefer "ned_stark" over "ned_stark.pem" for deterministic behavior
|
61
|
+
it "returns the contents of the key that does not have an extension if both exist" do
|
62
|
+
setup_key
|
63
|
+
setup_pem_key
|
64
|
+
expect(Cheffish.get_private_key("ned_stark", config)).to eq(private_key_contents)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#get_private_key" do
|
69
|
+
context "when private_key_paths has a directory which is empty" do
|
70
|
+
let(:config) {
|
71
|
+
{ :private_key_paths => [ directory_that_exists ] }
|
72
|
+
}
|
73
|
+
|
74
|
+
it_behaves_like "returning the contents of the key file if it finds one"
|
75
|
+
|
76
|
+
context "when it also has a garbage file" do
|
77
|
+
before { setup_garbage_key }
|
78
|
+
|
79
|
+
it "does not return the da vinci virus if we find only the garbage file" do
|
80
|
+
setup_garbage_key
|
81
|
+
expect(Cheffish.get_private_key("ned_stark", config)).to be_nil
|
82
|
+
end
|
83
|
+
|
84
|
+
it_behaves_like "returning the contents of the key file if it finds one"
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
context "when private_key_paths leads with a directory that does not exist and then an empty directory" do
|
90
|
+
let(:config) {
|
91
|
+
{ :private_key_paths => [ directory_that_does_not_exist, directory_that_exists ] }
|
92
|
+
}
|
93
|
+
|
94
|
+
it_behaves_like "returning the contents of the key file if it finds one"
|
95
|
+
end
|
96
|
+
|
97
|
+
context "when private_keys is empty" do
|
98
|
+
let(:config) {
|
99
|
+
{ :private_keys => {} }
|
100
|
+
}
|
101
|
+
|
102
|
+
it "returns nil" do
|
103
|
+
expect(Cheffish.get_private_key("ned_stark", config)).to be_nil
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "when private_keys contains the path to a key" do
|
108
|
+
let(:name) { "ned_stark" }
|
109
|
+
let(:config) {
|
110
|
+
{ :private_keys => {name => setup_key} }
|
111
|
+
}
|
112
|
+
|
113
|
+
it "returns the contents of the key file" do
|
114
|
+
setup_key
|
115
|
+
expect(Cheffish.get_private_key(name, config)).to eq(private_key_contents)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "when private_keys contains the path to a key" do
|
120
|
+
let(:name) { "ned_stark" }
|
121
|
+
let(:key) {double("key", :to_pem => private_key_contents)}
|
122
|
+
let(:config) {
|
123
|
+
{ :private_keys => {name => key} }
|
124
|
+
}
|
125
|
+
|
126
|
+
it "returns the contents of the key file" do
|
127
|
+
expect(Cheffish.get_private_key(name, config)).to eq(private_key_contents)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -1,37 +1,37 @@
|
|
1
|
-
require 'support/spec_support'
|
2
|
-
require 'cheffish/rspec/chef_run_support'
|
3
|
-
# require 'cheffish/rspec/recipe_run_wrapper'
|
4
|
-
|
5
|
-
module MyModule
|
6
|
-
def respond_to_missing?(name, *args)
|
7
|
-
if name == :allowable_method
|
8
|
-
true
|
9
|
-
else
|
10
|
-
false
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe Cheffish::RSpec::RecipeRunWrapper do
|
16
|
-
extend Cheffish::RSpec::ChefRunSupport
|
17
|
-
|
18
|
-
let(:run_wrapper) {
|
19
|
-
Cheffish::RSpec::RecipeRunWrapper.new(chef_config) do
|
20
|
-
log "test recipe in specs"
|
21
|
-
end
|
22
|
-
}
|
23
|
-
|
24
|
-
context "defines #respond_to_missing? on the client" do
|
25
|
-
it "calls the new super.respond_to_missing" do
|
26
|
-
run_wrapper.client.extend MyModule
|
27
|
-
expect(run_wrapper.client.respond_to?(:allowable_method)).to be_truthy
|
28
|
-
expect(run_wrapper.client.respond_to?(:not_an_allowable_method)).to be_falsey
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "does not define #respond_to_missing? on the client" do
|
33
|
-
it "calls the original super.respond_to_missing" do
|
34
|
-
expect(run_wrapper.client.respond_to?(:nonexistent_method)).to be_falsey
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
1
|
+
require 'support/spec_support'
|
2
|
+
require 'cheffish/rspec/chef_run_support'
|
3
|
+
# require 'cheffish/rspec/recipe_run_wrapper'
|
4
|
+
|
5
|
+
module MyModule
|
6
|
+
def respond_to_missing?(name, *args)
|
7
|
+
if name == :allowable_method
|
8
|
+
true
|
9
|
+
else
|
10
|
+
false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe Cheffish::RSpec::RecipeRunWrapper do
|
16
|
+
extend Cheffish::RSpec::ChefRunSupport
|
17
|
+
|
18
|
+
let(:run_wrapper) {
|
19
|
+
Cheffish::RSpec::RecipeRunWrapper.new(chef_config) do
|
20
|
+
log "test recipe in specs"
|
21
|
+
end
|
22
|
+
}
|
23
|
+
|
24
|
+
context "defines #respond_to_missing? on the client" do
|
25
|
+
it "calls the new super.respond_to_missing" do
|
26
|
+
run_wrapper.client.extend MyModule
|
27
|
+
expect(run_wrapper.client.respond_to?(:allowable_method)).to be_truthy
|
28
|
+
expect(run_wrapper.client.respond_to?(:not_an_allowable_method)).to be_falsey
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "does not define #respond_to_missing? on the client" do
|
33
|
+
it "calls the original super.respond_to_missing" do
|
34
|
+
expect(run_wrapper.client.respond_to?(:nonexistent_method)).to be_falsey
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheffish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Keiser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-zero
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '4.
|
19
|
+
version: '4.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '4.
|
26
|
+
version: '4.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: chef
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,9 +74,11 @@ extra_rdoc_files:
|
|
74
74
|
- README.md
|
75
75
|
- LICENSE
|
76
76
|
files:
|
77
|
+
- Gemfile
|
77
78
|
- LICENSE
|
78
79
|
- README.md
|
79
80
|
- Rakefile
|
81
|
+
- cheffish.gemspec
|
80
82
|
- lib/chef/provider/chef_acl.rb
|
81
83
|
- lib/chef/provider/chef_client.rb
|
82
84
|
- lib/chef/provider/chef_container.rb
|
@@ -167,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
169
|
version: '0'
|
168
170
|
requirements: []
|
169
171
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.4.
|
172
|
+
rubygems_version: 2.4.7
|
171
173
|
signing_key:
|
172
174
|
specification_version: 4
|
173
175
|
summary: A library to manipulate Chef in Chef.
|