~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

Viewing changes to spec/unit/indirector/certificate/rest.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
 
 
3
require File.dirname(__FILE__) + '/../../../spec_helper'
 
4
 
 
5
require 'puppet/indirector/certificate/rest'
 
6
 
 
7
describe Puppet::SSL::Certificate::Rest do
 
8
    before do
 
9
        @searcher = Puppet::SSL::Certificate::Rest.new
 
10
    end
 
11
 
 
12
    it "should be a sublcass of Puppet::Indirector::REST" do
 
13
        Puppet::SSL::Certificate::Rest.superclass.should equal(Puppet::Indirector::REST)
 
14
    end
 
15
 
 
16
    it "should set server_setting to :ca_server" do
 
17
        Puppet::SSL::Certificate::Rest.server_setting.should == :ca_server
 
18
    end
 
19
 
 
20
    it "should set port_setting to :ca_port" do
 
21
        Puppet::SSL::Certificate::Rest.port_setting.should == :ca_port
 
22
    end
 
23
 
 
24
    it "should make sure found certificates have their names set to the search string" do
 
25
        terminus = Puppet::SSL::Certificate::Rest.new
 
26
 
 
27
        # This has 'boo.com' in the CN
 
28
        cert_string = "-----BEGIN CERTIFICATE-----
 
29
MIICPzCCAaigAwIBAgIBBDANBgkqhkiG9w0BAQUFADAWMRQwEgYDVQQDDAtidWNr
 
30
eS5sb2NhbDAeFw0wOTA5MTcxNzI1MzJaFw0xNDA5MTYxNzI1MzJaMBIxEDAOBgNV
 
31
BAMMB2Jvby5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKG9B+DkTCNh
 
32
F5xHchNDfnbC9NzWKM600oxrr84pgUVAG6B2wAZcdfoEtXszhsY9Jzpwqkvxk4Mx
 
33
AbYqo9+TCi4UoiH6e+vAKOOJD3DHrlf+/RW4hGtyaI41DBhf4+B4/oFz5PH9mvKe
 
34
NSfHFI/yPW+1IXYjxKLQNwF9E7q3JbnzAgMBAAGjgaAwgZ0wOAYJYIZIAYb4QgEN
 
35
BCsWKVB1cHBldCBSdWJ5L09wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMAwG
 
36
A1UdEwEB/wQCMAAwHQYDVR0OBBYEFJOxEUeyf4cNOBmf9zIaE1JTuNdLMAsGA1Ud
 
37
DwQEAwIFoDAnBgNVHSUEIDAeBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwME
 
38
MA0GCSqGSIb3DQEBBQUAA4GBAFTJxKprMg6tfhGnvEvURPmlJrINn9c2b5Y4AGYp
 
39
tO86PFFkWw/EIJvvJzbj3s+Butr+eUo//+f1xxX7UCwwGqGxKqjtVS219oU/wkx8
 
40
h7rW4Xk7MrLl0auSS1p4wLcAMm+ZImf94+j8Cj+tkr8eGozZceRV13b8+EkdaE3S
 
41
rn/G
 
42
-----END CERTIFICATE-----
 
43
"
 
44
 
 
45
        network = stub 'network'
 
46
        terminus.stubs(:network).returns network
 
47
 
 
48
        response = stub 'response', :code => "200", :body => cert_string
 
49
        response.stubs(:[]).with('content-type').returns "text/plain"
 
50
        network.expects(:get).returns response
 
51
 
 
52
        request = Puppet::Indirector::Request.new(:certificate, :find, "foo.com")
 
53
        result = terminus.find(request)
 
54
        result.should_not be_nil
 
55
        result.name.should == "foo.com"
 
56
    end
 
57
end