blob: a81e95a86276794353f5a53006570a805b8ecfc5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#!/usr/bin/env ruby
$:.unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppettest'
require 'puppet/network/xmlrpc/client'
require 'mocha'
class TestXMLRPCClient < Test::Unit::TestCase
include PuppetTest
def setup
Puppet::Util::SUIDManager.stubs(:asuser).yields
super
end
def test_set_backtrace
error = Puppet::Network::XMLRPCClientError.new("An error")
assert_nothing_raised do
error.set_backtrace ["caller"]
end
assert_equal(["caller"], error.backtrace)
end
# Make sure we correctly generate a netclient
def test_handler_class
# Create a test handler
klass = Puppet::Network::XMLRPCClient
yay = Class.new(Puppet::Network::Handler) do
@interface = XMLRPC::Service::Interface.new("yay") { |iface|
iface.add_method("array getcert(csr)")
}
@name = :Yay
end
Object.const_set("Yay", yay)
net = nil
assert_nothing_raised("Failed when retrieving client for handler") do
net = klass.handler_class(yay)
end
assert(net, "did not get net client")
end
# Make sure the xmlrpc client is correctly reading all of the cert stuff
# and setting it into the @http var
def test_cert_setup
client = nil
assert_nothing_raised do
client = Puppet::Network::XMLRPCClient.new()
end
ca = Puppet::Network::Handler.ca.new
caclient = Puppet::Network::Client.ca.new :CA => ca
caclient.request_cert
class << client
attr_accessor :http
end
client.http.expects(:ca_file=).with(Puppet[:localcacert])
client.http.expects(:cert=).with(caclient.cert)
client.http.expects(:key=).with(caclient.key)
client.http.expects(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
client.http.expects(:cert_store=)
assert_nothing_raised do
client.cert_setup(caclient)
end
end
end
|