File: mock.rb

package info (click to toggle)
ruby-fog-google 1.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,568 kB
  • sloc: ruby: 16,775; makefile: 3
file content (102 lines) | stat: -rw-r--r-- 3,178 bytes parent folder | download | duplicates (5)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
module Fog
  module Storage
    class GoogleXML
      class Mock
        include Utils

        def self.acls(type)
          case type
          when "private"
            {
              "AccessControlList" => [
                {
                  "Permission" => "FULL_CONTROL",
                  "Scope" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById" }
                }
              ],
              "Owner" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0" }
            }
          when "public-read"
            {
              "AccessControlList" => [
                {
                  "Permission" => "FULL_CONTROL",
                  "Scope" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById" }
                },
                {
                  "Permission" => "READ",
                  "Scope" => { "type" => "AllUsers" }
                }
              ],
              "Owner" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0" }
            }
          when "public-read-write"
            {
              "AccessControlList" => [
                {
                  "Permission" => "FULL_CONTROL",
                  "Scope" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById" }
                },
                {
                  "Permission" => "READ",
                  "Scope" => { "type" => "AllUsers" }
                },
                {
                  "Permission" => "WRITE",
                  "Scope" => { "type" => "AllUsers" }
                }
              ],
              "Owner" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0" }
            }
          when "authenticated-read"
            {
              "AccessControlList" => [
                {
                  "Permission" => "FULL_CONTROL",
                  "Scope" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById" }
                },
                {
                  "Permission" => "READ",
                  "Scope" => { "type" => "AllAuthenticatedUsers" }
                }
              ],
              "Owner" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0" }
            }
          end
        end

        def self.data
          @data ||= Hash.new do |hash, key|
            hash[key] = {
              :acls => {
                :bucket => {},
                :object => {}
              },
              :buckets => {}
            }
          end
        end

        def self.reset
          @data = nil
        end

        def initialize(options = {})
          @google_storage_access_key_id = options[:google_storage_access_key_id]
        end

        def data
          self.class.data[@google_storage_access_key_id]
        end

        def reset_data
          self.class.data.delete(@google_storage_access_key_id)
        end

        def signature(_params)
          "foo"
        end
      end
    end
  end
end