403Webshell
Server IP : 66.29.132.122  /  Your IP : 52.14.151.45
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/opt/puppetlabs/puppet/vendor_modules/cron_core/spec/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/opt/puppetlabs/puppet/vendor_modules/cron_core/spec//spec_helper_acceptance.rb
require 'beaker-rspec'
require 'beaker-puppet'
require 'beaker/module_install_helper'
require 'beaker/puppet_install_helper'
require 'voxpupuli/acceptance/spec_helper_acceptance'

$LOAD_PATH << File.join(__dir__, 'acceptance/lib')

# TODO: This should be added to Beaker
def assert_matching_arrays(expected, actual, message = '')
  assert_equal(expected.sort, actual.sort, message)
end

# TODO: Remove the wrappers to user_present
# and user_absent if Beaker::Host's user_present
# and user_absent functions are fixed to work with
# Arista (EOS).

def user_present(host, username)
  case host['platform']
  when %r{eos}
    on(host, "useradd #{username}")
  else
    host.user_present(username)
  end
end

def user_absent(host, username)
  case host['platform']
  when %r{eos}
    on(host, "userdel #{username}", acceptable_exit_codes: [0, 1])
  else
    host.user_absent(username)
  end
end

def beaker_opts
  { debug: true, trace: true, expect_failures: true, acceptable_exit_codes: (0...256) }
  # { expect_failures: true, acceptable_exit_codes: (0...256) }
end

def compatible_agents
  agents.reject { |agent| agent['platform'].include?('windows') || agent['platform'].include?('eos-') }
end

def clean(agent, o = {})
  o = { user: 'tstuser' }.merge(o)
  run_cron_on(agent, :remove, o[:user])
  apply_manifest_on(agent, %([user{'%s': ensure => absent, managehome => false }]) % o[:user])
end

def setup(agent, o = {})
  o = { user: 'tstuser' }.merge(o)
  apply_manifest_on(agent, %(user { '%s': ensure => present, managehome => false }) % o[:user])
  apply_manifest_on(agent, %(case $facts['os']['name'] {
                                centos, redhat, fedora, amazon: {$cron = 'cronie'}
                                solaris: { $cron = 'core-os' }
                                default: {$cron ='cron'} }
                                package {'cron': name=> $cron, ensure=>present, }))
end

# Returns all of the lines that correspond to crontab entries
# on the agent. For simplicity, these are any lines that do
# not begin with '#'.
def crontab_entries_of(host, username)
  crontab_contents = run_cron_on(host, :list, username).stdout.strip
  crontab_contents.lines.map(&:chomp).reject { |line| line =~ %r{^#} }
end

def resource_manifest(resource, title, params = {})
  params_str = params.map { |param, value|
    # This is not quite correct for all parameter values,
    # but it is good enough for most purposes.
    value_str = value.to_s
    value_str = "\"#{value_str}\"" if value.is_a?(String)

    "  #{param} => #{value_str}"
  }.join(",\n")

  <<-MANIFEST
  #{resource} { '#{title}':
  #{params_str}
}
   MANIFEST
end

def file_manifest(path, params = {})
  resource_manifest('file', path, params)
end

def cron_manifest(entry_name, params = {})
  resource_manifest('cron', entry_name, params)
end

def user_manifest(username, params = {})
  resource_manifest('user', username, params)
end

RSpec.configure do |c|
  c.before :suite do
    unless ENV['BEAKER_provision'] == 'no'
      hosts.each { |host| host[:type] = 'aio' }
      run_puppet_install_helper
      install_module_on(hosts_as('default'))
      install_module_dependencies_on(hosts)
    end
  end
end

Youez - 2016 - github.com/yon3zu
LinuXploit