require 'spec_helper'

# as regular user
describe command('puppet config print') do
  its(:stdout) { should match(%r{^basemodulepath = /home/test/.puppet/code/modules:/usr/share/puppet/modules}) }
  its(:stdout) { should match(%r{^cadir = /etc/puppet/puppetserver/ca}) }
  its(:stdout) { should match(%r{^confdir = /home/test/.puppet/etc}) }
  its(:stdout) { should match(%r{^logdir = /home/test/.puppet/var/log}) }
  its(:stdout) { should match(%r{^modulepath = /usr/share/puppet/modules}) }
  its(:stdout) { should match(%r{^publicdir = /home/test/.puppet/cache/public}) }
  its(:stdout) { should match(%r{^rundir = /home/test/.puppet/var/run}) }
  its(:stdout) { should match(%r{^ssldir = /home/test/.puppet/etc/ssl}) }
  its(:stdout) { should match(%r{^vardir = /home/test/.puppet/cache}) }
  its(:stdout) { should match(%r{^vendormoduledir = /usr/share/puppet/vendor_modules}) }
end

# as root
describe command('sudo puppet config print') do
  its(:stdout) { should match(%r{^basemodulepath = /etc/puppet/code/modules:/usr/share/puppet/modules}) }
  its(:stdout) { should match(%r{^cadir = /etc/puppet/puppetserver/ca}) }
  its(:stdout) { should match(%r{^confdir = /etc/puppet}) }
  its(:stdout) { should match(%r{^logdir = /var/log/puppet}) }
  its(:stdout) { should match(%r{^modulepath = /usr/share/puppet/modules}) }
  its(:stdout) { should match(%r{^publicdir = /var/cache/puppet/public}) }
  its(:stdout) { should match(%r{^rundir = /run/puppet}) }
  its(:stdout) { should match(%r{^ssldir = /var/lib/puppet/ssl}) }
  its(:stdout) { should match(%r{^vardir = /var/cache/puppet}) }
  its(:stdout) { should match(%r{^vendormoduledir = /usr/share/puppet/vendor_modules}) }
end

# as regular user which owns /var/lib/puppet/ssl
# (eg. puppetserver)

describe command('sudo -u puppet puppet config print ssldir') do
  its(:stdout) { should eq "/var/lib/puppet/ssl\n" }
end
