Sha256: d1049e8e0d638ad11d81d742bfb6551ecdcb8e80514ec04454781af1aa6160d7

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

require "test_helper"

class ClassificationTest < ActiveSupport::TestCase

  #TODO: add more tests here
  def setup
    @classification = Classification.new(:host => hosts(:one))
  end

  test 'it should return puppetclasses' do
    assert classification.send(:puppetclass_ids).map(&:to_i).include?(puppetclasses(:one).id)
  end

  test 'classes should have parameters' do
    assert classification.send(:class_parameters).include?(lookup_keys(:complex))
  end

  test 'enc_should_return_cluster_param' do
    enc = classification.enc
    assert_equal 'secret', enc['base']['cluster']
  end

  test 'enc_should_return_updated_cluster_param' do
    key   = lookup_keys(:complex)
    assert_equal 'organization,location', key.path
    host = hosts(:one)
    assert_equal taxonomies(:location1), host.location
    assert_equal taxonomies(:organization1), host.organization

    value = User.as :admin do
      LookupValue.create! :lookup_key_id => key.id,
                          :match => "organization=#{taxonomies(:organization1)},location=#{taxonomies(:location1)}",
                          :value => 'test'
    end
    enc = classification.enc

    key.reload
    # ensures it works per key (as it was before the optimization)
    assert_equal value.value, key.value_for(hosts(:one))
    assert_equal value.value, enc['base']['cluster']
  end
  private

  attr_reader :classification

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/test/unit/classification_test.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/test/unit/classification_test.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/test/unit/classification_test.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/test/unit/classification_test.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/test/unit/classification_test.rb