summaryrefslogtreecommitdiff
path: root/kitchen-tests/cookbooks/end_to_end/recipes/_macos_userdefaults.rb
blob: 80cbfddfccb8e04353f144dffda3db8ac514d0b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#
# Cookbook:: end_to_end
# Recipe:: _macos_userdefaults
#
# Copyright:: Copyright (c) Chef Software Inc.
#

# test that we can autodetect the type
mac_os_x_userdefaults "Disable fast user switching" do
  domain "/Library/Preferences/.GlobalPreferences"
  key "MultipleSessionEnabled"
  value 0
end

# test full path to the domain
macos_userdefaults "Enable macOS firewall" do
  domain "/Library/Preferences/com.apple.alf"
  key "globalstate"
  value "1"
  type "int"
end

# test short domain name
macos_userdefaults "Set the dock size" do
  domain "com.apple.dock"
  type "int"
  key "tilesize"
  value "20"
end

# test that we can properly handle spaces
macos_userdefaults "Value with space" do
  domain "/Library/Preferences/ManagedInstalls"
  type "string"
  key "LogFile"
  value "/Library/Managed Installs/Logs/ManagedSoftwareUpdate2.log"
end

# test that we can set an array
macos_userdefaults "Bogus key with array value" do
  domain "/Library/Preferences/ManagedInstalls"
  type "array"
  key "LogFileArray"
  value [ "/Library/Managed Installs/fake.log", "/Library/Managed Installs/also_fake.log"]
end

# test that we can set a dict
macos_userdefaults "Bogus key with dict value" do
  domain "/Library/Preferences/ManagedInstalls"
  type "dict"
  key "LogFileDict"
  value "User": "/Library/Managed Installs/way_fake.log"
end

# test that we can set a bool
macos_userdefaults "Bogus key with boolean value" do
  domain "/Library/Preferences/ManagedInstalls"
  key "LoggingIsTheThingToDoRight"
  value "yes"
  type "bool"
end

# test that we can handle the 2nd client run with :delete
macos_userdefaults "bogus key" do
  domain "/Library/Preferences/com.apple.alf"
  key "GlobalStateNope"
  action :delete
end

# try to delete a key we known is there
macos_userdefaults "delete a key" do
  domain "/Library/Preferences/ManagedInstalls"
  key "LoggingIsTheThingToDoRight"
  action :delete
end