File: file_serving.rb

package info (click to toggle)
puppet 5.5.10-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 21,116 kB
  • sloc: ruby: 250,669; sh: 1,620; xml: 218; makefile: 151; sql: 103
file content (75 lines) | stat: -rw-r--r-- 2,406 bytes parent folder | download | duplicates (6)
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
68
69
70
71
72
73
74
75
#! /usr/bin/env ruby

shared_examples_for "Puppet::FileServing::Files" do |indirection|
  %w[find search].each do |method|
    let(:request) { Puppet::Indirector::Request.new(indirection, method, 'foo', nil) }

    describe "##{method}" do
      it "should proxy to file terminus if the path is absolute" do
        request.key = make_absolute('/tmp/foo')

        described_class.indirection.terminus(:file).class.any_instance.expects(method).with(request)

        subject.send(method, request)
      end

      it "should proxy to file terminus if the protocol is file" do
        request.protocol = 'file'

        described_class.indirection.terminus(:file).class.any_instance.expects(method).with(request)

        subject.send(method, request)
      end

      describe "when the protocol is puppet" do
        before :each do
          request.protocol = 'puppet'
        end

        describe "and a server is specified" do
          before :each do
            request.server = 'puppet_server'
          end

          it "should proxy to rest terminus if default_file_terminus is rest" do
            Puppet[:default_file_terminus] = "rest"

            described_class.indirection.terminus(:rest).class.any_instance.expects(method).with(request)

            subject.send(method, request)
          end

          it "should proxy to rest terminus if default_file_terminus is not rest" do
            Puppet[:default_file_terminus] = 'file_server'

            described_class.indirection.terminus(:rest).class.any_instance.expects(method).with(request)

            subject.send(method, request)
          end
        end

        describe "and no server is specified" do
          before :each do
            request.server = nil
          end

          it "should proxy to file_server if default_file_terminus is 'file_server'" do
            Puppet[:default_file_terminus] = 'file_server'

            described_class.indirection.terminus(:file_server).class.any_instance.expects(method).with(request)

            subject.send(method, request)
          end

          it "should proxy to rest if default_file_terminus is 'rest'" do
            Puppet[:default_file_terminus] = "rest"

            described_class.indirection.terminus(:rest).class.any_instance.expects(method).with(request)

            subject.send(method, request)
          end
        end
      end
    end
  end
end