2
shared_examples_for "Puppet::FileServing::Files" do
3
it "should use the rest terminus when the 'puppet' URI scheme is used and a host name is present" do
4
uri = "puppet://myhost/fakemod/my/file"
6
# It appears that the mocking somehow interferes with the caching subsystem.
7
# This mock somehow causes another terminus to get generated.
8
term = @indirection.terminus(:rest)
9
@indirection.stubs(:terminus).with(:rest).returns term
11
@indirection.find(uri)
14
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
15
uri = "puppet:///fakemod/my/file"
16
Puppet.settings.stubs(:value).returns "foo"
17
Puppet.settings.stubs(:value).with(:name).returns("puppetd")
18
Puppet.settings.stubs(:value).with(:modulepath).returns("")
19
@indirection.terminus(:rest).expects(:find)
20
@indirection.find(uri)
23
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
24
uri = "puppet:///fakemod/my/file"
25
Puppet::Node::Environment.stubs(:new).returns(stub("env", :name => "testing", :module => nil, :modulepath => []))
26
Puppet.settings.stubs(:value).returns ""
27
Puppet.settings.stubs(:value).with(:name).returns("puppet")
28
Puppet.settings.stubs(:value).with(:fileserverconfig).returns("/whatever")
29
@indirection.terminus(:file_server).expects(:find)
30
@indirection.terminus(:file_server).stubs(:authorized?).returns(true)
31
@indirection.find(uri)
34
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
35
uri = "puppet:///fakemod/my/file"
36
Puppet::Node::Environment.stubs(:new).returns(stub("env", :name => "testing", :module => nil, :modulepath => []))
37
Puppet.settings.stubs(:value).returns ""
38
Puppet.settings.stubs(:value).with(:name).returns("apply")
39
Puppet.settings.stubs(:value).with(:fileserverconfig).returns("/whatever")
40
@indirection.terminus(:file_server).expects(:find)
41
@indirection.terminus(:file_server).stubs(:authorized?).returns(true)
42
@indirection.find(uri)
45
it "should use the file terminus when the 'file' URI scheme is used" do
46
uri = Puppet::Util.path_to_uri(File.expand_path('/fakemod/my/other file'))
47
uri.scheme.should == 'file'
48
@indirection.terminus(:file).expects(:find)
49
@indirection.find(uri.to_s)
52
it "should use the file terminus when a fully qualified path is provided" do
53
uri = File.expand_path("/fakemod/my/file")
54
@indirection.terminus(:file).expects(:find)
55
@indirection.find(uri)
58
it "should use the configuration to test whether the request is allowed" do
59
uri = "fakemod/my/file"
61
config = stub 'configuration', :split_path => [mount, "eh"]
62
@indirection.terminus(:file_server).stubs(:configuration).returns config
64
@indirection.terminus(:file_server).expects(:find)
65
mount.expects(:allowed?).returns(true)
66
@indirection.find(uri, :node => "foo", :ip => "bar")