class Inspec::Resources::User
end
its(:encrypted_password) { should eq 1234 }
it { should have_authorized_key ‘ssh-rsa ADg54…3434 user@example.local’ }
describe user(‘root’) do
ServerSpec tests that are not supported:
end
its(‘maximum_days_between_password_change’) { should eq 99 }
its(‘minimum_days_between_password_change’) { should eq 0 }
it { should have_login_shell ‘/bin/bash’ }
it { should have_home_directory ‘/root’ }
it { should have_uid 0 }
it { should belong_to_group ‘root’ }
describe user(‘root’) do
The following Serverspec matchers are deprecated in favor for direct value access
end
its(‘warndays’) { should eq 5 }
its(‘maxdays’) { should eq 99 }
its(‘mindays’) { should eq 0 }
its(‘shell’) { should eq ‘/bin/bash’ }
its(‘home’) { should eq ‘/root’ }
its(‘groups’) { should eq [‘root’, ‘wheel’]}
its(‘group’) { should eq ‘root’ }
its(‘gid’) { should eq 0 }
its(‘uid’) { should eq 0 }
it { should exist }
describe user(‘root’) do
The ‘user` resource handles the special case where only one resource is required
def credentials
def credentials return @cred_cache if defined?(@cred_cache) @cred_cache = @user_provider.credentials(@username) if !@user_provider.nil? end
def deprecated(name, alternative = nil)
def deprecated(name, alternative = nil) warn "[DEPRECATION] #{name} is deprecated. #{alternative}" end
def disabled?
def disabled? identity[:disabled] == true unless identity.nil? end
def enabled?
def enabled? identity[:disabled] == false unless identity.nil? end
def exists?
def exists? !identity.nil? && !identity[:username].nil? end
def gid
def gid identity[:gid] unless identity.nil? end
def groupname
def groupname identity[:groupname] unless identity.nil? end
def groups
def groups identity[:groups] unless identity.nil? end
def has_authorized_key?(_compare_key)
def has_authorized_key?(_compare_key) deprecated('has_authorized_key?') raise NotImplementedError end
def has_home_directory?(compare_home)
def has_home_directory?(compare_home) deprecated('has_home_directory?', "Please use: its('home')") home == compare_home end
def has_login_shell?(compare_shell)
def has_login_shell?(compare_shell) deprecated('has_login_shell?', "Please use: its('shell')") shell == compare_shell end
def has_uid?(compare_uid)
implements rspec has matcher, to be compatible with serverspec
def has_uid?(compare_uid) deprecated('has_uid?') uid == compare_uid end
def home
def home meta_info[:home] unless meta_info.nil? end
def identity
def identity return @id_cache if defined?(@id_cache) @id_cache = @user_provider.identity(@username) if !@user_provider.nil? end
def initialize(username = nil)
def initialize(username = nil) @username = username # select user provider @user_provider = select_user_manager(inspec.os) return skip_resource 'The `user` resource is not supported on your OS yet.' if @user_provider.nil? end
def maxdays
def maxdays credentials[:maxdays] unless credentials.nil? end
def maximum_days_between_password_change
def maximum_days_between_password_change deprecated('maximum_days_between_password_change', "Please use: its('maxdays')") maxdays end
def meta_info
def meta_info return @meta_cache if defined?(@meta_cache) @meta_cache = @user_provider.meta_info(@username) if !@user_provider.nil? end
def mindays
def mindays credentials[:mindays] unless credentials.nil? end
def minimum_days_between_password_change
def minimum_days_between_password_change deprecated('minimum_days_between_password_change', "Please use: its('mindays')") mindays end
def shell
def shell meta_info[:shell] unless meta_info.nil? end
def to_s
def to_s "User #{@username}" end
def uid
def uid identity[:uid] unless identity.nil? end
def username
def username identity[:username] unless identity.nil? end
def warndays
def warndays credentials[:warndays] unless credentials.nil? end