Sha256: 041b1f9d053de65f3e798b1e43372cd208fbbdc8bb03fc0ce643bc3f652ad773

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 KB

Contents

require 'test_plugin_helper'

module ForemanSalt
  class HostExtensionsTest < ActiveSupport::TestCase
    setup do
      User.current = User.find_by_login 'admin'
    end

    test 'host has a salt smart proxy' do
      host = FactoryGirl.create :host, :with_salt_proxy
      assert host.salt_proxy.has_feature? 'Salt'
    end

    test 'smart_proxy_ids returns salt smart proxy' do
      host = FactoryGirl.create :host, :with_salt_proxy
      assert host.smart_proxy_ids.include? host.salt_proxy_id
    end

    test 'host params includes salt_master' do
      host = FactoryGirl.create :host, :with_salt_proxy
      assert host.params.key? 'salt_master'
      assert_equal host.params['salt_master'], host.salt_master
    end

    test 'host inherits salt proxy from host group' do
      hostgroup = FactoryGirl.create :hostgroup, :with_salt_proxy
      host = FactoryGirl.create :host, :hostgroup => hostgroup
      host.set_hostgroup_defaults
      assert_equal host.salt_proxy, hostgroup.salt_proxy
    end

    test 'host does not accept salt modules outside its environment' do
      hosts_environment = FactoryGirl.create :salt_environment
      other_environment = FactoryGirl.create :salt_environment

      state = FactoryGirl.create :salt_module
      other_environment.salt_modules << state

      host = FactoryGirl.create :host, :with_salt_proxy, :salt_environment => hosts_environment
      host.salt_modules = [state]

      refute host.save
      assert host.errors.full_messages.include? 'Salt states must be in the environment of the host'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_salt-3.0.2 test/unit/host_extensions_test.rb
foreman_salt-3.0.1 test/unit/host_extensions_test.rb
foreman_salt-3.0.0 test/unit/host_extensions_test.rb
foreman_salt-2.1.0 test/unit/host_extensions_test.rb