Project

General

Profile

« Previous | Next » 

Revision ad635ac8

Added by Jan Vansteenkiste over 11 years ago

  • ID ad635ac88540c690c986efa152dad274d5912b7b

Tests the autosign.conf operations

View differences:

test/puppetca_test.rb
require 'test_helper'
require 'tempfile'
require 'fileutils'
class ProxyTest < Test::Unit::TestCase
## Helper for autosign files.
def create_temp_autosign_file
file = Tempfile.new('autosign_test')
begin
## Setup
FileUtils.cp './test/fixtures/autosign.conf', file.path
Proxy::PuppetCA.stubs(:autosign_file).returns(file.path)
rescue
file.close
file.unlink
file = nil
end
file
end
def test_should_list_autosign_entries
Proxy::PuppetCA.stubs(:autosign_file).returns('./test/fixtures/autosign.conf')
assert_equal Proxy::PuppetCA.autosign_list, ['foo.example.com', '*.bar.example.com']
end
def test_should_add_autosign_entry
file = create_temp_autosign_file
content = []
begin
## Execute
Proxy::PuppetCA.autosign 'foobar.example.com'
## Read output
content = file.read.split("\n")
ensure
file.close
file.unlink
end
assert_equal content.include?('foobar.example.com'), true
end
def test_should_remove_autosign_entry
file = create_temp_autosign_file
content = ['foo.example.com']
begin
Proxy::PuppetCA.disable 'foo.example.com'
content = file.read.split("\n")
ensure
file.close
file.unlink
end
assert_equal content.include?('foo.example.com'), false
end
def test_should_have_a_logger
assert_respond_to Proxy::PuppetCA, :logger

Also available in: Unified diff