File: file.rb

package info (click to toggle)
ruby-gitlab-fog-azure-rm 1.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 756 kB
  • sloc: ruby: 5,926; sh: 9; makefile: 4
file content (252 lines) | stat: -rw-r--r-- 10,338 bytes parent folder | download | duplicates (2)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
module ApiStub
  module Requests
    module Storage
      # Mock class for Deployment Requests
      # Below data should be as same as those in Mock classes in lib/fog/azurerm/requests/storage/*.rb
      class File
        def self.blob
          blob_data = blob_as_hash
          blob = Azure::Storage::Blob::Blob.new
          blob.name = blob_data['name']
          blob.metadata = blob_data['metadata']
          blob.properties = blob_data['properties'].map { |k, v| { k.to_sym => v } }.reduce({}, &:merge!)
          blob
        end

        def self.blob_as_hash
          {
            'name' => 'test_blob',
            'metadata' => {},
            'properties' => {
              'last_modified' => 'Mon, 04 Jul 2016 09:30:31 GMT',
              'etag' => '0x8D3A3EDD7C2B777',
              'lease_status' => 'unlocked',
              'lease_state' => 'available',
              'lease_duration' => nil,
              'content_length' => 4_194_304,
              'content_type' => 'application/octet-stream',
              'content_encoding' => nil,
              'content_language' => nil,
              'content_disposition' => nil,
              'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
              'cache_control' => nil,
              'sequence_number' => 0,
              'blob_type' => 'PageBlob',
              'copy_id' => '095adc3b-e277-4c3d-97e0-0abca881f60c',
              'copy_status' => 'success',
              'copy_source' => 'https://testaccount.blob.core.windows.net/testblob/4m?snapshot=2016-02-04T08%3A35%3A50.3157696Z',
              'copy_progress' => '4194304/4194304',
              'copy_completion_time' => 'Thu, 04 Feb 2016 08:35:52 GMT',
              'copy_status_description' => nil,
              'accept_ranges' => 0
            }
          }
        end

        def self.blob_https_url(environment = Fog::AzureRM::ENVIRONMENT_AZURE_CLOUD)
          case environment
          when Fog::AzureRM::ENVIRONMENT_AZURE_CHINA_CLOUD
            'https://mockaccount.blob.core.chinacloudapi.cn/test_container/test_blob'
          when Fog::AzureRM::ENVIRONMENT_AZURE_US_GOVERNMENT
            'https://mockaccount.blob.core.usgovcloudapi.net/test_container/test_blob'
          when Fog::AzureRM::ENVIRONMENT_AZURE_GERMAN_CLOUD
            'https://mockaccount.blob.core.cloudapi.de/test_container/test_blob'
          else
            'https://mockaccount.blob.core.windows.net/test_container/test_blob'
          end
        end

        def self.blob_url_token
          'token'
        end

        def self.blob_lease_id
          {
            'leaseId' => 'abc123'
          }
        end

        def self.blob_metadata
          {
            'created-by' => 'User',
            'source-machine' => 'Test-machine',
            'category' => 'guidance',
            'doctype' => 'textDocuments'
          }
        end

        def self.blob_copy_result
          # copy_id, copy_status
          %w(abc123 pending)
        end

        def self.block_blob
          {
            'name' => 'test_blob',
            'metadata' => {},
            'properties' => {
              'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
              'etag' => '0x8D3A3B5F017F52D',
              'lease_status' => 'unlocked',
              'lease_state' => 'available',
              'content_length' => 4_194_304,
              'content_type' => 'application/octet-stream',
              'content_encoding' => nil,
              'content_language' => nil,
              'content_disposition' => nil,
              'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
              'cache_control' => nil,
              'sequence_number' => 0,
              'blob_type' => 'BlockBlob',
              'copy_id' => '095adc3b-e277-4c3d-97e0-0abca881f60c',
              'copy_status' => 'success',
              'copy_source' => 'https://testaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A50.3256874Z',
              'copy_progress' => '4194304/4194304',
              'copy_completion_time' => 'Thu, 04 Feb 2016 08:35:52 GMT',
              'copy_status_description' => nil,
              'accept_ranges' => 0
            }
          }
        end

        def self.emtpy_block_blob
          {
            'name' => 'test_blob',
            'metadata' => {},
            'properties' => {
              'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
              'etag' => '0x8D3A3B5F017F52D',
              'lease_status' => nil,
              'lease_state' => nil,
              'content_length' => 0,
              'content_type' => 'application/octet-stream',
              'content_encoding' => nil,
              'content_language' => nil,
              'content_disposition' => nil,
              'content_md5' => nil,
              'cache_control' => nil,
              'sequence_number' => 0,
              'blob_type' => 'BlockBlob',
              'copy_id' => nil,
              'copy_status' => nil,
              'copy_source' => nil,
              'copy_progress' => nil,
              'copy_completion_time' => nil,
              'copy_status_description' => nil,
              'accept_ranges' => 0
            }
          }
        end

        def self.blob_list
          [
            {
              'name' => 'test_blob1',
              'metadata' => {},
              'properties' => {
                'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
                'etag' => '0x8D3A3B5F017F52D',
                'lease_status' => 'unlocked',
                'lease_state' => 'available',
                'content_length' => 4_194_304,
                'content_type' => 'application/octet-stream',
                'content_encoding' => nil,
                'content_language' => nil,
                'content_disposition' => nil,
                'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
                'cache_control' => nil,
                'sequence_number' => 0,
                'blob_type' => 'PageBlob',
                'copy_id' => '095adc3b-e277-4c3d-97e0-0abca881f60c',
                'copy_status' => 'success',
                'copy_source' => 'https://testaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A50.3256874Z',
                'copy_progress' => '4194304/4194304',
                'copy_completion_time' => 'Thu, 04 Feb 2016 08:35:52 GMT',
                'copy_status_description' => nil,
                'accept_ranges' => 0
              }
            },
            {
              'name' => 'test_blob2',
              'metadata' => {},
              'properties' => {
                'last_modified' => 'Tue, 04 Aug 2015 06:02:08 GMT',
                'etag' => '0x8D29C92173526C8',
                'lease_status' => 'unlocked',
                'lease_state' => 'available',
                'content_length' => 4_194_304,
                'content_type' => 'application/octet-stream',
                'content_encoding' => nil,
                'content_language' => nil,
                'content_disposition' => nil,
                'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
                'cache_control' => nil,
                'sequence_number' => 0,
                'blob_type' => 'PageBlob',
                'copy_id' => '0abcdc3b-4c3d-e277-97e0-0abca881f60c',
                'copy_status' => 'success',
                'copy_source' => 'https://testaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A55.3157696Z',
                'copy_progress' => '4194304/4194304',
                'copy_completion_time' => 'Thu, 04 Feb 2016 08:40:52 GMT',
                'copy_status_description' => nil,
                'accept_ranges' => 0
              }
            },
            {
              'name' => 'test_blob3',
              'metadata' => {},
              'properties' => {
                'last_modified' => 'Tue, 04 Aug 2015 06:02:08 GMT',
                'etag' => '0x8D29C92173526C8',
                'lease_status' => 'unlocked',
                'lease_state' => 'available',
                'content_length' => 4_194_304,
                'content_type' => 'application/octet-stream',
                'content_encoding' => nil,
                'content_language' => nil,
                'content_disposition' => nil,
                'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
                'cache_control' => nil,
                'sequence_number' => 0,
                'blob_type' => 'PageBlob',
                'copy_id' => '0abcdc3b-4c3d-e277-97e0-0abca881f60c',
                'copy_status' => 'success',
                'copy_source' => 'https://testaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A55.3157696Z',
                'copy_progress' => '4194304/4194304',
                'copy_completion_time' => 'Thu, 04 Feb 2016 08:40:52 GMT',
                'copy_status_description' => nil,
                'accept_ranges' => 0
              }
            },
            {
              'name' => 'test_blob4',
              'metadata' => {},
              'properties' => {
                'last_modified' => 'Tue, 04 Aug 2015 06:02:08 GMT',
                'etag' => '0x8D29C92173526C8',
                'lease_status' => 'unlocked',
                'lease_state' => 'available',
                'content_length' => 4_194_304,
                'content_type' => 'application/octet-stream',
                'content_encoding' => nil,
                'content_language' => nil,
                'content_disposition' => nil,
                'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
                'cache_control' => nil,
                'sequence_number' => 0,
                'blob_type' => 'PageBlob',
                'copy_id' => '0abcdc3b-4c3d-e277-97e0-0abca881f60c',
                'copy_status' => 'success',
                'copy_source' => 'https://testaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A55.3157696Z',
                'copy_progress' => '4194304/4194304',
                'copy_completion_time' => 'Thu, 04 Feb 2016 08:40:52 GMT',
                'copy_status_description' => nil,
                'accept_ranges' => 0
              }
            }
          ]
        end
      end
    end
  end
end