summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRishi Kumar Chawda <rishichawda@users.noreply.github.com>2023-03-08 01:58:55 +0530
committerGitHub <noreply@github.com>2023-03-07 15:28:55 -0500
commit364813a324b71cc4ee38238e096216b27491d6bb (patch)
tree61a2504e4c7e4355f00b5114dedc3931e873d0f4
parent8a78e532bd87a525bab5e414826aa31f13ae3125 (diff)
downloadchef-364813a324b71cc4ee38238e096216b27491d6bb.tar.gz
set default values for user and host on userdefaults (#12791)
* set default values for user and host on userdefaults Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
-rw-r--r--.github/workflows/func_spec.yml2
-rw-r--r--lib/chef/resource/macos_userdefaults.rb14
-rw-r--r--spec/functional/resource/macos_userdefaults_spec.rb8
-rw-r--r--spec/unit/resource/macos_user_defaults_spec.rb8
4 files changed, 18 insertions, 14 deletions
diff --git a/.github/workflows/func_spec.yml b/.github/workflows/func_spec.yml
index 3900bd1d00..f7a2c47b21 100644
--- a/.github/workflows/func_spec.yml
+++ b/.github/workflows/func_spec.yml
@@ -40,4 +40,4 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: false
- run: bundle install
- - run: bundle exec rspec spec/functional/resource/macos_userdefaults_spec.rb
+ - run: sudo bundle exec rspec spec/functional/resource/macos_userdefaults_spec.rb
diff --git a/lib/chef/resource/macos_userdefaults.rb b/lib/chef/resource/macos_userdefaults.rb
index 7559990d3a..558188c932 100644
--- a/lib/chef/resource/macos_userdefaults.rb
+++ b/lib/chef/resource/macos_userdefaults.rb
@@ -50,15 +50,17 @@ class Chef
end
```
- **Specifying the type of a key to skip automatic type detection**
+ **Setting a value for specific user and hosts**
```ruby
- macos_userdefaults 'Finder expanded save dialogs' do
- key 'NSNavPanelExpandedStateForSaveMode'
- value 'TRUE'
- type 'bool'
+ macos_userdefaults 'Enable macOS firewall' do
+ key 'globalstate'
+ value 1
+ user 'jane'
+ host :current
end
```
+
DOC
property :domain, String,
@@ -79,6 +81,7 @@ class Chef
property :host, [String, Symbol],
description: "Set either :current, :all or a hostname to set the user default at the host level.",
+ default: :all,
desired_state: false,
introduced: "16.3"
@@ -94,6 +97,7 @@ class Chef
property :user, [String, Symbol],
description: "The system user that the default will be applied to. Set :current for current user, :all for all users or pass a valid username",
+ default: :current,
desired_state: false
property :sudo, [TrueClass, FalseClass],
diff --git a/spec/functional/resource/macos_userdefaults_spec.rb b/spec/functional/resource/macos_userdefaults_spec.rb
index 0ed7839ad0..2d3f538cf2 100644
--- a/spec/functional/resource/macos_userdefaults_spec.rb
+++ b/spec/functional/resource/macos_userdefaults_spec.rb
@@ -38,12 +38,12 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
expect(resource.domain).to eq("NSGlobalDomain")
end
- it "nil for the host property" do
- expect(resource.host).to be_nil
+ it ":all for the host property" do
+ expect(resource.host).to eq(:all)
end
- it "nil for the user property" do
- expect(resource.user).to be_nil
+ it ":current for the user property" do
+ expect(resource.user).to eq(:current)
end
it ":write for resource action" do
diff --git a/spec/unit/resource/macos_user_defaults_spec.rb b/spec/unit/resource/macos_user_defaults_spec.rb
index 8363b822ec..5252684df5 100644
--- a/spec/unit/resource/macos_user_defaults_spec.rb
+++ b/spec/unit/resource/macos_user_defaults_spec.rb
@@ -39,12 +39,12 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
expect(resource.domain).to eq("NSGlobalDomain")
end
- it "nil for the host property" do
- expect(resource.host).to be_nil
+ it ":all for the host property" do
+ expect(resource.host).to eq(:all)
end
- it "nil for the user property" do
- expect(resource.user).to be_nil
+ it ":current for the user property" do
+ expect(resource.user).to eq(:current)
end
it ":write for resource action" do