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

« back to all changes in this revision

Viewing changes to spec/unit/node.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:
76
76
        Puppet::Node::Facts.stubs(:find).with(@node.name).returns(Puppet::Node::Facts.new(@node.name, "one" => "c", "two" => "b"))
77
77
    end
78
78
 
 
79
    it "should fail intelligently if it cannot find facts" do
 
80
        Puppet::Node::Facts.expects(:find).with(@node.name).raises "foo"
 
81
        lambda { @node.fact_merge }.should raise_error(Puppet::Error)
 
82
    end
 
83
 
79
84
    it "should prefer parameters already set on the node over facts from the node" do
80
85
        @node.parameters = {"one" => "a"}
81
86
        @node.fact_merge
93
98
        @node.merge "two" => "three"
94
99
        @node.parameters["two"].should == "three"
95
100
    end
 
101
 
 
102
    it "should add the environment to the list of parameters" do
 
103
        Puppet.settings.stubs(:value).with(:environments).returns("one,two")
 
104
        Puppet.settings.stubs(:value).with(:environment).returns("one")
 
105
        @node = Puppet::Node.new("testnode", :environment => "one")
 
106
        @node.merge "two" => "three"
 
107
        @node.parameters["environment"].should == "one"
 
108
    end
 
109
 
 
110
    it "should not set the environment if it is already set in the parameters" do
 
111
        Puppet.settings.stubs(:value).with(:environments).returns("one,two")
 
112
        Puppet.settings.stubs(:value).with(:environment).returns("one")
 
113
        @node = Puppet::Node.new("testnode", :environment => "one")
 
114
        @node.merge "environment" => "two"
 
115
        @node.parameters["environment"].should == "two"
 
116
    end
96
117
end
97
118
 
98
119
describe Puppet::Node, "when indirecting" do
112
133
    end
113
134
 
114
135
    after do
115
 
        Puppet::Indirector::Indirection.clear_cache
 
136
        Puppet::Util::Cacher.expire
116
137
    end
117
138
end
118
139
 
126
147
        @node.names.should be_instance_of(Array)
127
148
    end
128
149
 
129
 
    it "should have the node's fqdn as the second name" do
130
 
        @node.names[1].should == "yay.domain.com"
131
 
    end
132
 
 
133
 
    it "should set the fqdn to the node's 'fqdn' fact if it is available" do
134
 
        @node.parameters["fqdn"] = "boo.domain.com"
135
 
        @node.names[1].should == "boo.domain.com"
136
 
    end
137
 
 
138
 
    it "should set the fqdn to the node's hostname and domain if no fqdn is available" do
139
 
        @node.names[1].should == "yay.domain.com"
 
150
    describe "and the node name is fully qualified" do
 
151
        it "should contain an entry for each part of the node name" do
 
152
            @node.names.should be_include("foo.domain.com")
 
153
            @node.names.should be_include("foo.domain")
 
154
            @node.names.should be_include("foo")
 
155
        end
 
156
    end
 
157
 
 
158
    it "should include the node's fqdn" do
 
159
        @node.names.should be_include("yay.domain.com")
 
160
    end
 
161
 
 
162
    it "should combine and include the node's hostname and domain if no fqdn is available" do
 
163
        @node.names.should be_include("yay.domain.com")
140
164
    end
141
165
 
142
166
    it "should contain an entry for each name available by stripping a segment of the fqdn" do
143
167
        @node.parameters["fqdn"] = "foo.deep.sub.domain.com"
144
 
        @node.names[2].should == "foo.deep.sub.domain"
145
 
        @node.names[3].should == "foo.deep.sub"
 
168
        @node.names.should be_include("foo.deep.sub.domain")
 
169
        @node.names.should be_include("foo.deep.sub")
146
170
    end
147
171
 
148
172
    describe "and :node_name is set to 'cert'" do
149
173
        before do
 
174
            Puppet.settings.stubs(:value).with(:strict_hostname_checking).returns false
150
175
            Puppet.settings.stubs(:value).with(:node_name).returns "cert"
151
176
        end
152
177
 
153
178
        it "should use the passed-in key as the first value" do
154
179
            @node.names[0].should == "foo.domain.com"
155
180
        end
 
181
 
 
182
        describe "and strict hostname checking is enabled" do
 
183
            it "should only use the passed-in key" do
 
184
                Puppet.settings.expects(:value).with(:strict_hostname_checking).returns true
 
185
                @node.names.should == ["foo.domain.com"]
 
186
            end
 
187
        end
156
188
    end
157
189
 
158
190
    describe "and :node_name is set to 'facter'" do
159
191
        before do
 
192
            Puppet.settings.stubs(:value).with(:strict_hostname_checking).returns false
160
193
            Puppet.settings.stubs(:value).with(:node_name).returns "facter"
161
194
        end
162
195