~ubuntu-branches/ubuntu/quantal/puppet/quantal

« back to all changes in this revision

Viewing changes to spec/unit/network/authconfig_spec.rb

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-07-14 01:56:30 UTC
  • mfrom: (1.1.29) (3.1.43 sid)
  • Revision ID: package-import@ubuntu.com-20120714015630-ntj41rkvkq4zph4y
Tags: 2.7.18-1ubuntu1
* Resynchronise with Debian. (LP: #1023931) Remaining changes:
  - debian/puppetmaster-passenger.postinst: Make sure we error if puppet
    config print doesn't work
  - debian/puppetmaster-passenger.postinst: Ensure upgrades from
    <= 2.7.11-1 fixup passenger apache configuration.
* Dropped upstreamed patches:
  - debian/patches/CVE-2012-1906_CVE-2012-1986_to_CVE-2012-1989.patch
  - debian/patches/puppet-12844
  - debian/patches/2.7.17-Puppet-July-2012-CVE-fixes.patch
* Drop Build-Depends on ruby-rspec (in universe):
  - debian/control: remove ruby-rspec from Build-Depends
  - debian/patches/no-rspec.patch: make Rakefile work anyway if rspec
    isn't installed so we can use it in debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
  describe "when parsing authconfig file" do
98
98
    before :each do
99
99
      @fd = stub 'fd'
 
100
      @fd.expects(:each).never
100
101
      File.stubs(:open).yields(@fd)
101
102
      @rights.stubs(:include?).returns(false)
102
103
      @rights.stubs(:[])
103
104
    end
104
105
 
105
106
    it "should skip comments" do
106
 
      @fd.stubs(:each).yields('  # comment')
 
107
      @fd.stubs(:each_line).yields('  # comment')
107
108
 
108
109
      @rights.expects(:newright).never
109
110
 
111
112
    end
112
113
 
113
114
    it "should increment line number even on commented lines" do
114
 
      @fd.stubs(:each).multiple_yields('  # comment','[puppetca]')
 
115
      @fd.stubs(:each_line).multiple_yields('  # comment','[puppetca]')
115
116
 
116
117
      @rights.expects(:newright).with('[puppetca]', 2, 'dummy')
117
118
 
119
120
    end
120
121
 
121
122
    it "should skip blank lines" do
122
 
      @fd.stubs(:each).yields('  ')
 
123
      @fd.stubs(:each_line).yields('  ')
123
124
 
124
125
      @rights.expects(:newright).never
125
126
 
127
128
    end
128
129
 
129
130
    it "should increment line number even on blank lines" do
130
 
      @fd.stubs(:each).multiple_yields('  ','[puppetca]')
 
131
      @fd.stubs(:each_line).multiple_yields('  ','[puppetca]')
131
132
 
132
133
      @rights.expects(:newright).with('[puppetca]', 2, 'dummy')
133
134
 
135
136
    end
136
137
 
137
138
    it "should throw an error if the current namespace right already exist" do
138
 
      @fd.stubs(:each).yields('[puppetca]')
 
139
      @fd.stubs(:each_line).yields('[puppetca]')
139
140
 
140
141
      @rights.stubs(:include?).with("puppetca").returns(true)
141
142
 
143
144
    end
144
145
 
145
146
    it "should not throw an error if the current path right already exist" do
146
 
      @fd.stubs(:each).yields('path /hello')
 
147
      @fd.stubs(:each_line).yields('path /hello')
147
148
 
148
149
      @rights.stubs(:newright).with("/hello",1, 'dummy')
149
150
      @rights.stubs(:include?).with("/hello").returns(true)
152
153
    end
153
154
 
154
155
    it "should create a new right for found namespaces" do
155
 
      @fd.stubs(:each).yields('[puppetca]')
 
156
      @fd.stubs(:each_line).yields('[puppetca]')
156
157
 
157
158
      @rights.expects(:newright).with("[puppetca]", 1, 'dummy')
158
159
 
160
161
    end
161
162
 
162
163
    it "should create a new right for each found namespace line" do
163
 
      @fd.stubs(:each).multiple_yields('[puppetca]', '[fileserver]')
 
164
      @fd.stubs(:each_line).multiple_yields('[puppetca]', '[fileserver]')
164
165
 
165
166
      @rights.expects(:newright).with("[puppetca]", 1, 'dummy')
166
167
      @rights.expects(:newright).with("[fileserver]", 2, 'dummy')
169
170
    end
170
171
 
171
172
    it "should create a new right for each found path line" do
172
 
      @fd.stubs(:each).multiple_yields('path /certificates')
 
173
      @fd.stubs(:each_line).multiple_yields('path /certificates')
173
174
 
174
175
      @rights.expects(:newright).with("/certificates", 1, 'dummy')
175
176
 
177
178
    end
178
179
 
179
180
    it "should create a new right for each found regex line" do
180
 
      @fd.stubs(:each).multiple_yields('path ~ .rb$')
 
181
      @fd.stubs(:each_line).multiple_yields('path ~ .rb$')
181
182
 
182
183
      @rights.expects(:newright).with("~ .rb$", 1, 'dummy')
183
184
 
187
188
    it "should strip whitespace around ACE" do
188
189
      acl = stub 'acl', :info
189
190
 
190
 
      @fd.stubs(:each).multiple_yields('[puppetca]', ' allow 127.0.0.1 , 172.16.10.0  ')
 
191
      @fd.stubs(:each_line).multiple_yields('[puppetca]', ' allow 127.0.0.1 , 172.16.10.0  ')
191
192
      @rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
192
193
 
193
194
      acl.expects(:allow).with('127.0.0.1')
199
200
    it "should allow ACE inline comments" do
200
201
      acl = stub 'acl', :info
201
202
 
202
 
      @fd.stubs(:each).multiple_yields('[puppetca]', ' allow 127.0.0.1 # will it work?')
 
203
      @fd.stubs(:each_line).multiple_yields('[puppetca]', ' allow 127.0.0.1 # will it work?')
203
204
      @rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
204
205
 
205
206
      acl.expects(:allow).with('127.0.0.1')
210
211
    it "should create an allow ACE on each subsequent allow" do
211
212
      acl = stub 'acl', :info
212
213
 
213
 
      @fd.stubs(:each).multiple_yields('[puppetca]', 'allow 127.0.0.1')
 
214
      @fd.stubs(:each_line).multiple_yields('[puppetca]', 'allow 127.0.0.1')
214
215
      @rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
215
216
 
216
217
      acl.expects(:allow).with('127.0.0.1')
221
222
    it "should create a deny ACE on each subsequent deny" do
222
223
      acl = stub 'acl', :info
223
224
 
224
 
      @fd.stubs(:each).multiple_yields('[puppetca]', 'deny 127.0.0.1')
 
225
      @fd.stubs(:each_line).multiple_yields('[puppetca]', 'deny 127.0.0.1')
225
226
      @rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
226
227
 
227
228
      acl.expects(:deny).with('127.0.0.1')
233
234
      acl = stub 'acl', :info
234
235
      acl.stubs(:acl_type).returns(:regex)
235
236
 
236
 
      @fd.stubs(:each).multiple_yields('path /certificates', 'method search,find')
 
237
      @fd.stubs(:each_line).multiple_yields('path /certificates', 'method search,find')
237
238
      @rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
238
239
 
239
240
      acl.expects(:restrict_method).with('search')
246
247
      acl = stub 'acl', :info
247
248
      acl.stubs(:acl_type).returns(:regex)
248
249
 
249
 
      @fd.stubs(:each).multiple_yields('[puppetca]', 'method search,find')
 
250
      @fd.stubs(:each_line).multiple_yields('[puppetca]', 'method search,find')
250
251
      @rights.stubs(:newright).with("puppetca", 1, 'dummy').returns(acl)
251
252
 
252
253
      lambda { @authconfig.read }.should raise_error
256
257
      acl = stub 'acl', :info
257
258
      acl.stubs(:acl_type).returns(:regex)
258
259
 
259
 
      @fd.stubs(:each).multiple_yields('path /certificates', 'environment production,development')
 
260
      @fd.stubs(:each_line).multiple_yields('path /certificates', 'environment production,development')
260
261
      @rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
261
262
 
262
263
      acl.expects(:restrict_environment).with('production')
269
270
      acl = stub 'acl', :info
270
271
      acl.stubs(:acl_type).returns(:regex)
271
272
 
272
 
      @fd.stubs(:each).multiple_yields('[puppetca]', 'environment env')
 
273
      @fd.stubs(:each_line).multiple_yields('[puppetca]', 'environment env')
273
274
      @rights.stubs(:newright).with("puppetca", 1, 'dummy').returns(acl)
274
275
 
275
276
      lambda { @authconfig.read }.should raise_error
279
280
      acl = stub 'acl', :info
280
281
      acl.stubs(:acl_type).returns(:regex)
281
282
 
282
 
      @fd.stubs(:each).multiple_yields('path /certificates', 'auth yes')
 
283
      @fd.stubs(:each_line).multiple_yields('path /certificates', 'auth yes')
283
284
      @rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
284
285
 
285
286
      acl.expects(:restrict_authenticated).with('yes')
291
292
      acl = stub 'acl', :info
292
293
      acl.stubs(:acl_type).returns(:regex)
293
294
 
294
 
      @fd.stubs(:each).multiple_yields('path /certificates', 'authenticated yes')
 
295
      @fd.stubs(:each_line).multiple_yields('path /certificates', 'authenticated yes')
295
296
      @rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
296
297
 
297
298
      acl.expects(:restrict_authenticated).with('yes')
303
304
      acl = stub 'acl', :info
304
305
      acl.stubs(:acl_type).returns(:regex)
305
306
 
306
 
      @fd.stubs(:each).multiple_yields('[puppetca]', 'auth yes')
 
307
      @fd.stubs(:each_line).multiple_yields('[puppetca]', 'auth yes')
307
308
      @rights.stubs(:newright).with("puppetca", 1, 'dummy').returns(acl)
308
309
 
309
310
      lambda { @authconfig.read }.should raise_error