chef 11.16.4-x86-mingw32 → 11.18.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/lib/chef/api_client.rb +1 -1
  4. data/lib/chef/chef_fs/chef_fs_data_store.rb +3 -2
  5. data/lib/chef/chef_fs/command_line.rb +3 -2
  6. data/lib/chef/chef_fs/data_handler/group_data_handler.rb +5 -1
  7. data/lib/chef/chef_fs/file_system/acl_entry.rb +2 -1
  8. data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +2 -1
  9. data/lib/chef/chef_fs/file_system/rest_list_dir.rb +3 -2
  10. data/lib/chef/chef_fs/file_system/rest_list_entry.rb +5 -4
  11. data/lib/chef/config_fetcher.rb +1 -1
  12. data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
  13. data/lib/chef/cookbook/metadata.rb +1 -1
  14. data/lib/chef/cookbook_version.rb +2 -2
  15. data/lib/chef/data_bag.rb +1 -1
  16. data/lib/chef/data_bag_item.rb +1 -1
  17. data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
  18. data/lib/chef/environment.rb +1 -1
  19. data/lib/chef/exceptions.rb +19 -2
  20. data/lib/chef/json_compat.rb +64 -45
  21. data/lib/chef/knife/bootstrap.rb +2 -2
  22. data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
  23. data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
  24. data/lib/chef/knife/bootstrap/chef-aix.erb +2 -2
  25. data/lib/chef/knife/bootstrap/chef-full.erb +2 -2
  26. data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -2
  27. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
  28. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -2
  29. data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -2
  30. data/lib/chef/knife/cookbook_site_download.rb +1 -1
  31. data/lib/chef/knife/cookbook_site_install.rb +34 -10
  32. data/lib/chef/knife/cookbook_site_list.rb +1 -1
  33. data/lib/chef/knife/cookbook_site_search.rb +1 -1
  34. data/lib/chef/knife/cookbook_site_share.rb +2 -2
  35. data/lib/chef/knife/cookbook_site_show.rb +3 -3
  36. data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
  37. data/lib/chef/knife/core/subcommand_loader.rb +24 -0
  38. data/lib/chef/knife/deps.rb +3 -2
  39. data/lib/chef/node.rb +1 -1
  40. data/lib/chef/provider/deploy/revision.rb +1 -1
  41. data/lib/chef/provider/dsc_script.rb +32 -5
  42. data/lib/chef/provider/env.rb +25 -10
  43. data/lib/chef/provider/remote_file/cache_control_data.rb +1 -1
  44. data/lib/chef/resource.rb +1 -1
  45. data/lib/chef/resource/dsc_script.rb +2 -16
  46. data/lib/chef/resource_collection.rb +1 -1
  47. data/lib/chef/resource_reporter.rb +3 -3
  48. data/lib/chef/role.rb +1 -1
  49. data/lib/chef/run_list.rb +1 -1
  50. data/lib/chef/user.rb +1 -1
  51. data/lib/chef/util/dsc/local_configuration_manager.rb +15 -11
  52. data/lib/chef/util/powershell/cmdlet_result.rb +2 -2
  53. data/lib/chef/version.rb +1 -2
  54. data/spec/data/bootstrap/test-hints.erb +1 -1
  55. data/spec/data/bootstrap/test.erb +1 -1
  56. data/spec/functional/knife/cookbook_delete_spec.rb +3 -3
  57. data/spec/functional/knife/exec_spec.rb +1 -1
  58. data/spec/functional/resource/dsc_script_spec.rb +92 -47
  59. data/spec/functional/resource/env_spec.rb +3 -4
  60. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -2
  61. data/spec/integration/knife/chef_fs_data_store_spec.rb +1 -1
  62. data/spec/integration/knife/chef_repo_path_spec.rb +6 -1
  63. data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -1
  64. data/spec/integration/knife/chefignore_spec.rb +1 -1
  65. data/spec/integration/knife/common_options_spec.rb +1 -1
  66. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -1
  67. data/spec/integration/knife/delete_spec.rb +1 -1
  68. data/spec/integration/knife/deps_spec.rb +1 -1
  69. data/spec/integration/knife/diff_spec.rb +3 -3
  70. data/spec/integration/knife/download_spec.rb +3 -3
  71. data/spec/integration/knife/list_spec.rb +1 -1
  72. data/spec/integration/knife/raw_spec.rb +11 -1
  73. data/spec/integration/knife/redirection_spec.rb +1 -1
  74. data/spec/integration/knife/serve_spec.rb +1 -1
  75. data/spec/integration/knife/show_spec.rb +1 -1
  76. data/spec/integration/knife/upload_spec.rb +9 -9
  77. data/spec/spec_helper.rb +6 -0
  78. data/spec/support/shared/integration/integration_helper.rb +1 -2
  79. data/spec/support/shared/shared_examples.rb +10 -0
  80. data/spec/tiny_server.rb +2 -1
  81. data/spec/unit/api_client_spec.rb +3 -3
  82. data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +63 -0
  83. data/spec/unit/config_fetcher_spec.rb +1 -1
  84. data/spec/unit/cookbook/metadata_spec.rb +7 -3
  85. data/spec/unit/cookbook_loader_spec.rb +1 -1
  86. data/spec/unit/cookbook_version_spec.rb +4 -0
  87. data/spec/unit/data_bag_item_spec.rb +5 -1
  88. data/spec/unit/data_bag_spec.rb +5 -1
  89. data/spec/unit/deprecation_spec.rb +1 -1
  90. data/spec/unit/encrypted_data_bag_item_spec.rb +14 -7
  91. data/spec/unit/environment_spec.rb +7 -3
  92. data/spec/unit/exceptions_spec.rb +6 -0
  93. data/spec/unit/json_compat_spec.rb +58 -17
  94. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +0 -1
  95. data/spec/unit/knife/cookbook_site_download_spec.rb +2 -1
  96. data/spec/unit/knife/cookbook_site_install_spec.rb +161 -116
  97. data/spec/unit/knife/cookbook_site_share_spec.rb +6 -6
  98. data/spec/unit/knife/core/bootstrap_context_spec.rb +2 -2
  99. data/spec/unit/knife/core/subcommand_loader_spec.rb +66 -1
  100. data/spec/unit/knife/data_bag_from_file_spec.rb +1 -2
  101. data/spec/unit/node_spec.rb +4 -0
  102. data/spec/unit/provider/dsc_script_spec.rb +134 -105
  103. data/spec/unit/provider/env/windows_spec.rb +2 -2
  104. data/spec/unit/provider/env_spec.rb +76 -11
  105. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +1 -1
  106. data/spec/unit/resource/dsc_script_spec.rb +0 -29
  107. data/spec/unit/resource_collection_spec.rb +5 -1
  108. data/spec/unit/resource_reporter_spec.rb +3 -3
  109. data/spec/unit/resource_spec.rb +5 -1
  110. data/spec/unit/role_spec.rb +4 -0
  111. data/spec/unit/run_list_spec.rb +5 -1
  112. data/spec/unit/user_spec.rb +5 -1
  113. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +15 -10
  114. metadata +11 -9
@@ -126,7 +126,8 @@ describe Chef::Resource::Env, :windows_only do
126
126
  context 'when using PATH' do
127
127
  let(:random_name) { Time.now.to_i }
128
128
  let(:env_val) { "#{env_value_expandable}_#{random_name}"}
129
- let(:path_before) { test_resource.provider_for_action(test_resource.action).env_value('PATH') }
129
+ let!(:path_before) { test_resource.provider_for_action(test_resource.action).env_value('PATH') || '' }
130
+ let!(:env_path_before) { ENV['PATH'] }
130
131
 
131
132
  it 'should expand PATH' do
132
133
  path_before.should_not include(env_val)
@@ -142,9 +143,7 @@ describe Chef::Resource::Env, :windows_only do
142
143
  test_resource.key_name('PATH')
143
144
  test_resource.value(path_before)
144
145
  test_resource.run_action(:create)
145
- if test_resource.provider_for_action(test_resource.action).env_value('PATH') != path_before
146
- raise 'Failed to cleanup after ourselves'
147
- end
146
+ ENV['PATH'] = env_path_before
148
147
  end
149
148
  end
150
149
 
@@ -16,7 +16,6 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'json'
20
19
  require File.expand_path('../../../../spec_helper', __FILE__)
21
20
 
22
21
  describe Chef::Util::Powershell::Cmdlet, :windows_only do
@@ -91,7 +90,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_only do
91
90
  it "returns json format data", :windows_powershell_dsc_only do
92
91
  result = cmdlet_alias_requires_switch_or_argument.run({},{},'ls')
93
92
  expect(result.succeeded?).to eq(true)
94
- expect(lambda{JSON.parse(result.return_value)}).not_to raise_error
93
+ expect(lambda{Chef::JSONCompat.parse(result.return_value)}).not_to raise_error
95
94
  end
96
95
  end
97
96
 
@@ -22,7 +22,7 @@ require 'chef/knife/show'
22
22
  require 'chef/knife/raw'
23
23
  require 'chef/knife/cookbook_upload'
24
24
 
25
- describe 'ChefFSDataStore tests' do
25
+ describe 'ChefFSDataStore tests', :workstation do
26
26
  extend IntegrationSupport
27
27
  include KnifeSupport
28
28
 
@@ -20,7 +20,7 @@ require 'support/shared/context/config'
20
20
  require 'chef/knife/list'
21
21
  require 'chef/knife/show'
22
22
 
23
- describe 'chef_repo_path tests' do
23
+ describe 'chef_repo_path tests', :workstation do
24
24
  extend IntegrationSupport
25
25
  include KnifeSupport
26
26
 
@@ -287,6 +287,7 @@ EOM
287
287
  knife('show --local /clients/blah.json').should_succeed <<EOM
288
288
  /clients/blah.json:
289
289
  {
290
+
290
291
  }
291
292
  EOM
292
293
  end
@@ -374,6 +375,7 @@ EOM
374
375
  knife('show --local /environments/blah.json').should_succeed <<EOM
375
376
  /environments/blah.json:
376
377
  {
378
+
377
379
  }
378
380
  EOM
379
381
  end
@@ -386,6 +388,7 @@ EOM
386
388
  knife('show --local /nodes/blah.json').should_succeed <<EOM
387
389
  /nodes/blah.json:
388
390
  {
391
+
389
392
  }
390
393
  EOM
391
394
  end
@@ -398,6 +401,7 @@ EOM
398
401
  knife('show --local /roles/blah.json').should_succeed <<EOM
399
402
  /roles/blah.json:
400
403
  {
404
+
401
405
  }
402
406
  EOM
403
407
  end
@@ -410,6 +414,7 @@ EOM
410
414
  knife('show --local /users/blah.json').should_succeed <<EOM
411
415
  /users/blah.json:
412
416
  {
417
+
413
418
  }
414
419
  EOM
415
420
  end
@@ -19,7 +19,7 @@ require 'support/shared/integration/integration_helper'
19
19
  require 'chef/knife/list'
20
20
  require 'chef/knife/show'
21
21
 
22
- describe 'General chef_repo file system checks' do
22
+ describe 'General chef_repo file system checks', :workstation do
23
23
  extend IntegrationSupport
24
24
  include KnifeSupport
25
25
 
@@ -19,7 +19,7 @@ require 'support/shared/integration/integration_helper'
19
19
  require 'chef/knife/list'
20
20
  require 'chef/knife/show'
21
21
 
22
- describe 'chefignore tests' do
22
+ describe 'chefignore tests', :workstation do
23
23
  extend IntegrationSupport
24
24
  include KnifeSupport
25
25
 
@@ -18,7 +18,7 @@
18
18
  require 'support/shared/integration/integration_helper'
19
19
  require 'chef/knife/raw'
20
20
 
21
- describe 'knife common options' do
21
+ describe 'knife common options', :workstation do
22
22
  extend IntegrationSupport
23
23
  include KnifeSupport
24
24
 
@@ -18,7 +18,7 @@
18
18
  require 'support/shared/integration/integration_helper'
19
19
  require 'chef/mixin/shell_out'
20
20
 
21
- describe "Knife cookbook API integration with IPv6" do
21
+ describe "Knife cookbook API integration with IPv6", :workstation do
22
22
  extend IntegrationSupport
23
23
  include Chef::Mixin::ShellOut
24
24
 
@@ -20,7 +20,7 @@ require 'chef/knife/delete'
20
20
  require 'chef/knife/list'
21
21
  require 'chef/knife/raw'
22
22
 
23
- describe 'knife delete' do
23
+ describe 'knife delete', :workstation do
24
24
  extend IntegrationSupport
25
25
  include KnifeSupport
26
26
 
@@ -19,7 +19,7 @@ require 'support/shared/integration/integration_helper'
19
19
  require 'support/shared/context/config'
20
20
  require 'chef/knife/deps'
21
21
 
22
- describe 'knife deps' do
22
+ describe 'knife deps', :workstation do
23
23
  extend IntegrationSupport
24
24
  include KnifeSupport
25
25
 
@@ -18,7 +18,7 @@
18
18
  require 'support/shared/integration/integration_helper'
19
19
  require 'chef/knife/diff'
20
20
 
21
- describe 'knife diff' do
21
+ describe 'knife diff', :workstation do
22
22
  extend IntegrationSupport
23
23
  include KnifeSupport
24
24
 
@@ -275,7 +275,7 @@ EOM
275
275
  when_the_repository 'has an environment with bad JSON' do
276
276
  file 'environments/x.json', '{'
277
277
  it 'knife diff reports an error and does a textual diff' do
278
- knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n")
278
+ knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => /WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF\n/)
279
279
  end
280
280
  end
281
281
  end
@@ -528,7 +528,7 @@ EOM
528
528
  when_the_repository 'has an environment with bad JSON' do
529
529
  file 'environments/x.json', '{'
530
530
  it 'knife diff reports an error and does a textual diff' do
531
- knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n")
531
+ knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => /WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF\n/)
532
532
  end
533
533
  end
534
534
  end
@@ -19,7 +19,7 @@ require 'support/shared/integration/integration_helper'
19
19
  require 'chef/knife/download'
20
20
  require 'chef/knife/diff'
21
21
 
22
- describe 'knife download' do
22
+ describe 'knife download', :workstation do
23
23
  extend IntegrationSupport
24
24
  include KnifeSupport
25
25
 
@@ -496,7 +496,7 @@ EOM
496
496
  when_the_repository 'has an environment with bad JSON' do
497
497
  file 'environments/x.json', '{'
498
498
  it 'knife download succeeds' do
499
- knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n", :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n"
499
+ knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n", :stderr => /WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF\n/
500
500
  knife('diff --name-status /environments/x.json').should_succeed ''
501
501
  end
502
502
  end
@@ -946,7 +946,7 @@ EOM
946
946
  when_the_repository 'has an environment with bad JSON' do
947
947
  file 'environments/x.json', '{'
948
948
  it 'knife download succeeds' do
949
- knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n", :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n"
949
+ knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n", :stderr => /WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF\n/
950
950
  knife('diff --name-status /environments/x.json').should_succeed ''
951
951
  end
952
952
  end
@@ -19,7 +19,7 @@ require 'support/shared/integration/integration_helper'
19
19
  require 'support/shared/context/config'
20
20
  require 'chef/knife/list'
21
21
 
22
- describe 'knife list' do
22
+ describe 'knife list', :workstation do
23
23
  extend IntegrationSupport
24
24
  include KnifeSupport
25
25
 
@@ -20,7 +20,7 @@ require 'support/shared/context/config'
20
20
  require 'chef/knife/raw'
21
21
  require 'chef/knife/show'
22
22
 
23
- describe 'knife raw' do
23
+ describe 'knife raw', :workstation do
24
24
  extend IntegrationSupport
25
25
  include KnifeSupport
26
26
  include AppServerSupport
@@ -44,12 +44,16 @@ describe 'knife raw' do
44
44
  "chef_type": "node",
45
45
  "chef_environment": "_default",
46
46
  "override": {
47
+
47
48
  },
48
49
  "normal": {
50
+
49
51
  },
50
52
  "default": {
53
+
51
54
  },
52
55
  "automatic": {
56
+
53
57
  },
54
58
  "run_list": [
55
59
 
@@ -70,13 +74,16 @@ EOM
70
74
  "json_class": "Chef::Role",
71
75
  "chef_type": "role",
72
76
  "default_attributes": {
77
+
73
78
  },
74
79
  "override_attributes": {
80
+
75
81
  },
76
82
  "run_list": [
77
83
 
78
84
  ],
79
85
  "env_run_lists": {
86
+
80
87
  }
81
88
  }
82
89
  EOM
@@ -111,13 +118,16 @@ EOM
111
118
  "json_class": "Chef::Role",
112
119
  "chef_type": "role",
113
120
  "default_attributes": {
121
+
114
122
  },
115
123
  "override_attributes": {
124
+
116
125
  },
117
126
  "run_list": [
118
127
 
119
128
  ],
120
129
  "env_run_lists": {
130
+
121
131
  }
122
132
  }
123
133
  EOM
@@ -19,7 +19,7 @@ require 'support/shared/integration/integration_helper'
19
19
  require 'support/shared/context/config'
20
20
  require 'chef/knife/list'
21
21
 
22
- describe 'redirection' do
22
+ describe 'redirection', :workstation do
23
23
  extend IntegrationSupport
24
24
  include KnifeSupport
25
25
  include AppServerSupport
@@ -19,7 +19,7 @@ require 'support/shared/integration/integration_helper'
19
19
  require 'chef/knife/serve'
20
20
  require 'chef/server_api'
21
21
 
22
- describe 'knife serve' do
22
+ describe 'knife serve', :workstation do
23
23
  extend IntegrationSupport
24
24
  include KnifeSupport
25
25
  include AppServerSupport
@@ -19,7 +19,7 @@ require 'support/shared/integration/integration_helper'
19
19
  require 'support/shared/context/config'
20
20
  require 'chef/knife/show'
21
21
 
22
- describe 'knife show' do
22
+ describe 'knife show', :workstation do
23
23
  extend IntegrationSupport
24
24
  include KnifeSupport
25
25
 
@@ -20,7 +20,7 @@ require 'chef/knife/upload'
20
20
  require 'chef/knife/diff'
21
21
  require 'chef/knife/raw'
22
22
 
23
- describe 'knife upload' do
23
+ describe 'knife upload', :workstation do
24
24
  extend IntegrationSupport
25
25
  include KnifeSupport
26
26
 
@@ -237,7 +237,7 @@ Created /data_bags/x/y.json
237
237
  EOM
238
238
  knife('diff --name-status /data_bags').should_succeed <<EOM
239
239
  EOM
240
- JSON.parse(knife('raw /data/x/y').stdout, :create_additions => false).keys.sort.should == [ 'foo', 'id' ]
240
+ Chef::JSONCompat.parse(knife('raw /data/x/y').stdout, :create_additions => false).keys.sort.should == [ 'foo', 'id' ]
241
241
  end
242
242
 
243
243
  it 'knife upload /data_bags/x /data_bags/x/y.json uploads x once' do
@@ -256,7 +256,7 @@ Created /data_bags/x
256
256
  Created /data_bags/x/y.json
257
257
  EOM
258
258
  knife('diff --name-status /data_bags').should_succeed ''
259
- result = JSON.parse(knife('raw /data/x/y').stdout, :create_additions => false)
259
+ result = Chef::JSONCompat.parse(knife('raw /data/x/y').stdout, :create_additions => false)
260
260
  result.keys.sort.should == [ 'chef_type', 'data_bag', 'id' ]
261
261
  result['chef_type'].should == 'aaa'
262
262
  result['data_bag'].should == 'bbb'
@@ -528,8 +528,8 @@ EOM
528
528
  when_the_repository 'has an environment with bad JSON' do
529
529
  file 'environments/x.json', '{'
530
530
  it 'knife upload tries and fails' do
531
- knife('upload /environments/x.json').should_fail "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\nERROR: /environments/x.json failed to write: Parse error reading JSON: A JSON text must at least contain two octets!\n"
532
- knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n", :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n"
531
+ knife('upload /environments/x.json').should_fail /WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF\n.+ERROR: \/environments\/x.json failed to write: Parse error reading JSON: parse error: premature EOF\n/m
532
+ knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n", :stderr => /WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF\n/
533
533
  end
534
534
  end
535
535
 
@@ -554,7 +554,7 @@ EOM
554
554
  when_the_repository 'has an environment with bad JSON' do
555
555
  file 'environments/x.json', '{'
556
556
  it 'knife upload tries and fails' do
557
- knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Parse error reading JSON creating child 'x.json': A JSON text must at least contain two octets!\n"
557
+ knife('upload /environments/x.json').should_fail /ERROR: \/environments failed to create_child: Parse error reading JSON creating child 'x.json': parse error: premature EOF\n/
558
558
  knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n"
559
559
  end
560
560
  end
@@ -1007,8 +1007,8 @@ EOM
1007
1007
  when_the_repository 'has an environment with bad JSON' do
1008
1008
  file 'environments/x.json', '{'
1009
1009
  it 'knife upload tries and fails' do
1010
- knife('upload /environments/x.json').should_fail "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\nERROR: /environments/x.json failed to write: Parse error reading JSON: A JSON text must at least contain two octets!\n"
1011
- knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n", :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n"
1010
+ knife('upload /environments/x.json').should_fail /WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF\n.+ERROR: \/environments\/x.json failed to write: Parse error reading JSON: parse error: premature EOF\n/m
1011
+ knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n", :stderr => /WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF\n/
1012
1012
  end
1013
1013
  end
1014
1014
 
@@ -1033,7 +1033,7 @@ EOM
1033
1033
  when_the_repository 'has an environment with bad JSON' do
1034
1034
  file 'environments/x.json', '{'
1035
1035
  it 'knife upload tries and fails' do
1036
- knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Parse error reading JSON creating child 'x.json': A JSON text must at least contain two octets!\n"
1036
+ knife('upload /environments/x.json').should_fail /ERROR: \/environments failed to create_child: Parse error reading JSON creating child 'x.json': parse error: premature EOF\n/
1037
1037
  knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n"
1038
1038
  end
1039
1039
  end
@@ -97,6 +97,9 @@ RSpec.configure do |config|
97
97
  config.filter_run :focus => true
98
98
  config.filter_run_excluding :external => true
99
99
 
100
+ # Only run these tests on platforms that are also chef workstations
101
+ config.filter_run_excluding :workstation if solaris?
102
+
100
103
  # Tests that randomly fail, but may have value.
101
104
  config.filter_run_excluding :volatile => true
102
105
  config.filter_run_excluding :volatile_on_solaris => true if solaris?
@@ -182,3 +185,6 @@ module WEBrick
182
185
  end
183
186
  end
184
187
  end
188
+
189
+ # Enough stuff needs json serialization that I'm just adding it here for equality asserts
190
+ require 'chef/json_compat'
@@ -21,7 +21,6 @@ require 'tmpdir'
21
21
  require 'fileutils'
22
22
  require 'chef/config'
23
23
  require 'chef_zero/rspec'
24
- require 'json'
25
24
  require 'support/shared/integration/knife_support'
26
25
  require 'support/shared/integration/app_server_support'
27
26
  require 'spec_helper'
@@ -69,7 +68,7 @@ module IntegrationSupport
69
68
  File.open(filename, 'w') do |file|
70
69
  raw = case contents
71
70
  when Hash
72
- JSON.pretty_generate(contents)
71
+ Chef::JSONCompat.to_json_pretty(contents)
73
72
  when Array
74
73
  contents.join("\n")
75
74
  else
@@ -0,0 +1,10 @@
1
+ # For storing any examples shared between multiple tests
2
+
3
+ # Any object which defines a .to_json should import this test
4
+ shared_examples "to_json equalivent to Chef::JSONCompat.to_json" do
5
+
6
+ it "should allow consumers to call #to_json or Chef::JSONCompat.to_json" do
7
+ expect(subject.to_json).to eq(Chef::JSONCompat.to_json(subject))
8
+ end
9
+
10
+ end
@@ -25,6 +25,7 @@ require 'singleton'
25
25
  require 'chef/json_compat'
26
26
  require 'open-uri'
27
27
  require 'chef/config'
28
+ require 'chef/json_compat'
28
29
 
29
30
  module TinyServer
30
31
 
@@ -152,7 +153,7 @@ module TinyServer
152
153
  :available_routes => @routes, :request => env}
153
154
  # Uncomment me for glorious debugging
154
155
  # pp :not_found => debug_info
155
- [404, {'Content-Type' => 'application/json'}, [ debug_info.to_json ]]
156
+ [404, {'Content-Type' => 'application/json'}, [ Chef::JSONCompat.to_json(debug_info) ]]
156
157
  end
157
158
  end
158
159
 
@@ -92,7 +92,7 @@ describe Chef::ApiClient do
92
92
  before(:each) do
93
93
  @client.name("black")
94
94
  @client.public_key("crowes")
95
- @json = @client.to_json
95
+ @json = Chef::JSONCompat.to_json(@client)
96
96
  end
97
97
 
98
98
  it "serializes as a JSON object" do
@@ -117,7 +117,7 @@ describe Chef::ApiClient do
117
117
 
118
118
  it "includes the private key when present" do
119
119
  @client.private_key("monkeypants")
120
- @client.to_json.should include(%q{"private_key":"monkeypants"})
120
+ Chef::JSONCompat.to_json(@client).should include(%q{"private_key":"monkeypants"})
121
121
  end
122
122
 
123
123
  it "does not include the private key if not present" do
@@ -135,7 +135,7 @@ describe Chef::ApiClient do
135
135
  "validator" => true,
136
136
  "json_class" => "Chef::ApiClient"
137
137
  }
138
- @client = Chef::JSONCompat.from_json(client.to_json)
138
+ @client = Chef::JSONCompat.from_json(Chef::JSONCompat.to_json(client))
139
139
  end
140
140
 
141
141
  it "should deserialize to a Chef::ApiClient object" do