chef 14.12.3-universal-mingw32 → 14.12.9-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92e60ff6545327a69933c3552e5dc0b8ba165d291b06296ad5be6e5480b2cbd4
4
- data.tar.gz: 70ccd89b276b634e30aca829ed27c98a55b2a01179a2be41aa92471d2af50ce4
3
+ metadata.gz: d05ca2c32f6dbbd2d8d81afe5c9ec0b00a6fe691b250882df0a1c202bb586b07
4
+ data.tar.gz: 59ce9e89da8e616584f75d5aaee65e69b8fa484b60a2b64c7a96acffc3ed2703
5
5
  SHA512:
6
- metadata.gz: 43a435a07d4caf79d9ff0a50d7cfb51e6bd1f5b56cd4e77692598a19d3b444affe58d60ed68f085a7697206fceae7dfd4aefe2be2357285dbb338d4953ef2ded
7
- data.tar.gz: 0b9a317619fa9e7c5caa2de8e5e88f3322c2cb34ef319ece153bbb294131deddb4f8b207af88659248bd06aa5b3642d2cf487ce6e318b90beb948f3fac36eee7
6
+ metadata.gz: c61ee407d4e8be899e7de8d20fd34630edfc1149856b2abb9133e83a3cb86d94ec1a6f4217cafda2062367ca7426ad9277503a146def9ef5fde494e0887779e2
7
+ data.tar.gz: 49d3b21f1d9fe8137f1198ff52ab385053376518c6181f207a15aeb3e9e13cc2ca2ad08f58dcef93d9211de6cc47c88ec21d89876bb1ef4179bf75f07d13e0b0
@@ -132,10 +132,10 @@ class Chef
132
132
  config[:config_file] = config_fetcher.expanded_path
133
133
 
134
134
  if config[:config_file].nil?
135
- logger.warn("No config file found or specified on command line, using command line options.")
135
+ logger.warn("No config file found or specified on command line. Using command line options instead.")
136
136
  elsif config_fetcher.config_missing?
137
137
  logger.warn("*****************************************")
138
- logger.warn("Did not find config file: #{config[:config_file]}, using command line options.")
138
+ logger.warn("Did not find config file: #{config[:config_file]}. Using command line options instead.")
139
139
  logger.warn("*****************************************")
140
140
  else
141
141
  config_content = config_fetcher.read_config
@@ -113,6 +113,11 @@ class Chef::Application::Apply < Chef::Application
113
113
  description: "Only run the bare minimum ohai plugins chef needs to function",
114
114
  boolean: true
115
115
 
116
+ option :chef_license,
117
+ long: "--chef-license ACCEPTANCE",
118
+ description: "Placeholder option for Chef license acceptance to provide compatibility with Chef Infra 15+ command line options.",
119
+ required: false
120
+
116
121
  attr_reader :json_attribs
117
122
 
118
123
  def initialize
@@ -302,6 +302,11 @@ class Chef::Application::Client < Chef::Application
302
302
  description: "Use cached cookbooks without overwriting local differences from the server",
303
303
  boolean: false
304
304
 
305
+ option :chef_license,
306
+ long: "--chef-license ACCEPTANCE",
307
+ description: "Placeholder option for Chef license acceptance to provide compatibility with Chef Infra 15+ command line options.",
308
+ required: false
309
+
305
310
  IMMEDIATE_RUN_SIGNAL = "1".freeze
306
311
  RECONFIGURE_SIGNAL = "H".freeze
307
312
 
@@ -81,13 +81,13 @@ class Chef::Application::Solo < Chef::Application
81
81
  option :log_level,
82
82
  short: "-l LEVEL",
83
83
  long: "--log_level LEVEL",
84
- description: "Set the log level (trace, debug, info, warn, error, fatal)",
84
+ description: "Set the log level (auto, trace, debug, info, warn, error, fatal)",
85
85
  proc: lambda { |l| l.to_sym }
86
86
 
87
87
  option :log_location,
88
88
  short: "-L LOGLOCATION",
89
89
  long: "--logfile LOGLOCATION",
90
- description: "Set the log file location, defaults to STDOUT",
90
+ description: "Set the log file location, defaults to STDOUT - recommended for daemonizing",
91
91
  proc: nil
92
92
 
93
93
  option :help,
@@ -121,7 +121,7 @@ class Chef::Application::Solo < Chef::Application
121
121
 
122
122
  option :lockfile,
123
123
  long: "--lockfile LOCKFILE",
124
- description: "Set the lockfile location. Prevents multiple processes from converging at the same time",
124
+ description: "Set the lockfile location. Prevents multiple solo processes from converging at the same time",
125
125
  proc: nil
126
126
 
127
127
  option :interval,
@@ -164,7 +164,7 @@ class Chef::Application::Solo < Chef::Application
164
164
  option :override_runlist,
165
165
  short: "-o RunlistItem,RunlistItem...",
166
166
  long: "--override-runlist RunlistItem,RunlistItem...",
167
- description: "Replace current run list with specified items",
167
+ description: "Replace current run list with specified items for a single run",
168
168
  proc: lambda { |items|
169
169
  items = items.split(",")
170
170
  items.compact.map do |item|
@@ -213,6 +213,11 @@ class Chef::Application::Solo < Chef::Application
213
213
  description: "Run chef-solo in legacy mode",
214
214
  boolean: true
215
215
 
216
+ option :chef_license,
217
+ long: "--chef-license ACCEPTANCE",
218
+ description: "Placeholder option for Chef license acceptance to provide compatibility with Chef Infra 15+ command line options.",
219
+ required: false
220
+
216
221
  attr_reader :chef_client_json
217
222
 
218
223
  # Get this party started
@@ -299,8 +304,8 @@ class Chef::Application::Solo < Chef::Application
299
304
 
300
305
  def run_application
301
306
  if !Chef::Config[:client_fork] || Chef::Config[:once]
302
- # Run immediately without interval sleep or splay
303
307
  begin
308
+ # run immediately without interval sleep, or splay
304
309
  run_chef_client(Chef::Config[:specific_recipes])
305
310
  rescue SystemExit
306
311
  raise
@@ -313,7 +313,7 @@ class Chef
313
313
  end
314
314
  rescue Errno::ENOENT
315
315
  Chef::Log.warn("*****************************************")
316
- Chef::Log.warn("Did not find config file: #{config[:config_file]}, using command line options.")
316
+ Chef::Log.warn("Did not find config file: #{config[:config_file]}. Using command line options instead.")
317
317
  Chef::Log.warn("*****************************************")
318
318
 
319
319
  Chef::Config.merge!(config)
@@ -250,6 +250,11 @@ class Chef
250
250
  Chef::Config[:knife][:bootstrap_vault_item]
251
251
  }
252
252
 
253
+ option :chef_license,
254
+ long: "--chef-license ACCEPTANCE",
255
+ description: "Placeholder option for Chef license acceptance to provide compatibility with Chef Infra 15+ command line options.",
256
+ required: false
257
+
253
258
  def initialize(argv = [])
254
259
  super
255
260
  @client_builder = Chef::Knife::Bootstrap::ClientBuilder.new(
@@ -43,7 +43,7 @@ class Chef
43
43
  exit(1)
44
44
  end
45
45
  else
46
- return item, false
46
+ return item.raw_data, false
47
47
  end
48
48
  end
49
49
 
data/lib/chef/node.rb CHANGED
@@ -455,13 +455,10 @@ class Chef
455
455
 
456
456
  # Transform the node to a Hash
457
457
  def to_hash
458
- index_hash = Hash.new
458
+ index_hash = attributes.to_hash
459
459
  index_hash["chef_type"] = "node"
460
460
  index_hash["name"] = name
461
461
  index_hash["chef_environment"] = chef_environment
462
- attribute.each do |key, value|
463
- index_hash[key] = value
464
- end
465
462
  index_hash["recipe"] = run_list.recipe_names if run_list.recipe_names.length > 0
466
463
  index_hash["role"] = run_list.role_names if run_list.role_names.length > 0
467
464
  index_hash["run_list"] = run_list.run_list_items
@@ -472,10 +469,10 @@ class Chef
472
469
  display = {}
473
470
  display["name"] = name
474
471
  display["chef_environment"] = chef_environment
475
- display["automatic"] = automatic_attrs
476
- display["normal"] = normal_attrs
477
- display["default"] = attributes.combined_default
478
- display["override"] = attributes.combined_override
472
+ display["automatic"] = attributes.automatic.to_hash
473
+ display["normal"] = attributes.normal.to_hash
474
+ display["default"] = attributes.combined_default.to_hash
475
+ display["override"] = attributes.combined_override.to_hash
479
476
  display["run_list"] = run_list.run_list_items
480
477
  display
481
478
  end
@@ -490,11 +487,11 @@ class Chef
490
487
  "name" => name,
491
488
  "chef_environment" => chef_environment,
492
489
  "json_class" => self.class.name,
493
- "automatic" => attributes.automatic,
494
- "normal" => attributes.normal,
490
+ "automatic" => attributes.automatic.to_hash,
491
+ "normal" => attributes.normal.to_hash,
495
492
  "chef_type" => "node",
496
- "default" => attributes.combined_default,
497
- "override" => attributes.combined_override,
493
+ "default" => attributes.combined_default.to_hash,
494
+ "override" => attributes.combined_override.to_hash,
498
495
  # Render correctly for run_list items so malformed json does not result
499
496
  "run_list" => @primary_runlist.run_list.map { |item| item.to_s },
500
497
  }
data/lib/chef/version.rb CHANGED
@@ -23,7 +23,7 @@ require "chef/version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("../..", __FILE__)
26
- VERSION = Chef::VersionString.new("14.12.3")
26
+ VERSION = Chef::VersionString.new("14.12.9")
27
27
  end
28
28
 
29
29
  #
@@ -45,7 +45,7 @@ class Chef
45
45
  all_data = data
46
46
  filtered_data = new_data
47
47
  parts[0..-2].each do |part|
48
- unless all_data[part]
48
+ unless all_data.key?(part)
49
49
  Chef::Log.warn("Could not find whitelist attribute #{item}.")
50
50
  return nil
51
51
  end
@@ -27,29 +27,98 @@ describe "knife data bag create", :workstation do
27
27
  let(:err) { "Created data_bag[foo]\n" }
28
28
  let(:out) { "Created data_bag_item[bar]\n" }
29
29
  let(:exists) { "Data bag foo already exists\n" }
30
+ let(:secret) { "abc" }
30
31
 
31
32
  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
33
+ context "with encryption key" do
34
+ it "creates a new data bag and item" do
35
+ pretty_json = Chef::JSONCompat.to_json_pretty({ id: "bar", test: "pass" })
36
+ allow(Chef::JSONCompat).to receive(:to_json_pretty).and_return(pretty_json)
37
+ knife("data bag create foo bar --secret #{secret}").should_succeed stdout: out, stderr: err
38
+ expect(knife("data bag show foo bar --secret #{secret}").stderr).to eq("Encrypted data bag detected, decrypting with provided secret.\n")
39
+ expect(knife("data bag show foo bar --secret #{secret}").stdout).to eq("id: bar\ntest: pass\n")
40
+ end
41
+
42
+ it "creates a new data bag and an empty item" do
43
+ knife("data bag create foo bar --secret #{secret}").should_succeed stdout: out, stderr: err
44
+ expect(knife("data bag show foo bar --secret #{secret}").stderr).to eq("WARNING: Unencrypted data bag detected, ignoring any provided secret options.\n")
45
+ expect(knife("data bag show foo bar --secret #{secret}").stdout).to eq("id: bar\n")
46
+ end
34
47
  end
35
48
 
36
- it "creates a new data bag and item" do
37
- knife("data bag create foo bar").should_succeed stdout: out, stderr: err
49
+ context "without encryption key" do
50
+ it "creates a new data bag" do
51
+ knife("data bag create foo").should_succeed stderr: err
52
+ expect(knife("data bag show foo").stderr).to eq("")
53
+ end
54
+
55
+ it "creates a new data bag and item" do
56
+ knife("data bag create foo bar").should_succeed stdout: out, stderr: err
57
+ expect(knife("data bag show foo").stdout).to eq("bar\n")
58
+ end
38
59
  end
60
+ end
39
61
 
40
- it "adds a new item to an existing bag" do
41
- knife("data bag create foo").should_succeed stderr: err
42
- knife("data bag create foo bar").should_succeed stdout: out, stderr: exists
62
+ when_the_chef_server "has some data bags" do
63
+ before do
64
+ data_bag "foo", {}
65
+ data_bag "bag", { "box" => {} }
43
66
  end
44
67
 
45
- it "refuses to add an existing data bag" do
46
- knife("data bag create foo").should_succeed stderr: err
47
- knife("data bag create foo").should_succeed stderr: exists
68
+ context "with encryption key" do
69
+ it "creates a new data bag and item" do
70
+ pretty_json = Chef::JSONCompat.to_json_pretty({ id: "bar", test: "pass" })
71
+ allow(Chef::JSONCompat).to receive(:to_json_pretty).and_return(pretty_json)
72
+ knife("data bag create rocket bar --secret #{secret}").should_succeed stdout: out, stderr: <<~EOM
73
+ Created data_bag[rocket]
74
+ EOM
75
+ expect(knife("data bag show rocket bar --secret #{secret}").stderr).to eq("Encrypted data bag detected, decrypting with provided secret.\n")
76
+ expect(knife("data bag show rocket bar --secret #{secret}").stdout).to eq("id: bar\ntest: pass\n")
77
+ end
78
+
79
+ it "creates a new data bag and an empty item" do
80
+ knife("data bag create rocket bar --secret #{secret}").should_succeed stdout: out, stderr: <<~EOM
81
+ Created data_bag[rocket]
82
+ EOM
83
+ expect(knife("data bag show rocket bar --secret #{secret}").stderr).to eq("WARNING: Unencrypted data bag detected, ignoring any provided secret options.\n")
84
+ expect(knife("data bag show rocket bar --secret #{secret}").stdout).to eq("id: bar\n")
85
+ end
86
+
87
+ it "adds a new item to an existing bag" do
88
+ knife("data bag create foo bar --secret #{secret}").should_succeed stdout: out, stderr: exists
89
+ expect(knife("data bag show foo bar --secret #{secret}").stderr).to eq("WARNING: Unencrypted data bag detected, ignoring any provided secret options.\n")
90
+ expect(knife("data bag show foo bar --secret #{secret}").stdout).to eq("id: bar\n")
91
+ end
92
+
93
+ it "fails to add an existing item" do
94
+ expect { knife("data bag create bag box --secret #{secret}") }.to raise_error(Net::HTTPClientException)
95
+ end
48
96
  end
49
97
 
50
- it "fails to add an existing item" do
51
- knife("data bag create foo bar").should_succeed stdout: out, stderr: err
52
- expect { knife("data bag create foo bar") }.to raise_error(Net::HTTPClientException)
98
+ context "without encryption key" do
99
+ it "creates a new data bag" do
100
+ knife("data bag create rocket").should_succeed stderr: <<~EOM
101
+ Created data_bag[rocket]
102
+ EOM
103
+ end
104
+
105
+ it "creates a new data bag and item" do
106
+ knife("data bag create rocket bar").should_succeed stdout: out, stderr: <<~EOM
107
+ Created data_bag[rocket]
108
+ EOM
109
+ end
110
+
111
+ it "adds a new item to an existing bag" do
112
+ knife("data bag create foo bar").should_succeed stdout: out, stderr: exists
113
+ end
114
+
115
+ it "refuses to create an existing data bag" do
116
+ knife("data bag create foo").should_succeed stderr: exists
117
+ end
118
+
119
+ it "fails to add an existing item" do
120
+ expect { knife("data bag create bag box") }.to raise_error(Net::HTTPClientException)
121
+ end
53
122
  end
54
123
  end
55
124
  end
@@ -0,0 +1,104 @@
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_edit"
20
+
21
+ describe "knife data bag edit", :workstation do
22
+ include IntegrationSupport
23
+ include KnifeSupport
24
+
25
+ include_context "default config options"
26
+
27
+ let(:out) { "Saved data_bag_item[box]\n" }
28
+ let(:err) { "Saving data bag unencrypted. To encrypt it, provide an appropriate secret.\n" }
29
+ let(:secret) { "abc" }
30
+ let(:encrypt) { "Encrypted data bag detected, decrypting with provided secret.\n" }
31
+
32
+ when_the_chef_server "is empty" do
33
+ context "with encryption key" do
34
+ it "fails to edit an item" do
35
+ expect { knife("data bag edit bag box --secret #{secret}") }.to raise_error(Net::HTTPClientException)
36
+ end
37
+ end
38
+
39
+ context "without encryption key" do
40
+ it "fails to edit an item" do
41
+ expect { knife("data bag edit bag box") }.to raise_error(Net::HTTPClientException)
42
+ end
43
+ end
44
+ end
45
+
46
+ when_the_chef_server "has some data bags" do
47
+ before do
48
+ data_bag "foo", {}
49
+ data_bag "bag", { "box" => {} }
50
+ data_bag "rocket", { "falcon9" => { heavy: "true" }, "atlas" => {}, "ariane" => {} }
51
+ data_bag "encrypt", { "box" => { id: "box", foo: { "encrypted_data": "J8N0pJ+LFDQF3XvhzWgkSBOuZZn8Og==\n", "iv": "4S1sb4zLnMt71SXV\n", "auth_tag": "4ChINhxz4WmqOizvZNoPPg==\n", "version": 3, "cipher": "aes-256-gcm" } } }
52
+ end
53
+
54
+ context "with encryption key" do
55
+ it "fails to edit a non-existing item" do
56
+ expect { knife("data bag edit foo box --secret #{secret}") }.to raise_error(Net::HTTPClientException)
57
+ end
58
+
59
+ it "edits an encrypted data bag item" do
60
+ pretty_json = Chef::JSONCompat.to_json_pretty({ id: "box", foo: "bar" })
61
+ allow(Chef::JSONCompat).to receive(:to_json_pretty).and_return(pretty_json)
62
+ knife("data bag edit encrypt box --secret #{secret}")
63
+ knife("data bag show encrypt box --secret #{secret}").should_succeed stderr: encrypt, stdout: <<~EOM
64
+ foo: bar
65
+ id: box
66
+ EOM
67
+ end
68
+
69
+ it "encrypts an unencrypted data bag item" do
70
+ knife("data bag edit rocket falcon9 --secret #{secret}")
71
+ knife("data bag show rocket falcon9 --secret #{secret}").should_succeed stderr: encrypt, stdout: <<~EOM
72
+ heavy: true
73
+ id: falcon9
74
+ EOM
75
+ end
76
+ end
77
+
78
+ context "without encryption key" do
79
+ it "fails to edit a non-existing item" do
80
+ expect { knife("data bag edit foo box") }.to raise_error(Net::HTTPClientException)
81
+ end
82
+ it "edits an empty data bag item" do
83
+ pretty_json = Chef::JSONCompat.to_json_pretty({ id: "box", ab: "abc" })
84
+ allow(Chef::JSONCompat).to receive(:to_json_pretty).and_return(pretty_json)
85
+ knife("data bag edit bag box").should_succeed stderr: err, stdout: out
86
+ knife("data bag show bag box").should_succeed <<~EOM
87
+ ab: abc
88
+ id: box
89
+ EOM
90
+ end
91
+ it "edits a non-empty data bag item" do
92
+ pretty_json = Chef::JSONCompat.to_json_pretty({ id: "falcon9", heavy: false })
93
+ allow(Chef::JSONCompat).to receive(:to_json_pretty).and_return(pretty_json)
94
+ knife("data bag edit rocket falcon9").should_succeed stderr: err, stdout: <<~EOM
95
+ Saved data_bag_item[falcon9]
96
+ EOM
97
+ knife("data bag show rocket falcon9").should_succeed <<~EOM
98
+ heavy: false
99
+ id: falcon9
100
+ EOM
101
+ end
102
+ end
103
+ end
104
+ end
@@ -24,30 +24,71 @@ describe "knife data bag show", :workstation do
24
24
 
25
25
  include_context "default config options"
26
26
 
27
- when_the_chef_server "has some data bags" do
27
+ when_the_chef_server "is empty" do
28
+ it "raises error if try to retrieve it" do
29
+ expect { knife("data bag show bag") }.to raise_error(Net::HTTPServerException)
30
+ end
31
+ end
32
+
33
+ when_the_chef_server "contains data bags" do
34
+ let(:right_secret) { "abc" }
35
+ let(:wrong_secret) { "ab" }
36
+ let(:err) { "Encrypted data bag detected, decrypting with provided secret.\n" }
28
37
  before do
29
38
  data_bag "x", {}
30
39
  data_bag "canteloupe", {}
31
40
  data_bag "rocket", { "falcon9" => { heavy: "true" }, "atlas" => {}, "ariane" => {} }
41
+ data_bag "encrypt", { "box" => { id: "box", foo: { "encrypted_data": "J8N0pJ+LFDQF3XvhzWgkSBOuZZn8Og==\n", "iv": "4S1sb4zLnMt71SXV\n", "auth_tag": "4ChINhxz4WmqOizvZNoPPg==\n", "version": 3, "cipher": "aes-256-gcm" } } }
32
42
  end
33
43
 
34
- it "with an empty data bag" do
35
- knife("data bag show canteloupe").should_succeed "\n"
36
- end
44
+ context "with encrypted data" do
45
+ context "provided secret key" do
46
+ it "shows data if secret key is correct" do
47
+ knife("data bag show encrypt box --secret #{right_secret}").should_succeed stderr: err, stdout: <<~EOM
48
+ foo: bar
49
+ id: box
50
+ EOM
51
+ end
37
52
 
38
- it "with a bag with some items" do
39
- knife("data bag show rocket").should_succeed <<~EOM
40
- ariane
41
- atlas
42
- falcon9
43
- EOM
53
+ it "raises error if secret key is incorrect" do
54
+ expect { knife("data bag show encrypt box --secret #{wrong_secret}") }.to raise_error(Chef::EncryptedDataBagItem::DecryptionFailure)
55
+ end
56
+ end
57
+
58
+ context "not provided secret key" do
59
+ it "shows encrypted data with a warning" do
60
+ expect(knife("data bag show encrypt box").stderr).to eq("WARNING: Encrypted data bag detected, but no secret provided for decoding. Displaying encrypted data.\n")
61
+ end
62
+ end
44
63
  end
45
64
 
46
- it "with a single item" do
47
- knife("data bag show rocket falcon9").should_succeed <<~EOM
48
- heavy: true
49
- id: falcon9
50
- EOM
65
+ context "with unencrypted data" do
66
+ context "provided secret key" do
67
+ it "shows unencrypted data with a warning" do
68
+ expect(knife("data bag show rocket falcon9 --secret #{right_secret}").stderr).to eq("WARNING: Unencrypted data bag detected, ignoring any provided secret options.\n")
69
+ end
70
+ end
71
+
72
+ context "not provided secret key" do
73
+ it "shows null with an empty data bag" do
74
+ knife("data bag show canteloupe").should_succeed "\n"
75
+ end
76
+
77
+ it "show list of items in a bag" do
78
+ knife("data bag show rocket").should_succeed <<~EOM
79
+ ariane
80
+ atlas
81
+ falcon9
82
+ EOM
83
+ end
84
+
85
+ it "show data of the item" do
86
+ knife("data bag show rocket falcon9").should_succeed <<~EOM
87
+ heavy: true
88
+ id: falcon9
89
+ EOM
90
+ end
91
+ end
51
92
  end
52
93
  end
53
94
  end
@@ -162,7 +162,7 @@ describe Chef::Application do
162
162
 
163
163
  it "should emit a warning" do
164
164
  expect(Chef::Config).not_to receive(:from_file).with("/etc/chef/default.rb")
165
- expect(Chef::Log).to receive(:warn).with("No config file found or specified on command line, using command line options.")
165
+ expect(Chef::Log).to receive(:warn).with("No config file found or specified on command line. Using command line options instead.")
166
166
  @app.configure_chef
167
167
  end
168
168
  end
@@ -49,8 +49,7 @@ describe Chef::Knife::DataBagEdit do
49
49
 
50
50
  let(:is_encrypted?) { false }
51
51
  let(:transmitted_hash) { raw_edited_hash }
52
- let(:data_to_edit) { db }
53
-
52
+ let(:data_to_edit) { db.raw_data }
54
53
  shared_examples_for "editing a data bag" do
55
54
  it "correctly edits then uploads the data bag" do
56
55
  expect(Chef::DataBagItem).to receive(:load).with(bag_name, item_name).and_return(db)
@@ -40,8 +40,8 @@ describe "Chef::Log::Syslog", unix_only: true do
40
40
  end
41
41
 
42
42
  it "should send message with severity warning to syslog." do
43
- expect(syslog).to receive(:add).with(2, "No config file found or specified on command line, using command line options.", nil)
44
- Chef::Log.warn("No config file found or specified on command line, using command line options.")
43
+ expect(syslog).to receive(:add).with(2, "No config file found or specified on command line. Using command line options instead.", nil)
44
+ Chef::Log.warn("No config file found or specified on command line. Using command line options instead.")
45
45
  end
46
46
 
47
47
  it "should fallback into send message with severity info to syslog when wrong format." do
@@ -43,8 +43,8 @@ describe Chef::Log::WinEvt do
43
43
  end
44
44
 
45
45
  it "should send message with severity warning to Windows Event Log." do
46
- expect(winevt).to receive(:add).with(2, "No config file found or specified on command line, using command line options.", nil)
47
- Chef::Log.warn("No config file found or specified on command line, using command line options.")
46
+ expect(winevt).to receive(:add).with(2, "No config file found or specified on command line. Using command line options instead.", nil)
47
+ Chef::Log.warn("No config file found or specified on command line. Using command line options instead.")
48
48
  end
49
49
 
50
50
  it "should fallback into send message with severity info to Windows Event Log when wrong format." do
@@ -1469,13 +1469,12 @@ describe Chef::Node do
1469
1469
 
1470
1470
  context "with whitelisted attributes configured" do
1471
1471
  it "should only save whitelisted attributes (and subattributes)" do
1472
- Chef::Config[:automatic_attribute_whitelist] = [
1472
+ Chef::Config[:default_attribute_whitelist] = [
1473
1473
  ["filesystem", "/dev/disk0s2"],
1474
1474
  "network/interfaces/eth0",
1475
1475
  ]
1476
1476
 
1477
- data = {
1478
- "automatic" => {
1477
+ node.default = {
1479
1478
  "filesystem" => {
1480
1479
  "/dev/disk0s2" => { "size" => "10mb" },
1481
1480
  "map - autohome" => { "size" => "10mb" },
@@ -1486,12 +1485,13 @@ describe Chef::Node do
1486
1485
  "eth1" => {},
1487
1486
  },
1488
1487
  },
1489
- },
1490
- "default" => {}, "normal" => {}, "override" => {}
1491
- }
1488
+ }
1489
+ node.automatic = {}
1490
+ node.normal = {}
1491
+ node.override = {}
1492
1492
 
1493
1493
  selected_data = {
1494
- "automatic" => {
1494
+ "default" => {
1495
1495
  "filesystem" => {
1496
1496
  "/dev/disk0s2" => { "size" => "10mb" },
1497
1497
  },
@@ -1501,12 +1501,11 @@ describe Chef::Node do
1501
1501
  },
1502
1502
  },
1503
1503
  },
1504
- "default" => {}, "normal" => {}, "override" => {}
1504
+ "automatic" => {}, "normal" => {}, "override" => {}
1505
1505
  }
1506
1506
 
1507
1507
  node.name("picky-monkey")
1508
- allow(node).to receive(:for_json).and_return(data)
1509
- expect(@rest).to receive(:put).with("nodes/picky-monkey", selected_data).and_return("foo")
1508
+ expect(@rest).to receive(:put).with("nodes/picky-monkey", hash_including(selected_data)).and_return("foo")
1510
1509
  node.save
1511
1510
  end
1512
1511
 
@@ -1515,8 +1514,7 @@ describe Chef::Node do
1515
1514
  "foo/bar/baz",
1516
1515
  ]
1517
1516
 
1518
- data = {
1519
- "default" => {
1517
+ node.default = {
1520
1518
  "foo" => {
1521
1519
  "bar" => {
1522
1520
  "baz" => false,
@@ -1525,8 +1523,11 @@ describe Chef::Node do
1525
1523
  "stuff" => true,
1526
1524
  },
1527
1525
  },
1528
- },
1529
- }
1526
+ }
1527
+
1528
+ node.automatic = {}
1529
+ node.normal = {}
1530
+ node.override = {}
1530
1531
 
1531
1532
  selected_data = {
1532
1533
  "default" => {
@@ -1539,44 +1540,41 @@ describe Chef::Node do
1539
1540
  }
1540
1541
 
1541
1542
  node.name("falsey-monkey")
1542
- allow(node).to receive(:for_json).and_return(data)
1543
- expect(@rest).to receive(:put).with("nodes/falsey-monkey", selected_data).and_return("foo")
1543
+ expect(@rest).to receive(:put).with("nodes/falsey-monkey", hash_including(selected_data)).and_return("foo")
1544
1544
  node.save
1545
1545
  end
1546
1546
 
1547
1547
  it "should not save any attributes if the whitelist is empty" do
1548
- Chef::Config[:automatic_attribute_whitelist] = []
1548
+ Chef::Config[:default_attribute_whitelist] = []
1549
1549
 
1550
- data = {
1551
- "automatic" => {
1550
+ node.default = {
1552
1551
  "filesystem" => {
1553
1552
  "/dev/disk0s2" => { "size" => "10mb" },
1554
1553
  "map - autohome" => { "size" => "10mb" },
1555
1554
  },
1556
- },
1557
- "default" => {}, "normal" => {}, "override" => {}
1558
- }
1555
+ }
1556
+ node.automatic = {}
1557
+ node.normal = {}
1558
+ node.override = {}
1559
1559
 
1560
1560
  selected_data = {
1561
1561
  "automatic" => {}, "default" => {}, "normal" => {}, "override" => {}
1562
1562
  }
1563
1563
 
1564
1564
  node.name("picky-monkey")
1565
- allow(node).to receive(:for_json).and_return(data)
1566
- expect(@rest).to receive(:put).with("nodes/picky-monkey", selected_data).and_return("foo")
1565
+ expect(@rest).to receive(:put).with("nodes/picky-monkey", hash_including(selected_data)).and_return("foo")
1567
1566
  node.save
1568
1567
  end
1569
1568
  end
1570
1569
 
1571
1570
  context "with blacklisted attributes configured" do
1572
1571
  it "should only save non-blacklisted attributes (and subattributes)" do
1573
- Chef::Config[:automatic_attribute_blacklist] = [
1572
+ Chef::Config[:default_attribute_blacklist] = [
1574
1573
  ["filesystem", "/dev/disk0s2"],
1575
1574
  "network/interfaces/eth0",
1576
1575
  ]
1577
1576
 
1578
- data = {
1579
- "automatic" => {
1577
+ node.default = {
1580
1578
  "filesystem" => {
1581
1579
  "/dev/disk0s2" => { "size" => "10mb" },
1582
1580
  "map - autohome" => { "size" => "10mb" },
@@ -1587,12 +1585,13 @@ describe Chef::Node do
1587
1585
  "eth1" => {},
1588
1586
  },
1589
1587
  },
1590
- },
1591
- "default" => {}, "normal" => {}, "override" => {}
1592
- }
1588
+ }
1589
+ node.automatic = {}
1590
+ node.normal = {}
1591
+ node.override = {}
1593
1592
 
1594
1593
  selected_data = {
1595
- "automatic" => {
1594
+ "default" => {
1596
1595
  "filesystem" => {
1597
1596
  "map - autohome" => { "size" => "10mb" },
1598
1597
  },
@@ -1602,40 +1601,38 @@ describe Chef::Node do
1602
1601
  },
1603
1602
  },
1604
1603
  },
1605
- "default" => {}, "normal" => {}, "override" => {}
1604
+ "automatic" => {}, "normal" => {}, "override" => {}
1606
1605
  }
1607
1606
  node.name("picky-monkey")
1608
- allow(node).to receive(:for_json).and_return(data)
1609
- expect(@rest).to receive(:put).with("nodes/picky-monkey", selected_data).and_return("foo")
1607
+ expect(@rest).to receive(:put).with("nodes/picky-monkey", hash_including(selected_data)).and_return("foo")
1610
1608
  node.save
1611
1609
  end
1612
1610
 
1613
- it "should save all attributes if the blacklist is empty" do
1614
- Chef::Config[:automatic_attribute_blacklist] = []
1611
+ it "should save all attributes if the blacklist is empty" do
1612
+ Chef::Config[:default_attribute_blacklist] = []
1615
1613
 
1616
- data = {
1617
- "automatic" => {
1614
+ node.default = {
1618
1615
  "filesystem" => {
1619
1616
  "/dev/disk0s2" => { "size" => "10mb" },
1620
1617
  "map - autohome" => { "size" => "10mb" },
1621
1618
  },
1622
- },
1623
- "default" => {}, "normal" => {}, "override" => {}
1624
- }
1619
+ }
1620
+ node.automatic = {}
1621
+ node.normal = {}
1622
+ node.override = {}
1625
1623
 
1626
1624
  selected_data = {
1627
- "automatic" => {
1625
+ "default" => {
1628
1626
  "filesystem" => {
1629
1627
  "/dev/disk0s2" => { "size" => "10mb" },
1630
1628
  "map - autohome" => { "size" => "10mb" },
1631
1629
  },
1632
1630
  },
1633
- "default" => {}, "normal" => {}, "override" => {}
1631
+ "automatic" => {}, "normal" => {}, "override" => {}
1634
1632
  }
1635
1633
 
1636
1634
  node.name("picky-monkey")
1637
- allow(node).to receive(:for_json).and_return(data)
1638
- expect(@rest).to receive(:put).with("nodes/picky-monkey", selected_data).and_return("foo")
1635
+ expect(@rest).to receive(:put).with("nodes/picky-monkey", hash_including(selected_data)).and_return("foo")
1639
1636
  node.save
1640
1637
  end
1641
1638
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.12.3
4
+ version: 14.12.9
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-15 00:00:00.000000000 Z
11
+ date: 2019-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 14.12.3
19
+ version: 14.12.9
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: 14.12.3
26
+ version: 14.12.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-cli
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -2058,6 +2058,7 @@ files:
2058
2058
  - spec/integration/knife/cookbook_upload_spec.rb
2059
2059
  - spec/integration/knife/data_bag_create_spec.rb
2060
2060
  - spec/integration/knife/data_bag_delete_spec.rb
2061
+ - spec/integration/knife/data_bag_edit_spec.rb
2061
2062
  - spec/integration/knife/data_bag_from_file_spec.rb
2062
2063
  - spec/integration/knife/data_bag_list_spec.rb
2063
2064
  - spec/integration/knife/data_bag_show_spec.rb