Sha256: 848e6e4175541c5c5a0a379d897c485bd68928e3a8a05e108f77db596b615c27

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

require 'test_plugin_helper'

class HostsControllerTest < ActionController::TestCase
  setup do
    User.current = User.find_by_login "admin"
    @host = FactoryGirl.create(:host, :operatingsystem => FactoryGirl.create(:operatingsystem),
                               :architecture => FactoryGirl.create(:architecture),
                               :puppetclasses => [FactoryGirl.create(:puppetclass)])
  end

    test "index returns YAML output for rundeck" do
      get :index, {:format => 'yaml'}, set_session_user
      hosts = YAML.load(@response.body)
      assert_not_empty hosts
      host = Host.first
      unless host.nil? || host.name.nil? || hosts.nil? || hosts[host.name].nil?
        assert_equal host.os.name, hosts[host.name]["osName"] # rundeck-specific field
      end
    end

    test "show returns YAML output for rundeck" do
      host = Host.first
      get :show, {:id => host, :format => 'yaml'}, set_session_user
      yaml = YAML.load(@response.body)
      unless host.nil? || host.name.nil? || host.os.nil? || yaml[host.name].nil?
        assert_kind_of Hash, yaml[host.name]
        assert_equal host.name, yaml[host.name]["hostname"]
        assert_equal host.os.name, yaml[host.name]["osName"]  # rundeck-specific field
      end
    end

  test "show with add_enc_output shows enc output in YAML" do
    host = Host.first
    get :show, {:id => host, :format => 'yaml', :add_enc_output => true}, set_session_user
    yaml = YAML.load(@response.body)
    unless host.nil? || host.name.nil? || host.os.nil? || yaml[host.name].nil?
      assert_kind_of Hash, yaml[host.name]
      assert_equal host.name, yaml[host.name]["hostname"]
      assert_equal host.os.name, yaml[host.name]["osName"]  # rundeck-specific field
      assert_kind_of Hash, yaml[host.name]["Enc_output"]
      assert_present yaml[host.name]["Enc_output"]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_host_rundeck-0.0.3 test/functional/hosts_controller_test.rb