chef 12.17.44-universal-mingw32 → 12.18.31-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/README.md +3 -2
  4. data/Rakefile +9 -0
  5. data/VERSION +1 -1
  6. data/acceptance/Gemfile.lock +17 -17
  7. data/distro/common/html/knife_environment.html +4 -8
  8. data/distro/common/man/man1/knife-environment.1 +4 -16
  9. data/distro/powershell/chef/chef.psm1 +139 -24
  10. data/lib/chef/application.rb +5 -4
  11. data/lib/chef/application/windows_service_manager.rb +6 -4
  12. data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
  13. data/lib/chef/chef_fs/command_line.rb +1 -1
  14. data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +8 -1
  15. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +1 -1
  16. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +1 -1
  17. data/lib/chef/cookbook/chefignore.rb +1 -1
  18. data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
  19. data/lib/chef/cookbook/metadata.rb +2 -2
  20. data/lib/chef/cookbook_loader.rb +1 -1
  21. data/lib/chef/data_collector.rb +24 -13
  22. data/lib/chef/data_collector/messages.rb +8 -6
  23. data/lib/chef/data_collector/messages/helpers.rb +1 -1
  24. data/lib/chef/deprecated.rb +30 -0
  25. data/lib/chef/dsl/platform_introspection.rb +2 -2
  26. data/lib/chef/encrypted_data_bag_item.rb +1 -1
  27. data/lib/chef/encrypted_data_bag_item/decryptor.rb +2 -2
  28. data/lib/chef/environment.rb +1 -1
  29. data/lib/chef/exceptions.rb +5 -5
  30. data/lib/chef/file_access_control/unix.rb +5 -5
  31. data/lib/chef/formatters/error_description.rb +1 -1
  32. data/lib/chef/http/basic_client.rb +1 -1
  33. data/lib/chef/http/json_input.rb +2 -2
  34. data/lib/chef/knife.rb +1 -1
  35. data/lib/chef/knife/cookbook_site_install.rb +1 -1
  36. data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
  37. data/lib/chef/knife/core/ui.rb +1 -1
  38. data/lib/chef/mixin/command.rb +1 -0
  39. data/lib/chef/mixin/deep_merge.rb +1 -1
  40. data/lib/chef/mixin/shell_out.rb +58 -3
  41. data/lib/chef/mixin/which.rb +5 -9
  42. data/lib/chef/mixin/wide_string.rb +1 -1
  43. data/lib/chef/node.rb +1 -1
  44. data/lib/chef/node/attribute.rb +4 -5
  45. data/lib/chef/node_map.rb +18 -2
  46. data/lib/chef/platform/provider_handler_map.rb +2 -2
  47. data/lib/chef/platform/provider_mapping.rb +5 -0
  48. data/lib/chef/platform/resource_handler_map.rb +2 -2
  49. data/lib/chef/provider/env/windows.rb +1 -1
  50. data/lib/chef/provider/git.rb +1 -1
  51. data/lib/chef/provider/group.rb +41 -46
  52. data/lib/chef/provider/group/aix.rb +12 -19
  53. data/lib/chef/provider/group/dscl.rb +46 -43
  54. data/lib/chef/provider/group/gpasswd.rb +7 -7
  55. data/lib/chef/provider/group/groupadd.rb +29 -34
  56. data/lib/chef/provider/group/groupmod.rb +26 -31
  57. data/lib/chef/provider/group/pw.rb +28 -31
  58. data/lib/chef/provider/group/suse.rb +9 -9
  59. data/lib/chef/provider/group/usermod.rb +10 -11
  60. data/lib/chef/provider/group/windows.rb +18 -20
  61. data/lib/chef/provider/ifconfig.rb +52 -63
  62. data/lib/chef/provider/ifconfig/aix.rb +23 -28
  63. data/lib/chef/provider/ifconfig/debian.rb +23 -22
  64. data/lib/chef/provider/ifconfig/redhat.rb +12 -12
  65. data/lib/chef/provider/mount/mount.rb +1 -1
  66. data/lib/chef/provider/osx_profile.rb +4 -2
  67. data/lib/chef/provider/package.rb +16 -7
  68. data/lib/chef/provider/package/chocolatey.rb +3 -1
  69. data/lib/chef/provider/package/dnf.rb +183 -0
  70. data/lib/chef/provider/package/dnf/dnf_helper.py +91 -0
  71. data/lib/chef/provider/package/dnf/python_helper.rb +120 -0
  72. data/lib/chef/provider/package/dnf/version.rb +56 -0
  73. data/lib/chef/provider/package/easy_install.rb +1 -1
  74. data/lib/chef/provider/package/freebsd/base.rb +1 -1
  75. data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
  76. data/lib/chef/provider/package/powershell.rb +3 -3
  77. data/lib/chef/provider/package/windows.rb +1 -1
  78. data/lib/chef/provider/package/zypper.rb +1 -1
  79. data/lib/chef/provider/route.rb +186 -184
  80. data/lib/chef/provider/service/arch.rb +2 -2
  81. data/lib/chef/provider/service/freebsd.rb +1 -1
  82. data/lib/chef/provider/service/gentoo.rb +2 -2
  83. data/lib/chef/provider/service/insserv.rb +2 -2
  84. data/lib/chef/provider/service/macosx.rb +2 -2
  85. data/lib/chef/provider/service/openbsd.rb +1 -1
  86. data/lib/chef/provider/service/redhat.rb +2 -2
  87. data/lib/chef/provider/support/yum_repo.erb +10 -3
  88. data/lib/chef/provider/user.rb +17 -20
  89. data/lib/chef/provider/user/aix.rb +23 -24
  90. data/lib/chef/provider/user/dscl.rb +56 -53
  91. data/lib/chef/provider/user/linux.rb +13 -16
  92. data/lib/chef/provider/user/pw.rb +26 -30
  93. data/lib/chef/provider/user/solaris.rb +11 -12
  94. data/lib/chef/provider/user/useradd.rb +20 -22
  95. data/lib/chef/provider/user/windows.rb +19 -22
  96. data/lib/chef/provider_resolver.rb +4 -2
  97. data/lib/chef/providers.rb +1 -0
  98. data/lib/chef/resource.rb +7 -0
  99. data/lib/chef/resource/chocolatey_package.rb +1 -0
  100. data/lib/chef/resource/dnf_package.rb +64 -0
  101. data/lib/chef/resource/file/verification.rb +6 -4
  102. data/lib/chef/resource/yum_package.rb +18 -14
  103. data/lib/chef/resource/yum_repository.rb +1 -1
  104. data/lib/chef/resource_reporter.rb +11 -0
  105. data/lib/chef/resources.rb +1 -0
  106. data/lib/chef/scan_access_control.rb +4 -4
  107. data/lib/chef/util/dsc/resource_store.rb +1 -1
  108. data/lib/chef/version.rb +1 -1
  109. data/lib/chef/win32/memory.rb +1 -1
  110. data/lib/chef/win32/security.rb +2 -2
  111. data/lib/chef/win32/security/sid.rb +2 -2
  112. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.i686.rpm +0 -0
  113. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.src.rpm +0 -0
  114. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.x86_64.rpm +0 -0
  115. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.i686.rpm +0 -0
  116. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.src.rpm +0 -0
  117. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.x86_64.rpm +0 -0
  118. data/spec/functional/assets/yumrepo/repodata/313329137b55fd333b2dc66394a6661a2befa6cc535d8460d92a4a78a9c581f0-primary.sqlite.bz2 +0 -0
  119. data/spec/functional/assets/yumrepo/repodata/31ac4db5d5ac593728fcc26aef82b7b93c4cc4dbec843786b1845b939b658553-other.xml.gz +0 -0
  120. data/spec/functional/assets/yumrepo/repodata/4ac40fa3c6728c1401318e2e20a997436624e83dcf7a5f952b851ef422637773-filelists.sqlite.bz2 +0 -0
  121. data/spec/functional/assets/yumrepo/repodata/66391e53f0510b98b3f0b79f40ba1048026d9a1ef20905d9c40ba6f5411f3243-primary.xml.gz +0 -0
  122. data/spec/functional/assets/yumrepo/repodata/8b34697595fcc87928e12d24644dda9462c3857bd932861e28bc77ae1f31be16-filelists.xml.gz +0 -0
  123. data/spec/functional/assets/yumrepo/repodata/b97cca3fe14bcf06c52be4449b6108f7731239ff221111dcce8aada5467f60dc-other.sqlite.bz2 +0 -0
  124. data/spec/functional/assets/yumrepo/repodata/repomd.xml +55 -0
  125. data/spec/functional/resource/dnf_package_spec.rb +686 -0
  126. data/spec/functional/resource/dsc_script_spec.rb +1 -0
  127. data/spec/functional/resource/user/useradd_spec.rb +10 -1
  128. data/spec/integration/knife/chef_repo_path_spec.rb +2 -2
  129. data/spec/integration/recipes/recipe_dsl_spec.rb +3 -0
  130. data/spec/integration/recipes/resource_load_spec.rb +3 -3
  131. data/spec/spec_helper.rb +5 -3
  132. data/spec/support/lib/chef/provider/snakeoil.rb +1 -0
  133. data/spec/support/lib/chef/resource/cat.rb +1 -0
  134. data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -0
  135. data/spec/support/lib/chef/resource/openldap_includer.rb +2 -0
  136. data/spec/support/lib/chef/resource/with_state.rb +2 -0
  137. data/spec/support/lib/chef/resource/zen_master.rb +1 -0
  138. data/spec/unit/cookbook/metadata_spec.rb +3 -3
  139. data/spec/unit/data_collector/messages/helpers_spec.rb +7 -0
  140. data/spec/unit/data_collector_spec.rb +56 -0
  141. data/spec/unit/decorator/lazy_spec.rb +1 -1
  142. data/spec/unit/environment_spec.rb +1 -1
  143. data/spec/unit/lwrp_spec.rb +3 -4
  144. data/spec/unit/node_spec.rb +23 -2
  145. data/spec/unit/platform_spec.rb +1 -0
  146. data/spec/unit/provider/group/dscl_spec.rb +29 -29
  147. data/spec/unit/provider/group/gpasswd_spec.rb +10 -10
  148. data/spec/unit/provider/group/groupadd_spec.rb +31 -30
  149. data/spec/unit/provider/group/groupmod_spec.rb +16 -16
  150. data/spec/unit/provider/group/pw_spec.rb +11 -11
  151. data/spec/unit/provider/group/suse_spec.rb +5 -5
  152. data/spec/unit/provider/group/usermod_spec.rb +15 -15
  153. data/spec/unit/provider/ifconfig/aix_spec.rb +14 -14
  154. data/spec/unit/provider/ifconfig/debian_spec.rb +10 -22
  155. data/spec/unit/provider/ifconfig/redhat_spec.rb +4 -4
  156. data/spec/unit/provider/ifconfig_spec.rb +18 -19
  157. data/spec/unit/provider/package/chocolatey_spec.rb +21 -21
  158. data/spec/unit/provider/package/msu_spec.rb +1 -1
  159. data/spec/unit/provider/route_spec.rb +21 -21
  160. data/spec/unit/provider/user/dscl_spec.rb +54 -57
  161. data/spec/unit/provider/user/linux_spec.rb +5 -5
  162. data/spec/unit/provider/user/pw_spec.rb +26 -22
  163. data/spec/unit/provider/user/windows_spec.rb +4 -4
  164. data/spec/unit/provider/user_spec.rb +19 -21
  165. data/spec/unit/provider_resolver_spec.rb +1 -0
  166. data/spec/unit/resource/chocolatey_package_spec.rb +12 -0
  167. data/spec/unit/resource/dnf_package_spec.rb +99 -0
  168. data/spec/unit/resource/remote_file_spec.rb +2 -2
  169. data/spec/unit/resource/yum_package_spec.rb +20 -0
  170. data/spec/unit/resource_reporter_spec.rb +24 -0
  171. data/spec/unit/resource_spec.rb +2 -0
  172. data/spec/unit/runner_spec.rb +1 -0
  173. data/tasks/bin/bundle-platform +1 -1
  174. data/tasks/gemfile_util.rb +2 -2
  175. data/tasks/templates/prerelease.md.erb +1 -10
  176. data/tasks/templates/release.md.erb +1 -9
  177. metadata +24 -5
  178. data/lib/chef/platform/handler_map.rb +0 -40
@@ -27,11 +27,11 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
27
27
  @new_resource.members %w{lobster rage fist}
28
28
  @new_resource.append false
29
29
  @provider = Chef::Provider::Group::Gpasswd.new(@new_resource, @run_context)
30
- #@provider.stub(:run_command).and_return(true)
30
+ # @provider.stub(:run_command).and_return(true)
31
31
  end
32
32
 
33
33
  describe "when determining the current group state" do
34
- before (:each) do
34
+ before(:each) do
35
35
  @provider.action = :create
36
36
  @provider.load_current_resource
37
37
  @provider.define_resource_requirements
@@ -41,13 +41,13 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
41
41
  # for Chef::Provider::Group - no need to repeat it here. We'll
42
42
  # include only what's specific to this provider.
43
43
  it "should raise an error if the required binary /usr/bin/gpasswd doesn't exist" do
44
- allow(File).to receive(:exists?).and_return(true)
45
- expect(File).to receive(:exists?).with("/usr/bin/gpasswd").and_return(false)
44
+ allow(File).to receive(:exist?).and_return(true)
45
+ expect(File).to receive(:exist?).with("/usr/bin/gpasswd").and_return(false)
46
46
  expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Group)
47
47
  end
48
48
 
49
49
  it "shouldn't raise an error if the required binaries exist" do
50
- allow(File).to receive(:exists?).and_return(true)
50
+ allow(File).to receive(:exist?).and_return(true)
51
51
  expect { @provider.process_resource_requirements }.not_to raise_error
52
52
  end
53
53
  end
@@ -66,7 +66,7 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
66
66
 
67
67
  it "logs a message and sets group's members to 'none'" do
68
68
  expect(Chef::Log).to receive(:debug).with("group[wheel] setting group members to: none")
69
- expect(@provider).to receive(:shell_out!).with("gpasswd -M \"\" wheel")
69
+ expect(@provider).to receive(:shell_out!).with("gpasswd", "-M", "", "wheel")
70
70
  @provider.modify_group_members
71
71
  end
72
72
  end
@@ -91,7 +91,7 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
91
91
  end
92
92
 
93
93
  it "should run gpasswd with the members joined by ',' followed by the target group" do
94
- expect(@provider).to receive(:shell_out!).with("gpasswd -M lobster,rage,fist wheel")
94
+ expect(@provider).to receive(:shell_out!).with("gpasswd", "-M", "lobster,rage,fist", "wheel")
95
95
  @provider.modify_group_members
96
96
  end
97
97
 
@@ -104,9 +104,9 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
104
104
 
105
105
  it "should run gpasswd individually for each user when the append option is set" do
106
106
  @new_resource.append(true)
107
- expect(@provider).to receive(:shell_out!).with("gpasswd -a lobster wheel")
108
- expect(@provider).to receive(:shell_out!).with("gpasswd -a rage wheel")
109
- expect(@provider).to receive(:shell_out!).with("gpasswd -a fist wheel")
107
+ expect(@provider).to receive(:shell_out!).with("gpasswd", "-a", "lobster", "wheel")
108
+ expect(@provider).to receive(:shell_out!).with("gpasswd", "-a", "rage", "wheel")
109
+ expect(@provider).to receive(:shell_out!).with("gpasswd", "-a", "fist", "wheel")
110
110
  @provider.modify_group_members
111
111
  end
112
112
  end
@@ -46,7 +46,7 @@ describe Chef::Provider::Group::Groupadd do
46
46
 
47
47
  describe "#set_options" do
48
48
  field_list = {
49
- :gid => "-g",
49
+ gid: "-g",
50
50
  }
51
51
 
52
52
  field_list.each do |attribute, option|
@@ -58,36 +58,37 @@ describe Chef::Provider::Group::Groupadd do
58
58
 
59
59
  it "should set the option for #{attribute} if the new resources #{attribute} is not null" do
60
60
  allow(new_resource).to receive(attribute).and_return("wowaweea")
61
- expect(provider.set_options).to eql(" #{option} '#{new_resource.send(attribute)}' #{new_resource.group_name}")
61
+ expect(provider.set_options).to eql([ option, new_resource.send(attribute), new_resource.group_name])
62
62
  end
63
63
  end
64
64
 
65
65
  it "should combine all the possible options" do
66
- match_string = ""
66
+ match_array = []
67
67
  field_list.sort { |a, b| a[0] <=> b[0] }.each do |attribute, option|
68
68
  allow(new_resource).to receive(attribute).and_return("hola")
69
- match_string << " #{option} 'hola'"
69
+ match_array << option
70
+ match_array << "hola"
70
71
  end
71
- match_string << " aj"
72
- expect(provider.set_options).to eql(match_string)
72
+ match_array << "aj"
73
+ expect(provider.set_options).to eql(match_array)
73
74
  end
74
75
 
75
76
  describe "when we want to create a system group" do
76
77
  it "should not set groupadd_options '-r' when system is false" do
77
78
  new_resource.system(false)
78
- expect(provider.groupadd_options).not_to match(/-r/)
79
+ expect(provider.groupadd_options).to eq([])
79
80
  end
80
81
 
81
82
  it "should set groupadd -r if system is true" do
82
83
  new_resource.system(true)
83
- expect(provider.groupadd_options).to eq(" -r")
84
+ expect(provider.groupadd_options).to eq(["-r"])
84
85
  end
85
86
 
86
87
  context "on Solaris" do
87
88
  before { node.automatic["platform"] = "solaris2" }
88
89
  it "should not set groupadd -r if system is true" do
89
90
  new_resource.system(true)
90
- expect(provider.groupadd_options).not_to match(/-r/)
91
+ expect(provider.groupadd_options).to eql([])
91
92
  end
92
93
  end
93
94
  end
@@ -95,26 +96,26 @@ describe Chef::Provider::Group::Groupadd do
95
96
  describe "when we want to create a non_unique gid group" do
96
97
  it "should not set groupadd_options '-o' when non_unique is false" do
97
98
  new_resource.non_unique(false)
98
- expect(provider.groupadd_options).not_to match(/-o/)
99
+ expect(provider.groupadd_options).to eq([])
99
100
  end
100
101
 
101
102
  it "should set groupadd -o if non_unique is true" do
102
103
  new_resource.non_unique(true)
103
- expect(provider.groupadd_options).to eq(" -o")
104
+ expect(provider.groupadd_options).to eq(["-o"])
104
105
  end
105
106
  end
106
107
  end
107
108
 
108
109
  describe "#create_group" do
109
110
  before do
110
- allow(provider).to receive(:run_command).and_return(true)
111
- allow(provider).to receive(:set_options).and_return(" monkey")
112
- allow(provider).to receive(:groupadd_options).and_return("")
111
+ allow(provider).to receive(:shell_out!).and_return(true)
112
+ allow(provider).to receive(:set_options).and_return("monkey")
113
+ allow(provider).to receive(:groupadd_options).and_return([])
113
114
  allow(provider).to receive(:modify_group_members).and_return(true)
114
115
  end
115
116
 
116
117
  it "should run groupadd with the return of set_options" do
117
- expect(provider).to receive(:run_command).with({ :command => "groupadd monkey" }).and_return(true)
118
+ expect(provider).to receive(:shell_out!).with("groupadd", "monkey").and_return(true)
118
119
  provider.create_group
119
120
  end
120
121
 
@@ -126,13 +127,13 @@ describe Chef::Provider::Group::Groupadd do
126
127
 
127
128
  describe "#manage_group" do
128
129
  before do
129
- allow(provider).to receive(:run_command).and_return(true)
130
- allow(provider).to receive(:set_options).and_return(" monkey")
130
+ allow(provider).to receive(:shell_out!).and_return(true)
131
+ allow(provider).to receive(:set_options).and_return("monkey")
131
132
  end
132
133
 
133
134
  it "should run groupmod with the return of set_options" do
134
135
  allow(provider).to receive(:modify_group_members).and_return(true)
135
- expect(provider).to receive(:run_command).with({ :command => "groupmod monkey" }).and_return(true)
136
+ expect(provider).to receive(:shell_out!).with("groupmod", "monkey").and_return(true)
136
137
  provider.manage_group
137
138
  end
138
139
 
@@ -144,12 +145,12 @@ describe Chef::Provider::Group::Groupadd do
144
145
 
145
146
  describe "#remove_group" do
146
147
  before do
147
- allow(provider).to receive(:run_command).and_return(true)
148
- allow(provider).to receive(:set_options).and_return(" monkey")
148
+ allow(provider).to receive(:shell_out!).and_return(true)
149
+ allow(provider).to receive(:set_options).and_return("monkey")
149
150
  end
150
151
 
151
152
  it "should run groupdel with the new resources group name" do
152
- expect(provider).to receive(:run_command).with({ :command => "groupdel aj" }).and_return(true)
153
+ expect(provider).to receive(:shell_out!).with("groupdel", "aj").and_return(true)
153
154
  provider.remove_group
154
155
  end
155
156
  end
@@ -162,30 +163,30 @@ describe Chef::Provider::Group::Groupadd do
162
163
 
163
164
  describe "#load_current_resource" do
164
165
  before do
165
- allow(provider).to receive(:run_command).and_return(true)
166
- allow(provider).to receive(:set_options).and_return(" monkey")
166
+ allow(provider).to receive(:shell_out!).and_return(true)
167
+ allow(provider).to receive(:set_options).and_return("monkey")
167
168
  end
168
169
 
169
170
  before do
170
- allow(File).to receive(:exists?).and_return(false)
171
+ allow(File).to receive(:exist?).and_return(false)
171
172
  provider.define_resource_requirements
172
173
  end
173
174
 
174
175
  it "should raise an error if the required binary /usr/sbin/groupadd doesn't exist" do
175
- expect(File).to receive(:exists?).with("/usr/sbin/groupadd").and_return(false)
176
+ expect(File).to receive(:exist?).with("/usr/sbin/groupadd").and_return(false)
176
177
  expect { provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Group)
177
178
  end
178
179
 
179
180
  it "should raise an error if the required binary /usr/sbin/groupmod doesn't exist" do
180
- expect(File).to receive(:exists?).with("/usr/sbin/groupadd").and_return(true)
181
- expect(File).to receive(:exists?).with("/usr/sbin/groupmod").and_return(false)
181
+ expect(File).to receive(:exist?).with("/usr/sbin/groupadd").and_return(true)
182
+ expect(File).to receive(:exist?).with("/usr/sbin/groupmod").and_return(false)
182
183
  expect { provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Group)
183
184
  end
184
185
 
185
186
  it "should raise an error if the required binary /usr/sbin/groupdel doesn't exist" do
186
- expect(File).to receive(:exists?).with("/usr/sbin/groupadd").and_return(true)
187
- expect(File).to receive(:exists?).with("/usr/sbin/groupmod").and_return(true)
188
- expect(File).to receive(:exists?).with("/usr/sbin/groupdel").and_return(false)
187
+ expect(File).to receive(:exist?).with("/usr/sbin/groupadd").and_return(true)
188
+ expect(File).to receive(:exist?).with("/usr/sbin/groupmod").and_return(true)
189
+ expect(File).to receive(:exist?).with("/usr/sbin/groupdel").and_return(false)
189
190
  expect { provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Group)
190
191
  end
191
192
 
@@ -33,17 +33,17 @@ describe Chef::Provider::Group::Groupmod do
33
33
  describe "manage_group" do
34
34
  describe "when determining the current group state" do
35
35
  it "should raise an error if the required binary /usr/sbin/group doesn't exist" do
36
- expect(File).to receive(:exists?).with("/usr/sbin/group").and_return(false)
36
+ expect(File).to receive(:exist?).with("/usr/sbin/group").and_return(false)
37
37
  expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Group)
38
38
  end
39
39
  it "should raise an error if the required binary /usr/sbin/user doesn't exist" do
40
- expect(File).to receive(:exists?).with("/usr/sbin/group").and_return(true)
41
- expect(File).to receive(:exists?).with("/usr/sbin/user").and_return(false)
40
+ expect(File).to receive(:exist?).with("/usr/sbin/group").and_return(true)
41
+ expect(File).to receive(:exist?).with("/usr/sbin/user").and_return(false)
42
42
  expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Group)
43
43
  end
44
44
 
45
45
  it "shouldn't raise an error if the required binaries exist" do
46
- allow(File).to receive(:exists?).and_return(true)
46
+ allow(File).to receive(:exist?).and_return(true)
47
47
  expect { @provider.load_current_resource }.not_to raise_error
48
48
  end
49
49
  end
@@ -62,9 +62,9 @@ describe Chef::Provider::Group::Groupmod do
62
62
 
63
63
  it "logs a message and sets group's members to 'none', then removes existing group members" do
64
64
  expect(Chef::Log).to receive(:debug).with("group[wheel] setting group members to: none")
65
- expect(@provider).to receive(:shell_out!).with("group mod -n wheel_bak wheel")
66
- expect(@provider).to receive(:shell_out!).with("group add -g '123' -o wheel")
67
- expect(@provider).to receive(:shell_out!).with("group del wheel_bak")
65
+ expect(@provider).to receive(:shell_out!).with("group", "mod", "-n", "wheel_bak", "wheel")
66
+ expect(@provider).to receive(:shell_out!).with("group", "add", "-g", "123", "-o", "wheel")
67
+ expect(@provider).to receive(:shell_out!).with("group", "del", "wheel_bak")
68
68
  @provider.manage_group
69
69
  end
70
70
  end
@@ -90,10 +90,10 @@ describe Chef::Provider::Group::Groupmod do
90
90
 
91
91
  it "updates group membership correctly" do
92
92
  allow(Chef::Log).to receive(:debug)
93
- expect(@provider).to receive(:shell_out!).with("group mod -n wheel_bak wheel")
94
- expect(@provider).to receive(:shell_out!).with("user mod -G wheel lobster")
95
- expect(@provider).to receive(:shell_out!).with("group add -g '123' -o wheel")
96
- expect(@provider).to receive(:shell_out!).with("group del wheel_bak")
93
+ expect(@provider).to receive(:shell_out!).with("group", "mod", "-n", "wheel_bak", "wheel")
94
+ expect(@provider).to receive(:shell_out!).with("user", "mod", "-G", "wheel", "lobster")
95
+ expect(@provider).to receive(:shell_out!).with("group", "add", "-g", "123", "-o", "wheel")
96
+ expect(@provider).to receive(:shell_out!).with("group", "del", "wheel_bak")
97
97
  @provider.manage_group
98
98
  end
99
99
  end
@@ -108,10 +108,10 @@ describe Chef::Provider::Group::Groupmod do
108
108
  end
109
109
 
110
110
  it "should run a group add command and some user mod commands" do
111
- expect(@provider).to receive(:shell_out!).with("group add -g '123' wheel")
112
- expect(@provider).to receive(:shell_out!).with("user mod -G wheel lobster")
113
- expect(@provider).to receive(:shell_out!).with("user mod -G wheel rage")
114
- expect(@provider).to receive(:shell_out!).with("user mod -G wheel fist")
111
+ expect(@provider).to receive(:shell_out!).with("group", "add", "-g", "123", "wheel")
112
+ expect(@provider).to receive(:shell_out!).with("user", "mod", "-G", "wheel", "lobster")
113
+ expect(@provider).to receive(:shell_out!).with("user", "mod", "-G", "wheel", "rage")
114
+ expect(@provider).to receive(:shell_out!).with("user", "mod", "-G", "wheel", "fist")
115
115
  @provider.create_group
116
116
  end
117
117
  end
@@ -125,7 +125,7 @@ describe Chef::Provider::Group::Groupmod do
125
125
  end
126
126
 
127
127
  it "should run a group del command" do
128
- expect(@provider).to receive(:shell_out!).with("group del wheel")
128
+ expect(@provider).to receive(:shell_out!).with("group", "del", "wheel")
129
129
  @provider.remove_group
130
130
  end
131
131
  end
@@ -37,19 +37,19 @@ describe Chef::Provider::Group::Pw do
37
37
 
38
38
  describe "when setting options for the pw command" do
39
39
  it "does not set the gid option if gids match or are unmanaged" do
40
- expect(@provider.set_options).to eq(" wheel")
40
+ expect(@provider.set_options).to eq(["wheel"])
41
41
  end
42
42
 
43
43
  it "sets the option for gid if it is not nil" do
44
44
  @new_resource.gid(42)
45
- expect(@provider.set_options).to eql(" wheel -g '42'")
45
+ expect(@provider.set_options).to eql(["wheel", "-g", 42])
46
46
  end
47
47
  end
48
48
 
49
49
  describe "when creating a group" do
50
50
  it "should run pw groupadd with the return of set_options and set_members_option" do
51
51
  @new_resource.gid(23)
52
- expect(@provider).to receive(:run_command).with({ :command => "pw groupadd wheel -g '23' -M root,aj" }).and_return(true)
52
+ expect(@provider).to receive(:shell_out!).with("pw", "groupadd", "wheel", "-g", "23", "-M", "root,aj").and_return(true)
53
53
  @provider.create_group
54
54
  end
55
55
  end
@@ -59,8 +59,8 @@ describe Chef::Provider::Group::Pw do
59
59
  it "should run pw groupmod with the return of set_options" do
60
60
  @new_resource.gid(42)
61
61
  @new_resource.members(["someone"])
62
- expect(@provider).to receive(:run_command).with({ :command => "pw groupmod wheel -g '42' -m someone" }).and_return(true)
63
- expect(@provider).to receive(:run_command).with({ :command => "pw groupmod wheel -g '42' -d root,aj" }).and_return(true)
62
+ expect(@provider).to receive(:shell_out!).with("pw", "groupmod", "wheel", "-g", "42", "-m", "someone").and_return(true)
63
+ expect(@provider).to receive(:shell_out!).with("pw", "groupmod", "wheel", "-g", "42", "-d", "root,aj").and_return(true)
64
64
  @provider.manage_group
65
65
  end
66
66
 
@@ -68,7 +68,7 @@ describe Chef::Provider::Group::Pw do
68
68
 
69
69
  describe "when removing the group" do
70
70
  it "should run pw groupdel with the new resources group name" do
71
- expect(@provider).to receive(:run_command).with({ :command => "pw groupdel wheel" }).and_return(true)
71
+ expect(@provider).to receive(:shell_out!).with("pw", "groupdel", "wheel").and_return(true)
72
72
  @provider.remove_group
73
73
  end
74
74
  end
@@ -98,7 +98,7 @@ describe Chef::Provider::Group::Pw do
98
98
  end
99
99
 
100
100
  it "should set the -d option with the members joined by ','" do
101
- expect(@provider.set_members_options).to eql([ " -d all,your,base" ])
101
+ expect(@provider.set_members_options).to eql([ ["-d", "all,your,base"] ])
102
102
  end
103
103
  end
104
104
 
@@ -114,24 +114,24 @@ describe Chef::Provider::Group::Pw do
114
114
  end
115
115
 
116
116
  it "should set the -m option with the members joined by ','" do
117
- expect(@provider.set_members_options).to eql([ " -m all,your,base" ])
117
+ expect(@provider.set_members_options).to eql([[ "-m", "all,your,base" ]])
118
118
  end
119
119
  end
120
120
  end
121
121
 
122
122
  describe "load_current_resource" do
123
- before (:each) do
123
+ before(:each) do
124
124
  @provider.action = :create
125
125
  @provider.load_current_resource
126
126
  @provider.define_resource_requirements
127
127
  end
128
128
  it "should raise an error if the required binary /usr/sbin/pw doesn't exist" do
129
- expect(File).to receive(:exists?).with("/usr/sbin/pw").and_return(false)
129
+ expect(File).to receive(:exist?).with("/usr/sbin/pw").and_return(false)
130
130
  expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Group)
131
131
  end
132
132
 
133
133
  it "shouldn't raise an error if /usr/sbin/pw exists" do
134
- allow(File).to receive(:exists?).and_return(true)
134
+ allow(File).to receive(:exist?).and_return(true)
135
135
  expect { @provider.process_resource_requirements }.not_to raise_error
136
136
  end
137
137
  end
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- #     http://www.apache.org/licenses/LICENSE-2.0
10
+ #      http://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -47,7 +47,7 @@ describe Chef::Provider::Group::Suse do
47
47
 
48
48
  describe "when determining the current group state" do
49
49
  before(:each) do
50
- allow(File).to receive(:exists?).and_return(true)
50
+ allow(File).to receive(:exist?).and_return(true)
51
51
  provider.action = :create
52
52
  provider.define_resource_requirements
53
53
  end
@@ -56,7 +56,7 @@ describe Chef::Provider::Group::Suse do
56
56
  # for Chef::Provider::Group - no need to repeat it here. We'll
57
57
  # include only what's specific to this provider.
58
58
  it "should raise an error if the required binary /usr/sbin/groupmod doesn't exist" do
59
- expect(File).to receive(:exists?).with("/usr/sbin/groupmod").and_return(false)
59
+ expect(File).to receive(:exist?).with("/usr/sbin/groupmod").and_return(false)
60
60
  expect { provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Group)
61
61
  end
62
62
 
@@ -76,14 +76,14 @@ describe Chef::Provider::Group::Suse do
76
76
 
77
77
  describe "#add_member" do
78
78
  it "should call out to groupmod to add user" do
79
- expect(provider).to receive(:shell_out!).with("groupmod -A new_user new_group")
79
+ expect(provider).to receive(:shell_out!).with("groupmod", "-A", "new_user", "new_group")
80
80
  provider.add_member("new_user")
81
81
  end
82
82
  end
83
83
 
84
84
  describe "#remove_member" do
85
85
  it "should call out to groupmod to remove user" do
86
- expect(provider).to receive(:shell_out!).with("groupmod -R new_user new_group")
86
+ expect(provider).to receive(:shell_out!).with("groupmod", "-R", "new_user", "new_group")
87
87
  provider.remove_member("new_user")
88
88
  end
89
89
  end
@@ -46,18 +46,18 @@ describe Chef::Provider::Group::Usermod do
46
46
 
47
47
  describe "with supplied members" do
48
48
  platforms = {
49
- "openbsd" => "-G",
50
- "netbsd" => "-G",
51
- "solaris" => "-a -G",
52
- "suse" => "-a -G",
53
- "opensuse" => "-a -G",
54
- "smartos" => "-G",
55
- "omnios" => "-G",
49
+ "openbsd" => [ "-G" ],
50
+ "netbsd" => [ "-G" ],
51
+ "solaris" => [ "-a", "-G" ],
52
+ "suse" => [ "-a", "-G" ],
53
+ "opensuse" => [ "-a", "-G" ],
54
+ "smartos" => [ "-G" ],
55
+ "omnios" => [ "-G" ],
56
56
  }
57
57
 
58
58
  before do
59
59
  allow(@new_resource).to receive(:members).and_return(%w{all your base})
60
- allow(File).to receive(:exists?).and_return(true)
60
+ allow(File).to receive(:exist?).and_return(true)
61
61
  end
62
62
 
63
63
  it "should raise an error when setting the entire group directly" do
@@ -85,9 +85,9 @@ describe Chef::Provider::Group::Usermod do
85
85
  @provider.current_resource = current_resource
86
86
  @node.automatic_attrs[:platform] = platform
87
87
  allow(@new_resource).to receive(:append).and_return(true)
88
- expect(@provider).to receive(:shell_out!).with("usermod #{flags} wheel all")
89
- expect(@provider).to receive(:shell_out!).with("usermod #{flags} wheel your")
90
- expect(@provider).to receive(:shell_out!).with("usermod #{flags} wheel base")
88
+ expect(@provider).to receive(:shell_out!).with("usermod", *flags, "wheel", "all")
89
+ expect(@provider).to receive(:shell_out!).with("usermod", *flags, "wheel", "your")
90
+ expect(@provider).to receive(:shell_out!).with("usermod", *flags, "wheel", "base")
91
91
  @provider.modify_group_members
92
92
  end
93
93
  end
@@ -96,19 +96,19 @@ describe Chef::Provider::Group::Usermod do
96
96
 
97
97
  describe "when loading the current resource" do
98
98
  before(:each) do
99
- allow(File).to receive(:exists?).and_return(false)
99
+ allow(File).to receive(:exist?).and_return(false)
100
100
  @provider.action = :create
101
101
  @provider.define_resource_requirements
102
102
  end
103
103
 
104
104
  it "should raise an error if the required binary /usr/sbin/usermod doesn't exist" do
105
- allow(File).to receive(:exists?).and_return(true)
106
- expect(File).to receive(:exists?).with("/usr/sbin/usermod").and_return(false)
105
+ allow(File).to receive(:exist?).and_return(true)
106
+ expect(File).to receive(:exist?).with("/usr/sbin/usermod").and_return(false)
107
107
  expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Group)
108
108
  end
109
109
 
110
110
  it "shouldn't raise an error if the required binaries exist" do
111
- allow(File).to receive(:exists?).and_return(true)
111
+ allow(File).to receive(:exist?).and_return(true)
112
112
  expect { @provider.process_resource_requirements }.not_to raise_error
113
113
  end
114
114
  end