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
|
#!/usr/bin/env rspec
shared_examples_for "Puppet::FileServing::Files" do
it "should use the rest terminus when the 'puppet' URI scheme is used and a host name is present" do
uri = "puppet://myhost/fakemod/my/file"
# It appears that the mocking somehow interferes with the caching subsystem.
# This mock somehow causes another terminus to get generated.
term = @indirection.terminus(:rest)
@indirection.stubs(:terminus).with(:rest).returns term
term.expects(:find)
@indirection.find(uri)
end
it "should use the rest terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is not 'puppet' or 'apply'" do
uri = "puppet:///fakemod/my/file"
Puppet.settings.stubs(:value).returns "foo"
Puppet.settings.stubs(:value).with(:name).returns("puppetd")
Puppet.settings.stubs(:value).with(:modulepath).returns("")
@indirection.terminus(:rest).expects(:find)
@indirection.find(uri)
end
it "should use the file_server terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is 'puppet'" do
uri = "puppet:///fakemod/my/file"
Puppet::Node::Environment.stubs(:new).returns(stub("env", :name => "testing", :module => nil, :modulepath => []))
Puppet.settings.stubs(:value).returns ""
Puppet.settings.stubs(:value).with(:name).returns("puppet")
Puppet.settings.stubs(:value).with(:fileserverconfig).returns("/whatever")
@indirection.terminus(:file_server).expects(:find)
@indirection.terminus(:file_server).stubs(:authorized?).returns(true)
@indirection.find(uri)
end
it "should use the file_server terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is 'apply'" do
uri = "puppet:///fakemod/my/file"
Puppet::Node::Environment.stubs(:new).returns(stub("env", :name => "testing", :module => nil, :modulepath => []))
Puppet.settings.stubs(:value).returns ""
Puppet.settings.stubs(:value).with(:name).returns("apply")
Puppet.settings.stubs(:value).with(:fileserverconfig).returns("/whatever")
@indirection.terminus(:file_server).expects(:find)
@indirection.terminus(:file_server).stubs(:authorized?).returns(true)
@indirection.find(uri)
end
it "should use the file terminus when the 'file' URI scheme is used" do
uri = "file:///fakemod/my/file"
@indirection.terminus(:file).expects(:find)
@indirection.find(uri)
end
it "should use the file terminus when a fully qualified path is provided" do
uri = "/fakemod/my/file"
@indirection.terminus(:file).expects(:find)
@indirection.find(uri)
end
it "should use the configuration to test whether the request is allowed" do
uri = "fakemod/my/file"
mount = mock 'mount'
config = stub 'configuration', :split_path => [mount, "eh"]
@indirection.terminus(:file_server).stubs(:configuration).returns config
@indirection.terminus(:file_server).expects(:find)
mount.expects(:allowed?).returns(true)
@indirection.find(uri, :node => "foo", :ip => "bar")
end
end
|