Release/2.1 (#111)
* bump version * Fix autologin functionality on 10.13.4 (#110) * add tests for setup assistant keys and 'lastUser' loginwindow key * refactor user_home * refactor setup_assistant_plist * add new setup assistant keypairs * add and implement login_window_keypair_values
This commit is contained in:
Родитель
cdd4e45706
Коммит
923ab69718
|
@ -5,7 +5,7 @@ license 'MIT'
|
|||
description 'Resources for configuring and provisioning macOS'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
chef_version '>= 13.0' if respond_to?(:chef_version)
|
||||
version '2.0.0'
|
||||
version '2.1.0'
|
||||
|
||||
source_url 'https://github.com/Microsoft/macos-cookbook'
|
||||
issues_url 'https://github.com/Microsoft/macos-cookbook/issues'
|
||||
|
|
|
@ -10,17 +10,30 @@ property :groups, [Array, String]
|
|||
|
||||
action_class do
|
||||
def user_home
|
||||
::File.join('/Users', new_resource.username)
|
||||
::File.join('/', 'Users', new_resource.username)
|
||||
end
|
||||
|
||||
def setup_assistant_plist
|
||||
::File.join(user_home, '/Library/Preferences/com.apple.SetupAssistant.plist')
|
||||
::File.join(user_home, 'Library', 'Preferences', 'com.apple.SetupAssistant.plist')
|
||||
end
|
||||
|
||||
def login_window_plist
|
||||
::File.join('/', 'Library', 'Preferences', 'com.apple.loginwindow.plist')
|
||||
end
|
||||
|
||||
def setup_assistant_keypair_values
|
||||
{ 'DidSeeSiriSetup' => true,
|
||||
'DidSeeCloudSetup' => true,
|
||||
'LastSeenCloudProductVersion' => node['platform_version'] }
|
||||
{ 'DidSeeCloudSetup' => true,
|
||||
'DidSeeSiriSetup' => true,
|
||||
'DidSeePrivacy' => true,
|
||||
'LastSeenCloudProductVersion' => node['platform_version'],
|
||||
'LastSeenBuddyBuildVersion' => node['platform_build'],
|
||||
}
|
||||
end
|
||||
|
||||
def login_window_keypair_values
|
||||
{ 'autoLoginUser' => new_resource.username,
|
||||
'lastUser' => 'loggedIn',
|
||||
}
|
||||
end
|
||||
|
||||
def sysadminctl
|
||||
|
@ -65,10 +78,11 @@ action :create do
|
|||
end
|
||||
end
|
||||
|
||||
plist "set user \"#{new_resource.username}\" to login automatically" do
|
||||
path '/Library/Preferences/com.apple.loginwindow.plist'
|
||||
entry 'autoLoginUser'
|
||||
value new_resource.username
|
||||
login_window_keypair_values.each do |e, v|
|
||||
plist login_window_plist do
|
||||
entry e
|
||||
value v
|
||||
end
|
||||
end
|
||||
|
||||
file '/etc/kcpassword' do
|
||||
|
|
|
@ -18,9 +18,23 @@ control 'admin-user' do
|
|||
its('stdout.split') { should include '80' }
|
||||
end
|
||||
|
||||
describe command("/usr/libexec/PlistBuddy -c 'Print :autoLoginUser' /Library/Preferences/com.apple.loginwindow.plist") do
|
||||
its('exit_status') { should eq 0 }
|
||||
its('stdout.chomp') { should eq 'randall' }
|
||||
setup_assistant_keypair_values = { 'autoLoginUser' => 'randall',
|
||||
'lastUser' => 'loggedIn',
|
||||
}
|
||||
setup_assistant_keypair_values.each do |key, expected_value|
|
||||
describe command("/usr/libexec/Plistbuddy -c 'Print #{key}' /Library/Preferences/com.apple.loginwindow.plist") do
|
||||
its('stdout.chomp') { should eq expected_value }
|
||||
end
|
||||
end
|
||||
|
||||
login_window_keypair_values = { 'DidSeeCloudSetup' => true,
|
||||
'DidSeeSiriSetup' => true,
|
||||
'DidSeePrivacy' => true,
|
||||
}
|
||||
login_window_keypair_values.each do |key, expected_value|
|
||||
describe command("/usr/libexec/Plistbuddy -c 'Print #{key}' /Users/randall/Library/Preferences/com.apple.SetupAssistant.plist") do
|
||||
its('stdout.chomp') { should eq expected_value.to_s }
|
||||
end
|
||||
end
|
||||
|
||||
describe groups.where { name == 'admin' } do
|
||||
|
|
Загрузка…
Ссылка в новой задаче