summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-04-30 16:55:57 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-05-04 10:57:09 -0700
commitc54c28cbc613bd2a13d000af720c2859dc898a49 (patch)
tree244c117dcf215f896efb2bf32265c47250f76771
parenta874fce5a4f7e79f7319e5959b6802ad48c45344 (diff)
downloadchef-c54c28cbc613bd2a13d000af720c2859dc898a49.tar.gz
add a spec test + linebreaks
-rw-r--r--lib/chef/node.rb10
-rw-r--r--spec/integration/client/client_spec.rb5
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index cc79a187a9..8c41d7e10e 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -83,7 +83,15 @@ class Chef
end
def chef_server_rest
- @chef_server_rest ||= Chef::REST.new(Chef::Config[:chef_server_url], Chef::Config[:node_name], Chef::Config[:client_key], validate_utf8: false)
+ # for saving node data we use validate_utf8: false which will not
+ # raise an exception on bad utf8 data, but will replace the bad
+ # characters and render valid JSON.
+ @chef_server_rest ||= Chef::REST.new(
+ Chef::Config[:chef_server_url],
+ Chef::Config[:node_name],
+ Chef::Config[:client_key],
+ validate_utf8: false,
+ )
end
# Set the name of this Node, or return the current name.
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index 69822b8a25..1a97acb561 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -87,6 +87,11 @@ EOM
result.error!
end
+ it "should be able to node.save with bad utf8 characters in the node data" do
+ file "cookbooks/x/attributes/default.rb", 'default["badutf8"] = "Elan Ruusam\xE4e"'
+ result = shell_out("#{chef_client} -z -r 'x::default' --disable-config", :cwd => path_to(''))
+ result.error!
+ end
context 'and no config file' do
it 'should complete with success when cwd is just above cookbooks and paths are not specified' do