cheffish 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -201
  3. data/README.md +120 -120
  4. data/Rakefile +23 -23
  5. data/lib/chef/provider/chef_acl.rb +439 -439
  6. data/lib/chef/provider/chef_client.rb +53 -53
  7. data/lib/chef/provider/chef_container.rb +55 -55
  8. data/lib/chef/provider/chef_data_bag.rb +55 -55
  9. data/lib/chef/provider/chef_data_bag_item.rb +278 -278
  10. data/lib/chef/provider/chef_environment.rb +83 -83
  11. data/lib/chef/provider/chef_group.rb +83 -83
  12. data/lib/chef/provider/chef_mirror.rb +169 -169
  13. data/lib/chef/provider/chef_node.rb +87 -87
  14. data/lib/chef/provider/chef_organization.rb +155 -155
  15. data/lib/chef/provider/chef_resolved_cookbooks.rb +46 -46
  16. data/lib/chef/provider/chef_role.rb +84 -84
  17. data/lib/chef/provider/chef_user.rb +59 -59
  18. data/lib/chef/provider/private_key.rb +225 -225
  19. data/lib/chef/provider/public_key.rb +88 -88
  20. data/lib/chef/resource/chef_acl.rb +69 -69
  21. data/lib/chef/resource/chef_client.rb +48 -48
  22. data/lib/chef/resource/chef_container.rb +22 -22
  23. data/lib/chef/resource/chef_data_bag.rb +22 -22
  24. data/lib/chef/resource/chef_data_bag_item.rb +121 -121
  25. data/lib/chef/resource/chef_environment.rb +77 -77
  26. data/lib/chef/resource/chef_group.rb +53 -53
  27. data/lib/chef/resource/chef_mirror.rb +52 -52
  28. data/lib/chef/resource/chef_node.rb +22 -22
  29. data/lib/chef/resource/chef_organization.rb +69 -69
  30. data/lib/chef/resource/chef_resolved_cookbooks.rb +35 -35
  31. data/lib/chef/resource/chef_role.rb +110 -110
  32. data/lib/chef/resource/chef_user.rb +56 -56
  33. data/lib/chef/resource/private_key.rb +48 -48
  34. data/lib/chef/resource/public_key.rb +25 -25
  35. data/lib/cheffish/actor_provider_base.rb +131 -131
  36. data/lib/cheffish/basic_chef_client.rb +184 -184
  37. data/lib/cheffish/chef_provider_base.rb +246 -246
  38. data/lib/cheffish/chef_run.rb +162 -162
  39. data/lib/cheffish/chef_run_data.rb +19 -19
  40. data/lib/cheffish/chef_run_listener.rb +30 -30
  41. data/lib/cheffish/key_formatter.rb +113 -113
  42. data/lib/cheffish/merged_config.rb +94 -94
  43. data/lib/cheffish/recipe_dsl.rb +157 -157
  44. data/lib/cheffish/rspec/chef_run_support.rb +83 -83
  45. data/lib/cheffish/rspec/matchers/be_idempotent.rb +16 -16
  46. data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +15 -15
  47. data/lib/cheffish/rspec/matchers/have_updated.rb +37 -37
  48. data/lib/cheffish/rspec/matchers/partially_match.rb +63 -63
  49. data/lib/cheffish/rspec/matchers.rb +4 -4
  50. data/lib/cheffish/rspec/recipe_run_wrapper.rb +78 -59
  51. data/lib/cheffish/rspec/repository_support.rb +108 -108
  52. data/lib/cheffish/rspec.rb +8 -8
  53. data/lib/cheffish/server_api.rb +52 -52
  54. data/lib/cheffish/version.rb +3 -3
  55. data/lib/cheffish/with_pattern.rb +21 -21
  56. data/lib/cheffish.rb +235 -235
  57. data/spec/functional/fingerprint_spec.rb +64 -64
  58. data/spec/functional/merged_config_spec.rb +19 -19
  59. data/spec/functional/server_api_spec.rb +13 -13
  60. data/spec/integration/chef_acl_spec.rb +879 -879
  61. data/spec/integration/chef_client_spec.rb +105 -105
  62. data/spec/integration/chef_container_spec.rb +33 -33
  63. data/spec/integration/chef_group_spec.rb +309 -309
  64. data/spec/integration/chef_mirror_spec.rb +491 -491
  65. data/spec/integration/chef_node_spec.rb +786 -786
  66. data/spec/integration/chef_organization_spec.rb +226 -226
  67. data/spec/integration/chef_role_spec.rb +78 -78
  68. data/spec/integration/chef_user_spec.rb +85 -85
  69. data/spec/integration/private_key_spec.rb +399 -399
  70. data/spec/integration/recipe_dsl_spec.rb +28 -28
  71. data/spec/integration/rspec/converge_spec.rb +183 -183
  72. data/spec/support/key_support.rb +29 -29
  73. data/spec/support/spec_support.rb +15 -15
  74. data/spec/unit/get_private_key_spec.rb +131 -131
  75. data/spec/unit/recipe_run_wrapper_spec.rb +37 -37
  76. metadata +3 -2
@@ -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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheffish
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
@@ -167,8 +167,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  version: '0'
168
168
  requirements: []
169
169
  rubyforge_project:
170
- rubygems_version: 2.2.2
170
+ rubygems_version: 2.2.3
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: A library to manipulate Chef in Chef.
174
174
  test_files: []
175
+ has_rdoc: