chef 12.11.18-universal-mingw32 → 12.12.13-universal-mingw32

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.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/Rakefile +3 -2
  4. data/VERSION +1 -1
  5. data/acceptance/Gemfile.lock +22 -23
  6. data/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb +2 -41
  7. data/lib/chef/application/solo.rb +7 -0
  8. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
  9. data/lib/chef/data_collector.rb +79 -43
  10. data/lib/chef/data_collector/messages.rb +4 -33
  11. data/lib/chef/data_collector/messages/helpers.rb +2 -2
  12. data/lib/chef/data_collector/resource_report.rb +21 -11
  13. data/lib/chef/decorator/unchain.rb +43 -0
  14. data/lib/chef/exceptions.rb +5 -0
  15. data/lib/chef/http.rb +5 -5
  16. data/lib/chef/knife/cookbook_create.rb +4 -0
  17. data/lib/chef/knife/cookbook_site_download.rb +8 -1
  18. data/lib/chef/knife/cookbook_site_install.rb +8 -0
  19. data/lib/chef/knife/cookbook_site_list.rb +8 -1
  20. data/lib/chef/knife/cookbook_site_search.rb +8 -1
  21. data/lib/chef/knife/cookbook_site_share.rb +8 -1
  22. data/lib/chef/knife/cookbook_site_show.rb +14 -3
  23. data/lib/chef/knife/cookbook_site_unshare.rb +8 -1
  24. data/lib/chef/knife/core/bootstrap_context.rb +1 -1
  25. data/lib/chef/knife/supermarket_download.rb +33 -0
  26. data/lib/chef/knife/supermarket_install.rb +33 -0
  27. data/lib/chef/knife/supermarket_list.rb +33 -0
  28. data/lib/chef/knife/supermarket_search.rb +33 -0
  29. data/lib/chef/knife/supermarket_share.rb +33 -0
  30. data/lib/chef/knife/supermarket_show.rb +33 -0
  31. data/lib/chef/knife/supermarket_unshare.rb +33 -0
  32. data/lib/chef/node.rb +13 -32
  33. data/lib/chef/node/attribute.rb +123 -70
  34. data/lib/chef/node/attribute_collections.rb +9 -130
  35. data/lib/chef/node/common_api.rb +124 -0
  36. data/lib/chef/node/immutable_collections.rb +27 -2
  37. data/lib/chef/property.rb +6 -2
  38. data/lib/chef/provider.rb +4 -5
  39. data/lib/chef/provider/batch.rb +1 -1
  40. data/lib/chef/provider/directory.rb +3 -1
  41. data/lib/chef/provider/package/openbsd.rb +1 -1
  42. data/lib/chef/provider/package/rubygems.rb +9 -3
  43. data/lib/chef/provider/package/windows/exe.rb +2 -5
  44. data/lib/chef/provider/powershell_script.rb +1 -1
  45. data/lib/chef/provider/remote_directory.rb +2 -0
  46. data/lib/chef/resource.rb +22 -17
  47. data/lib/chef/resource_builder.rb +9 -4
  48. data/lib/chef/shell.rb +1 -1
  49. data/lib/chef/version.rb +1 -1
  50. data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +2 -4
  51. data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +2 -3
  52. data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -2
  53. data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -2
  54. data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +2 -3
  55. data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +2 -3
  56. data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +2 -3
  57. data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +2 -3
  58. data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +2 -3
  59. data/spec/functional/assets/chocolatey_feed/test-A.1.0.nupkg +0 -0
  60. data/spec/functional/assets/chocolatey_feed/test-A.1.5.nupkg +0 -0
  61. data/spec/functional/assets/chocolatey_feed/test-A.2.0.nupkg +0 -0
  62. data/spec/functional/assets/chocolatey_feed/test-B.1.0.nupkg +0 -0
  63. data/spec/functional/resource/dsc_script_spec.rb +1 -0
  64. data/spec/functional/resource/package_spec.rb +1 -1
  65. data/spec/functional/resource/template_spec.rb +3 -3
  66. data/spec/functional/shell_spec.rb +1 -1
  67. data/spec/integration/knife/client_bulk_delete_spec.rb +130 -0
  68. data/spec/integration/knife/client_create_spec.rb +69 -0
  69. data/spec/integration/knife/client_delete_spec.rb +63 -0
  70. data/spec/integration/knife/client_key_create_spec.rb +65 -0
  71. data/spec/integration/knife/client_key_delete_spec.rb +42 -0
  72. data/spec/integration/knife/client_key_list_spec.rb +60 -0
  73. data/spec/integration/knife/client_key_show_spec.rb +44 -0
  74. data/spec/integration/knife/client_list_spec.rb +48 -0
  75. data/spec/integration/knife/client_show_spec.rb +36 -0
  76. data/spec/integration/knife/cookbook_bulk_delete_spec.rb +64 -0
  77. data/spec/integration/knife/cookbook_download_spec.rb +95 -0
  78. data/spec/integration/knife/cookbook_list_spec.rb +54 -0
  79. data/spec/integration/knife/cookbook_show_spec.rb +159 -0
  80. data/spec/integration/knife/cookbook_upload_spec.rb +90 -0
  81. data/spec/integration/knife/data_bag_create_spec.rb +58 -0
  82. data/spec/integration/knife/data_bag_delete_spec.rb +58 -0
  83. data/spec/integration/knife/data_bag_from_file_spec.rb +115 -0
  84. data/spec/integration/knife/data_bag_list_spec.rb +43 -0
  85. data/spec/integration/knife/data_bag_show_spec.rb +53 -0
  86. data/spec/integration/knife/environment_compare_spec.rb +74 -0
  87. data/spec/integration/knife/environment_create_spec.rb +40 -0
  88. data/spec/integration/knife/environment_delete_spec.rb +36 -0
  89. data/spec/integration/knife/environment_from_file_spec.rb +115 -0
  90. data/spec/integration/knife/environment_list_spec.rb +41 -0
  91. data/spec/integration/knife/environment_show_spec.rb +56 -0
  92. data/spec/integration/knife/node_bulk_delete_spec.rb +51 -0
  93. data/spec/integration/knife/node_create_spec.rb +46 -0
  94. data/spec/integration/knife/node_delete_spec.rb +47 -0
  95. data/spec/integration/knife/node_environment_set_spec.rb +42 -0
  96. data/spec/integration/knife/node_from_file_spec.rb +58 -0
  97. data/spec/integration/knife/node_list_spec.rb +44 -0
  98. data/spec/integration/knife/node_run_list_add_spec.rb +53 -0
  99. data/spec/integration/knife/node_run_list_remove_spec.rb +35 -0
  100. data/spec/integration/knife/node_run_list_set_spec.rb +40 -0
  101. data/spec/integration/knife/node_show_spec.rb +35 -0
  102. data/spec/integration/knife/role_bulk_delete_spec.rb +51 -0
  103. data/spec/integration/knife/role_create_spec.rb +40 -0
  104. data/spec/integration/knife/role_delete_spec.rb +47 -0
  105. data/spec/integration/knife/role_from_file_spec.rb +95 -0
  106. data/spec/integration/knife/role_list_spec.rb +44 -0
  107. data/spec/integration/knife/role_show_spec.rb +50 -0
  108. data/spec/support/shared/integration/knife_support.rb +10 -3
  109. data/spec/unit/application/solo_spec.rb +7 -0
  110. data/spec/unit/cookbook_version_spec.rb +4 -4
  111. data/spec/unit/data_collector/messages/helpers_spec.rb +3 -7
  112. data/spec/unit/data_collector/messages_spec.rb +28 -45
  113. data/spec/unit/data_collector_spec.rb +40 -47
  114. data/spec/unit/knife/cookbook_create_spec.rb +1 -0
  115. data/spec/unit/knife/cookbook_site_download_spec.rb +1 -0
  116. data/spec/unit/knife/node_environment_set_spec.rb +0 -24
  117. data/spec/unit/knife/node_run_list_set_spec.rb +0 -25
  118. data/spec/unit/node/attribute_spec.rb +7 -9
  119. data/spec/unit/node/immutable_collections_spec.rb +4 -0
  120. data/spec/unit/node/vivid_mash_spec.rb +344 -0
  121. data/spec/unit/node_spec.rb +115 -26
  122. data/spec/unit/provider/directory_spec.rb +11 -1
  123. data/spec/unit/provider/package/windows/exe_spec.rb +14 -9
  124. data/spec/unit/provider/powershell_script_spec.rb +4 -4
  125. data/spec/unit/provider/remote_directory_spec.rb +15 -0
  126. data/spec/unit/recipe_spec.rb +31 -6
  127. data/spec/unit/run_context_spec.rb +2 -2
  128. data/spec/unit/shell/shell_session_spec.rb +1 -1
  129. data/tasks/dependencies.rb +0 -2
  130. metadata +55 -786
  131. data/acceptance/.bundle/config +0 -2
  132. data/acceptance/basics/.kitchen/logs/chef-current-install-ubuntu-1404.log +0 -2
  133. data/acceptance/basics/.kitchen/logs/kitchen.log +0 -3
  134. data/acceptance/fips/.kitchen/logs/fips-integration-centos-6.log +0 -3
  135. data/acceptance/fips/.kitchen/logs/fips-integration-windows-2012r2.log +0 -3
  136. data/acceptance/fips/.kitchen/logs/fips-unit-functional-centos-6.log +0 -3
  137. data/acceptance/fips/.kitchen/logs/fips-unit-functional-windows-2012r2.log +0 -3
  138. data/acceptance/fips/.kitchen/logs/kitchen.log +0 -6
  139. data/acceptance/trivial/.kitchen/logs/chef-current-install-windows-2012r2.log +0 -2
  140. data/acceptance/trivial/.kitchen/logs/kitchen.log +0 -3
  141. data/acceptance/windows-service/.kitchen/logs/chef-windows-service-windows-2012r2.log +0 -2
  142. data/acceptance/windows-service/.kitchen/logs/kitchen.log +0 -3
@@ -0,0 +1,54 @@
1
+ #
2
+ # Copyright:: Copyright 2013-2016, Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "support/shared/integration/integration_helper"
18
+ require "support/shared/context/config"
19
+ require "chef/knife/cookbook_list"
20
+
21
+ describe "knife cookbook list", :workstation do
22
+ include IntegrationSupport
23
+ include KnifeSupport
24
+
25
+ include_context "default config options"
26
+
27
+ when_the_chef_server "has a cookbook" do
28
+ before do
29
+ cookbook "x", "1.0.0"
30
+ cookbook "x", "0.6.5"
31
+ cookbook "x", "0.6.0"
32
+ cookbook "y", "0.6.5"
33
+ cookbook "y", "0.6.0"
34
+ cookbook "z", "0.6.5"
35
+ end
36
+
37
+ it "knife cookbook list shows all the cookbooks" do
38
+ knife("cookbook list").should_succeed <<EOM
39
+ x 1.0.0
40
+ y 0.6.5
41
+ z 0.6.5
42
+ EOM
43
+ end
44
+
45
+ it "knife cookbook list -a shows all the versions of all the cookbooks" do
46
+ knife("cookbook list -a").should_succeed <<EOM
47
+ x 1.0.0 0.6.5 0.6.0
48
+ y 0.6.5 0.6.0
49
+ z 0.6.5
50
+ EOM
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,159 @@
1
+ #
2
+ # Copyright:: Copyright 2013-2016, Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "support/shared/integration/integration_helper"
18
+ require "support/shared/context/config"
19
+ require "chef/knife/cookbook_show"
20
+
21
+ describe "knife cookbook show", :workstation do
22
+ include IntegrationSupport
23
+ include KnifeSupport
24
+
25
+ include_context "default config options"
26
+
27
+ when_the_chef_server "has a cookbook" do
28
+ before do
29
+ cookbook "x", "1.0.0", { "recipes" => { "default.rb" => "file 'n'", "x.rb" => "" } }
30
+ cookbook "x", "0.6.5"
31
+ end
32
+
33
+ it "knife cookbook show x shows all the versions" do
34
+ knife("cookbook show x").should_succeed "x 1.0.0 0.6.5\n"
35
+ end
36
+
37
+ # rubocop:disable Style/TrailingWhitespace
38
+ it "knife cookbook show x 1.0.0 shows the correct version" do
39
+ knife("cookbook show x 1.0.0").should_succeed <<EOM
40
+ attributes:
41
+ chef_type: cookbook_version
42
+ cookbook_name: x
43
+ definitions:
44
+ files:
45
+ frozen?: false
46
+ json_class: Chef::CookbookVersion
47
+ libraries:
48
+ metadata:
49
+ attributes:
50
+ chef_versions:
51
+ conflicting:
52
+ dependencies:
53
+ description:
54
+ gems:
55
+ groupings:
56
+ issues_url:
57
+ license: All rights reserved
58
+ long_description:
59
+ maintainer:
60
+ maintainer_email:
61
+ name: x
62
+ ohai_versions:
63
+ platforms:
64
+ privacy: false
65
+ providing:
66
+ recipes:
67
+ recommendations:
68
+ replacing:
69
+ source_url:
70
+ suggestions:
71
+ version: 1.0.0
72
+ name: x-1.0.0
73
+ providers:
74
+ recipes:
75
+ checksum: 4631b34cf58de10c5ef1304889941b2e
76
+ name: default.rb
77
+ path: recipes/default.rb
78
+ specificity: default
79
+ url: http://127.0.0.1:8900/file_store/checksums/4631b34cf58de10c5ef1304889941b2e
80
+
81
+ checksum: d41d8cd98f00b204e9800998ecf8427e
82
+ name: x.rb
83
+ path: recipes/x.rb
84
+ specificity: default
85
+ url: http://127.0.0.1:8900/file_store/checksums/d41d8cd98f00b204e9800998ecf8427e
86
+ resources:
87
+ root_files:
88
+ checksum: 8226671f751ba102dea6a6b6bd32fa8d
89
+ name: metadata.rb
90
+ path: metadata.rb
91
+ specificity: default
92
+ url: http://127.0.0.1:8900/file_store/checksums/8226671f751ba102dea6a6b6bd32fa8d
93
+ templates:
94
+ version: 1.0.0
95
+ EOM
96
+ end
97
+
98
+ it "knife cookbook show x 1.0.0 metadata shows the metadata" do
99
+ knife("cookbook show x 1.0.0 metadata").should_succeed <<EOM
100
+ attributes:
101
+ chef_versions:
102
+ conflicting:
103
+ dependencies:
104
+ description:
105
+ gems:
106
+ groupings:
107
+ issues_url:
108
+ license: All rights reserved
109
+ long_description:
110
+ maintainer:
111
+ maintainer_email:
112
+ name: x
113
+ ohai_versions:
114
+ platforms:
115
+ privacy: false
116
+ providing:
117
+ recipes:
118
+ recommendations:
119
+ replacing:
120
+ source_url:
121
+ suggestions:
122
+ version: 1.0.0
123
+ EOM
124
+ end
125
+
126
+ it "knife cookbook show x 1.0.0 recipes shows all the recipes" do
127
+ knife("cookbook show x 1.0.0 recipes").should_succeed <<EOM
128
+ checksum: 4631b34cf58de10c5ef1304889941b2e
129
+ name: default.rb
130
+ path: recipes/default.rb
131
+ specificity: default
132
+ url: http://127.0.0.1:8900/file_store/checksums/4631b34cf58de10c5ef1304889941b2e
133
+
134
+ checksum: d41d8cd98f00b204e9800998ecf8427e
135
+ name: x.rb
136
+ path: recipes/x.rb
137
+ specificity: default
138
+ url: http://127.0.0.1:8900/file_store/checksums/d41d8cd98f00b204e9800998ecf8427e
139
+ EOM
140
+ end
141
+ # rubocop:enable Style/TrailingWhitespace
142
+
143
+ it "knife cookbook show x 1.0.0 recipes default.rb shows the default recipe" do
144
+ knife("cookbook show x 1.0.0 recipes default.rb").should_succeed "file 'n'\n"
145
+ end
146
+
147
+ it "knife cookbook show with a non-existent file displays an error" do
148
+ expect { knife("cookbook show x 1.0.0 recipes moose.rb") }.to raise_error(Chef::Exceptions::FileNotFound)
149
+ end
150
+
151
+ it "knife cookbook show with a non-existent version displays an error" do
152
+ expect { knife("cookbook show x 1.0.1") }.to raise_error(Net::HTTPServerException)
153
+ end
154
+
155
+ it "knife cookbook show with a non-existent cookbook displays an error" do
156
+ expect { knife("cookbook show y") }.to raise_error(Net::HTTPServerException)
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,90 @@
1
+ #
2
+ # Copyright:: Copyright 2013-2016, Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "support/shared/integration/integration_helper"
18
+ require "support/shared/context/config"
19
+ require "chef/knife/cookbook_upload"
20
+
21
+ describe "knife cookbook upload", :workstation do
22
+ include IntegrationSupport
23
+ include KnifeSupport
24
+
25
+ include_context "default config options"
26
+
27
+ let (:cb_dir) { "#{@repository_dir}/cookbooks" }
28
+
29
+ when_the_chef_server "is empty" do
30
+ when_the_repository "has a cookbook" do
31
+ before do
32
+ file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0")
33
+ end
34
+
35
+ it "knife cookbook upload uploads the cookbook" do
36
+ knife("cookbook upload x -o #{cb_dir}").should_succeed stderr: <<EOM
37
+ Uploading x [1.0.0]
38
+ Uploaded 1 cookbook.
39
+ EOM
40
+ end
41
+
42
+ it "knife cookbook upload --freeze uploads and freezes the cookbook" do
43
+ knife("cookbook upload x -o #{cb_dir} --freeze").should_succeed stderr: <<EOM
44
+ Uploading x [1.0.0]
45
+ Uploaded 1 cookbook.
46
+ EOM
47
+ # Modify the file, attempt to reupload
48
+ file "cookbooks/x/metadata.rb", 'name "x"; version "1.0.0"#different'
49
+ knife("cookbook upload x -o #{cb_dir} --freeze").should_fail stderr: <<EOM
50
+ Uploading x [1.0.0]
51
+ ERROR: Version 1.0.0 of cookbook x is frozen. Use --force to override.
52
+ WARNING: Not updating version constraints for x in the environment as the cookbook is frozen.
53
+ ERROR: Failed to upload 1 cookbook.
54
+ EOM
55
+ end
56
+ end
57
+
58
+ when_the_repository "has a cookbook that depends on another cookbook" do
59
+ before do
60
+ file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\ndepends 'y'")
61
+ file "cookbooks/y/metadata.rb", cb_metadata("y", "1.0.0")
62
+ end
63
+
64
+ it "knife cookbook upload --include-dependencies uploads both cookbooks" do
65
+ knife("cookbook upload --include-dependencies x -o #{cb_dir}").should_succeed stderr: <<EOM
66
+ Uploading x [1.0.0]
67
+ Uploading y [1.0.0]
68
+ Uploaded 2 cookbooks.
69
+ EOM
70
+ end
71
+
72
+ it "knife cookbook upload fails due to missing dependencies" do
73
+ knife("cookbook upload x -o #{cb_dir}").should_fail stderr: <<EOM
74
+ Uploading x [1.0.0]
75
+ ERROR: Cookbook x depends on cookbooks which are not currently
76
+ ERROR: being uploaded and cannot be found on the server.
77
+ ERROR: The missing cookbook(s) are: 'y' version '>= 0.0.0'
78
+ EOM
79
+ end
80
+
81
+ it "knife cookbook upload -a uploads both cookbooks" do
82
+ knife("cookbook upload -a -o #{cb_dir}").should_succeed stderr: <<EOM
83
+ Uploading x [1.0.0]
84
+ Uploading y [1.0.0]
85
+ Uploaded all cookbooks.
86
+ EOM
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,58 @@
1
+ #
2
+ # Copyright:: Copyright 2013-2016, Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "support/shared/integration/integration_helper"
18
+ require "support/shared/context/config"
19
+ require "chef/knife/data_bag_create"
20
+
21
+ describe "knife data bag create", :workstation do
22
+ include IntegrationSupport
23
+ include KnifeSupport
24
+
25
+ include_context "default config options"
26
+
27
+ let(:err) { "Created data_bag[foo]\n" }
28
+ let(:out) { "Created data_bag_item[bar]\n" }
29
+ let(:exists) { "Data bag foo already exists\n" }
30
+
31
+ when_the_chef_server "is empty" do
32
+ it "creates a new data bag" do
33
+ knife("data bag create foo").should_succeed stderr: err
34
+ end
35
+
36
+ it "creates a new data bag and item" do
37
+ pending "Deprecation warning must get fixed"
38
+ knife("data bag create foo bar").should_succeed stdout: out, stderr: err
39
+ end
40
+
41
+ it "adds a new item to an existing bag" do
42
+ pending "Deprecation warning must get fixed"
43
+ knife("data bag create foo").should_succeed stderr: err
44
+ knife("data bag create foo bar").should_succeed stdout: out, stderr: exists
45
+ end
46
+
47
+ it "refuses to add an existing data bag" do
48
+ knife("data bag create foo").should_succeed stderr: err
49
+ knife("data bag create foo").should_succeed stderr: exists
50
+ end
51
+
52
+ it "fails to add an existing item" do
53
+ pending "Deprecation warning must get fixed"
54
+ knife("data bag create foo bar").should_succeed stdout: out, stderr: err
55
+ expect { knife("data bag create foo bar") }.to raise_error(Net::HTTPServerException)
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,58 @@
1
+ #
2
+ # Copyright:: Copyright 2013-2016, Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "support/shared/integration/integration_helper"
18
+ require "support/shared/context/config"
19
+ require "chef/knife/data_bag_delete"
20
+
21
+ describe "knife data bag delete", :workstation do
22
+ include IntegrationSupport
23
+ include KnifeSupport
24
+
25
+ include_context "default config options"
26
+
27
+ when_the_chef_server "has some data bags" do
28
+ before do
29
+ data_bag "x", {}
30
+ data_bag "canteloupe", {}
31
+ data_bag "rocket", { "falcon9" => { heavy: "true" }, "atlas" => {}, "ariane" => {} }
32
+ end
33
+
34
+ it "with an empty data bag" do
35
+ knife("data bag delete canteloupe", input: "y").should_succeed <<EOM
36
+ Do you really want to delete canteloupe? (Y/N) Deleted data_bag[canteloupe]
37
+ EOM
38
+ end
39
+
40
+ it "with a bag with some items" do
41
+ knife("data bag delete rocket", input: "y").should_succeed <<EOM
42
+ Do you really want to delete rocket? (Y/N) Deleted data_bag[rocket]
43
+ EOM
44
+ end
45
+
46
+ it "with a single item" do
47
+ knife("data bag delete rocket falcon9", input: "y").should_succeed <<EOM
48
+ Do you really want to delete falcon9? (Y/N) Deleted data_bag_item[falcon9]
49
+ EOM
50
+ end
51
+
52
+ it "choosing not to delete" do
53
+ knife("data bag delete rocket falcon9", input: "n").should_succeed <<EOM, exit_code: 3
54
+ Do you really want to delete falcon9? (Y/N) You said no, so I'm done here.
55
+ EOM
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,115 @@
1
+ #
2
+ # Copyright:: Copyright 2013-2016, Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "support/shared/integration/integration_helper"
18
+ require "support/shared/context/config"
19
+
20
+ describe "knife data bag from file", :workstation do
21
+ include IntegrationSupport
22
+ include KnifeSupport
23
+
24
+ include_context "default config options"
25
+
26
+ let (:db_dir) { "#{@repository_dir}/data_bags" }
27
+
28
+ when_the_chef_server "has an empty data bag" do
29
+ before do
30
+ data_bag "foo", {}
31
+ data_bag "bar", {}
32
+ end
33
+
34
+ when_the_repository "has some data bag items" do
35
+ before do
36
+ file "data_bags/foo/bar.json", { "id" => "bar", "foo" => "bar " }
37
+ file "data_bags/foo/bzr.json", { "id" => "bzr", "foo" => "bar " }
38
+ file "data_bags/foo/cat.json", { "id" => "cat", "foo" => "bar " }
39
+ file "data_bags/foo/dog.json", { "id" => "dog", "foo" => "bar " }
40
+ file "data_bags/foo/encrypted.json", <<EOM
41
+ {
42
+ "id": "encrypted",
43
+ "password": {
44
+ "encrypted_data": "H6ab5RY9a9JAkS8A0RCMspXtOJh0ai8cNeA4Q3gLO8s=\\n",
45
+ "iv": "uWKKKxrJgtELlGMCOLJdkA==\\n",
46
+ "version": 1,
47
+ "cipher": "aes-256-cbc"
48
+ }
49
+ }
50
+ EOM
51
+ file "data_bags/bar/round_trip.json", <<EOM
52
+ {
53
+ "name": "data_bag_item_bar_round_trip",
54
+ "json_class": "Chef::DataBagItem",
55
+ "chef_type": "data_bag_item",
56
+ "data_bag": "bar",
57
+ "raw_data": {
58
+ "id": "round_trip",
59
+ "root_password": {
60
+ "encrypted_data": "noDOsTpsTAZlTU5sprhmYZzUDfr8du7hH/zRDOjRAmoTJHTZyfYoR221EOOW\\nXJ1D\\n",
61
+ "iv": "Bnqhfy6n0Hx1wCe9pxHLoA==\\n",
62
+ "version": 1,
63
+ "cipher": "aes-256-cbc"
64
+ },
65
+ "admin_password": {
66
+ "encrypted_data": "TcC7dU1gx6OnE5Ab4i/k42UEf0Nnr7cAyuTHId/LNjNOwpNf7XZc27DQSjuy\\nHPlt\\n",
67
+ "iv": "+TAWJuPWCI2+WB8lGJAyvw==\\n",
68
+ "version": 1,
69
+ "cipher": "aes-256-cbc"
70
+ }
71
+ }
72
+ }
73
+ EOM
74
+ end
75
+
76
+ it "uploads a single file" do
77
+ knife("data bag from file foo #{db_dir}/foo/bar.json").should_succeed stderr: <<EOM
78
+ Updated data_bag_item[foo::bar]
79
+ EOM
80
+ end
81
+
82
+ it "uploads a single encrypted file" do
83
+ knife("data bag from file foo #{db_dir}/foo/encrypted.json").should_succeed stderr: <<EOM
84
+ Updated data_bag_item[foo::encrypted]
85
+ EOM
86
+ end
87
+
88
+ it "uploads a file in chef's internal format" do
89
+ pending "chef/chef#4815"
90
+ knife("data bag from file bar #{db_dir}/bar/round_trip.json").should_succeed stderr: <<EOM
91
+ Updated data_bag_item[bar::round_trip]
92
+ EOM
93
+ end
94
+
95
+ it "uploads many files" do
96
+ knife("data bag from file foo #{db_dir}/foo/bar.json #{db_dir}/foo/bzr.json").should_succeed stderr: <<EOM
97
+ Updated data_bag_item[foo::bar]
98
+ Updated data_bag_item[foo::bzr]
99
+ EOM
100
+ end
101
+
102
+ it "uploads a whole directory" do
103
+ knife("data bag from file foo #{db_dir}/foo")
104
+ knife("data bag show foo").should_succeed <<EOM
105
+ bar
106
+ bzr
107
+ cat
108
+ dog
109
+ encrypted
110
+ EOM
111
+ end
112
+
113
+ end
114
+ end
115
+ end