Skip to content

Commit

Permalink
fixes #19328 - autosign tasks have correct wording
Browse files Browse the repository at this point in the history
  • Loading branch information
timogoebel authored and domcleal committed Apr 21, 2017
1 parent edd5310 commit 006929d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/models/concerns/orchestration/puppetca.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,21 @@ def queue_puppetca_create; end

def queue_puppetca_update
# Host has been built --> remove auto sign
if old.build? && !build?
queue.create(:name => _("Delete autosign entry for %s") % self, :priority => 50,
:action => [self, :delAutosign])
end
queue_puppetca_autosign_destroy if old.build? && !build?
true
end

def queue_puppetca_destroy
return unless puppetca? && errors.empty?
return unless Setting[:manage_puppetca]
queue.create(:name => _("Delete PuppetCA certificates for %s") % self, :priority => 50,
:action => [self, :delCertificate])
queue.create(:name => _("Delete PuppetCA certificates for %s") % self, :priority => 55,
queue_puppetca_autosign_destroy
true
end

def queue_puppetca_autosign_destroy
queue.create(:name => _("Delete PuppetCA autosign entry for %s") % self, :priority => 55,
:action => [self, :delAutosign])
end
end
38 changes: 38 additions & 0 deletions test/models/orchestration/puppetca_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'test_helper'

class PuppetCaOrchestrationTest < ActiveSupport::TestCase
def setup
User.current = users(:one)
disable_orchestration
SETTINGS[:locations_enabled] = false
SETTINGS[:organizations_enabled] = false
Setting[:manage_puppetca] = true
skip_without_unattended
end

def teardown
SETTINGS[:locations_enabled] = true
SETTINGS[:organizations_enabled] = true
User.current = nil
end

context 'a host with puppetca orchestration' do
let(:host) { FactoryGirl.create(:host, :managed, :with_puppet_ca, :build => true) }

test 'should queue puppetca update' do
host.build = false
assert_valid host
tasks = host.queue.all.map(&:name)
assert_includes tasks, "Delete PuppetCA autosign entry for #{host}"
assert_equal 1, tasks.size
end

test 'should queue puppetca destroy' do
host.send(:queue_puppetca_destroy)
tasks = host.queue.all.map(&:name)
assert_includes tasks, "Delete PuppetCA autosign entry for #{host}"
assert_includes tasks, "Delete PuppetCA certificates for #{host}"
assert_equal 2, tasks.size
end
end
end

0 comments on commit 006929d

Please sign in to comment.