gitlab-fog-azure-rm 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +12 -0
  3. data/.rubocop_todo.yml +1 -1
  4. data/gitlab-fog-azure-rm.gemspec +3 -2
  5. data/lib/fog/azurerm/docs/storage.md +1 -1
  6. data/lib/fog/azurerm/identity_encoding_filter.rb +12 -0
  7. data/lib/fog/azurerm/models/storage/directories.rb +6 -6
  8. data/lib/fog/azurerm/models/storage/directory.rb +4 -4
  9. data/lib/fog/azurerm/models/storage/file.rb +6 -3
  10. data/lib/fog/azurerm/models/storage/files.rb +8 -8
  11. data/lib/fog/azurerm/models/storage/storage_account.rb +4 -4
  12. data/lib/fog/azurerm/models/storage/storage_accounts.rb +6 -6
  13. data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +2 -2
  14. data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +2 -2
  15. data/lib/fog/azurerm/requests/storage/check_container_exists.rb +2 -2
  16. data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +2 -2
  17. data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +2 -2
  18. data/lib/fog/azurerm/requests/storage/copy_blob.rb +2 -2
  19. data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +2 -2
  20. data/lib/fog/azurerm/requests/storage/copy_object.rb +2 -2
  21. data/lib/fog/azurerm/requests/storage/create_block_blob.rb +2 -2
  22. data/lib/fog/azurerm/requests/storage/create_container.rb +2 -2
  23. data/lib/fog/azurerm/requests/storage/create_page_blob.rb +2 -2
  24. data/lib/fog/azurerm/requests/storage/delete_blob.rb +2 -2
  25. data/lib/fog/azurerm/requests/storage/delete_blob_https_url.rb +4 -4
  26. data/lib/fog/azurerm/requests/storage/delete_container.rb +2 -2
  27. data/lib/fog/azurerm/requests/storage/delete_object.rb +2 -2
  28. data/lib/fog/azurerm/requests/storage/delete_object_url.rb +2 -2
  29. data/lib/fog/azurerm/requests/storage/get_blob.rb +2 -2
  30. data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +5 -5
  31. data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +6 -5
  32. data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +2 -2
  33. data/lib/fog/azurerm/requests/storage/get_blob_url.rb +4 -4
  34. data/lib/fog/azurerm/requests/storage/get_container_acl.rb +2 -2
  35. data/lib/fog/azurerm/requests/storage/get_container_properties.rb +2 -2
  36. data/lib/fog/azurerm/requests/storage/get_container_url.rb +4 -4
  37. data/lib/fog/azurerm/requests/storage/get_object.rb +2 -2
  38. data/lib/fog/azurerm/requests/storage/get_object_url.rb +2 -2
  39. data/lib/fog/azurerm/requests/storage/list_blobs.rb +2 -2
  40. data/lib/fog/azurerm/requests/storage/list_containers.rb +2 -2
  41. data/lib/fog/azurerm/requests/storage/put_blob_block.rb +2 -2
  42. data/lib/fog/azurerm/requests/storage/put_blob_http_url.rb +39 -0
  43. data/lib/fog/azurerm/requests/storage/put_blob_https_url.rb +4 -4
  44. data/lib/fog/azurerm/requests/storage/put_blob_metadata.rb +2 -2
  45. data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +2 -2
  46. data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +2 -2
  47. data/lib/fog/azurerm/requests/storage/put_container_acl.rb +2 -2
  48. data/lib/fog/azurerm/requests/storage/put_container_metadata.rb +2 -2
  49. data/lib/fog/azurerm/requests/storage/put_object_url.rb +2 -2
  50. data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +2 -2
  51. data/lib/fog/azurerm/requests/storage/release_container_lease.rb +2 -2
  52. data/lib/fog/azurerm/requests/storage/save_page_blob.rb +2 -2
  53. data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +2 -2
  54. data/lib/fog/azurerm/storage.rb +62 -9
  55. data/lib/fog/azurerm/utilities/general.rb +0 -5
  56. data/lib/fog/azurerm/version.rb +1 -1
  57. data/lib/fog/azurerm.rb +4 -5
  58. data/rakefile +4 -5
  59. data/test/api_stub/models/storage/directory.rb +1 -1
  60. data/test/api_stub/models/storage/file.rb +1 -1
  61. data/test/api_stub/requests/storage/directory.rb +1 -1
  62. data/test/api_stub/requests/storage/file.rb +4 -4
  63. data/test/integration/README.md +5 -7
  64. data/test/integration/blob.rb +28 -36
  65. data/test/integration/container.rb +8 -39
  66. data/test/integration/credentials/azure.yml +4 -5
  67. data/test/models/storage/test_directories.rb +5 -5
  68. data/test/models/storage/test_directory.rb +2 -2
  69. data/test/models/storage/test_file.rb +16 -4
  70. data/test/models/storage/test_files.rb +8 -8
  71. data/test/requests/storage/test_acquire_blob_lease.rb +2 -2
  72. data/test/requests/storage/test_acquire_container_lease.rb +2 -2
  73. data/test/requests/storage/test_check_container_exists.rb +1 -1
  74. data/test/requests/storage/test_commit_blob_blocks.rb +2 -2
  75. data/test/requests/storage/test_compare_container_blobs.rb +2 -2
  76. data/test/requests/storage/test_copy_blob.rb +2 -2
  77. data/test/requests/storage/test_copy_blob_from_uri.rb +2 -2
  78. data/test/requests/storage/test_create_block_blob.rb +2 -2
  79. data/test/requests/storage/test_create_container.rb +2 -2
  80. data/test/requests/storage/test_create_page_blob.rb +2 -2
  81. data/test/requests/storage/test_delete_blob.rb +2 -2
  82. data/test/requests/storage/test_delete_blob_https_url.rb +7 -10
  83. data/test/requests/storage/test_delete_container.rb +2 -2
  84. data/test/requests/storage/test_delete_object.rb +2 -2
  85. data/test/requests/storage/test_get_blob.rb +2 -2
  86. data/test/requests/storage/test_get_blob_encoding.rb +45 -0
  87. data/test/requests/storage/test_get_blob_http_url.rb +13 -9
  88. data/test/requests/storage/test_get_blob_https_url.rb +95 -13
  89. data/test/requests/storage/test_get_blob_properties.rb +2 -2
  90. data/test/requests/storage/test_get_blob_url.rb +15 -24
  91. data/test/requests/storage/test_get_container_acl.rb +2 -2
  92. data/test/requests/storage/test_get_container_properties.rb +2 -2
  93. data/test/requests/storage/test_get_container_url.rb +5 -8
  94. data/test/requests/storage/test_get_object.rb +2 -2
  95. data/test/requests/storage/test_list_blobs.rb +2 -2
  96. data/test/requests/storage/test_list_containers.rb +2 -2
  97. data/test/requests/storage/test_put_blob_block.rb +2 -2
  98. data/test/requests/storage/test_put_blob_http_url.rb +33 -0
  99. data/test/requests/storage/test_put_blob_https_url.rb +8 -11
  100. data/test/requests/storage/test_put_blob_metadata.rb +2 -2
  101. data/test/requests/storage/test_put_blob_pages.rb +2 -2
  102. data/test/requests/storage/test_put_blob_properties.rb +2 -2
  103. data/test/requests/storage/test_put_container_acl.rb +2 -2
  104. data/test/requests/storage/test_put_container_metadata.rb +2 -2
  105. data/test/requests/storage/test_release_blob_lease.rb +2 -2
  106. data/test/requests/storage/test_release_container_lease.rb +2 -2
  107. data/test/requests/storage/test_save_page_blob.rb +2 -2
  108. data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +15 -6
  109. data/test/test_helper.rb +38 -690
  110. metadata +27 -20
  111. data/lib/fog/azurerm/models/resources/azure_resource.rb +0 -25
  112. data/lib/fog/azurerm/models/resources/azure_resources.rb +0 -40
  113. data/lib/fog/azurerm/models/resources/dependency.rb +0 -27
  114. data/lib/fog/azurerm/models/resources/deployment.rb +0 -65
  115. data/lib/fog/azurerm/models/resources/deployments.rb +0 -30
  116. data/lib/fog/azurerm/models/resources/provider.rb +0 -27
  117. data/lib/fog/azurerm/models/resources/provider_resource_type.rb +0 -22
  118. data/lib/fog/azurerm/models/resources/resource_group.rb +0 -34
  119. data/lib/fog/azurerm/models/resources/resource_groups.rb +0 -29
  120. data/test/integration/storage_account.rb +0 -135
  121. data/test/smoke_tests/compute/test_resource_group_smoke.rb +0 -37
data/test/test_helper.rb CHANGED
@@ -14,6 +14,20 @@ if ENV['CODECLIMATE_REPO_TOKEN']
14
14
  end
15
15
  end
16
16
 
17
+ class TestRaiseLogger
18
+ def write(message)
19
+ raise message
20
+ end
21
+
22
+ def tty?
23
+ false
24
+ end
25
+ end
26
+
27
+ require 'fog/core/logger'
28
+ Fog::Logger[:deprecation] = TestRaiseLogger.new
29
+ Fog::Logger[:warning] = TestRaiseLogger.new
30
+
17
31
  require 'minitest/autorun'
18
32
  require 'azure/core/http/http_error'
19
33
  require 'azure/core/http/http_response'
@@ -28,6 +42,14 @@ def storage_account_credentials
28
42
  }
29
43
  end
30
44
 
45
+ def storage_account_credentials_with_endpoint
46
+ storage_account_credentials.merge(
47
+ {
48
+ azure_storage_endpoint: 'http://localhost:10000/mockaccount'
49
+ }
50
+ )
51
+ end
52
+
31
53
  def storage_account_credentials_with_domain
32
54
  storage_account_credentials.merge(
33
55
  {
@@ -36,6 +58,17 @@ def storage_account_credentials_with_domain
36
58
  )
37
59
  end
38
60
 
61
+ def storage_account_credentials_with_token_signer
62
+ {
63
+ azure_storage_account_name: 'mockaccount',
64
+ azure_storage_token_signer: mock_token_signer
65
+ }
66
+ end
67
+
68
+ def mock_token_signer
69
+ @mock_token_signer ||= Minitest::Mock.new(Azure::Core::Auth::Signer.new('access-token'))
70
+ end
71
+
39
72
  # Mock Class for Blob
40
73
  class MockBlob
41
74
  def initialize
@@ -75,115 +108,8 @@ def mocked_storage_http_not_found_error
75
108
  Azure::Core::Http::HttpResponse.new mocked_net_response, 'mocked_uri'
76
109
  end
77
110
 
78
- def server(service)
79
- Fog::Compute::AzureRM::Server.new(
80
- name: 'fog-test-server',
81
- location: 'West US',
82
- resource_group: 'fog-test-rg',
83
- vm_size: 'Basic_A0',
84
- storage_account_name: 'shaffanstrg',
85
- username: 'shaffan',
86
- password: 'Confiz=123',
87
- disable_password_authentication: false,
88
- network_interface_card_ids: ['/subscriptions/########-####-####-####-############/resourceGroups/shaffanRG/providers/Microsoft.Network/networkInterfaces/testNIC'],
89
- publisher: 'Canonical',
90
- offer: 'UbuntuServer',
91
- sku: '14.04.2-LTS',
92
- version: 'latest',
93
- platform: 'Windows',
94
- service: service
95
- )
96
- end
97
-
98
- def virtual_machine_extension(service)
99
- Fog::Compute::AzureRM::VirtualMachineExtension.new(
100
- name: 'fog-test-extension',
101
- location: 'West US',
102
- resource_group: 'fog-test-rg',
103
- vm_name: 'fog-test-vm',
104
- type: 'fog-test-extension-type',
105
- publisher: 'fog-test-extension-publisher',
106
- type_handler_version: 'fog-test-extension-version',
107
- auto_upgrade_minor_version: 'fog-test-extension-upgrade',
108
- settings: '{"Key" => "Value"}',
109
- protected_settings: '{"Key" => "Value"}',
110
- service: service
111
- )
112
- end
113
-
114
- def availability_set(service)
115
- Fog::Compute::AzureRM::AvailabilitySet.new(
116
- name: 'availability-set',
117
- location: 'West US',
118
- resource_group: 'fog-test-rg',
119
- use_managed_disk: false,
120
- sku_name: 'Classic',
121
- service: service
122
- )
123
- end
124
-
125
- def resource_group(service)
126
- Fog::Resources::AzureRM::ResourceGroup.new(
127
- name: 'fog-test-rg',
128
- location: 'West US',
129
- service: service
130
- )
131
- end
132
-
133
- def deployment(service)
134
- Fog::Resources::AzureRM::Deployment.new(
135
- name: 'fog-test-deployment',
136
- resource_group: 'fog-test-rg',
137
- template_link: 'https://test.com/template.json',
138
- parameters_link: 'https://test.com/parameters.json',
139
- service: service
140
- )
141
- end
142
-
143
- def storage_account(service)
144
- Fog::Storage::AzureRM::StorageAccount.new(
145
- name: 'storage-account',
146
- location: 'West US',
147
- resource_group: 'fog-test-rg',
148
- service: service
149
- )
150
- end
151
-
152
- def standard_lrs(service)
153
- Fog::Storage::AzureRM::StorageAccount.new(
154
- name: 'storage-account',
155
- location: 'West US',
156
- resource_group: 'fog-test-rg',
157
- sku_name: 'Other',
158
- replication: 'LRS',
159
- service: service
160
- )
161
- end
162
-
163
- def standard_check_for_invalid_replications(service)
164
- Fog::Storage::AzureRM::StorageAccount.new(
165
- name: 'storage-account',
166
- location: 'West US',
167
- resource_group: 'fog-test-rg',
168
- sku_name: 'Standard',
169
- replication: 'HGDKS',
170
- service: service
171
- )
172
- end
173
-
174
- def premium_check_for_invalid_replications(service)
175
- Fog::Storage::AzureRM::StorageAccount.new(
176
- name: 'storage-account',
177
- location: 'West US',
178
- resource_group: 'fog-test-rg',
179
- sku_name: 'Premium',
180
- replication: 'HGDKS',
181
- service: service
182
- )
183
- end
184
-
185
111
  def directory(service)
186
- Fog::Storage::AzureRM::Directory.new(
112
+ Fog::AzureRM::Storage::Directory.new(
187
113
  key: 'test_container',
188
114
  acl: 'container',
189
115
  etag: '0x8D29C92176C8352',
@@ -196,12 +122,12 @@ def directory(service)
196
122
  'key2' => 'value2'
197
123
  },
198
124
  service: service,
199
- collection: Fog::Storage::AzureRM::Directories.new(service: @service)
125
+ collection: Fog::AzureRM::Storage::Directories.new(service: @service)
200
126
  )
201
127
  end
202
128
 
203
129
  def file(service)
204
- Fog::Storage::AzureRM::File.new(
130
+ Fog::AzureRM::Storage::File.new(
205
131
  key: 'test_blob',
206
132
  directory: directory(service),
207
133
  last_modified: Time.parse('Tue, 04 Aug 2015 06:01:08 GMT'),
@@ -230,7 +156,7 @@ def file(service)
230
156
  copy_status_description: nil,
231
157
  accept_ranges: 0,
232
158
  service: service,
233
- collection: Fog::Storage::AzureRM::Files.new(service: @service, directory: directory(service))
159
+ collection: Fog::AzureRM::Storage::Files.new(service: @service, directory: directory(service))
234
160
  )
235
161
  end
236
162
 
@@ -252,7 +178,7 @@ def storage_blob
252
178
  blob_type: 'PageBlob',
253
179
  copy_id: '095adc3b-e277-4c3d-97e0-0abca881f60c',
254
180
  copy_status: 'success',
255
- copy_source: 'https://sa.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A50.3157696Z',
181
+ copy_source: 'https://mockaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A50.3157696Z',
256
182
  copy_progress: '4194304/4194304',
257
183
  copy_completion_time: 'Thu, 04 Feb 2016 08:35:52 GMT',
258
184
  copy_status_description: nil,
@@ -266,581 +192,3 @@ def storage_blob
266
192
  }
267
193
  mock_blob
268
194
  end
269
-
270
- def public_ip(service)
271
- Fog::Network::AzureRM::PublicIp.new(
272
- name: 'fog-test-public-ip',
273
- resource_group: 'fog-test-rg',
274
- location: 'West US',
275
- public_ip_allocation_method: 'Dynamic',
276
- service: service
277
- )
278
- end
279
-
280
- def subnet(service)
281
- Fog::Network::AzureRM::Subnet.new(
282
- name: 'fog-test-subnet',
283
- resource_group: 'fog-test-rg',
284
- virtual_network_name: 'vnet1',
285
- address_prefix: '10.0.0.0/24',
286
- network_security_group_id: '/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/myNSG1',
287
- route_table_id: '/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/myRT1',
288
- service: service
289
- )
290
- end
291
-
292
- def virtual_network(service)
293
- Fog::Network::AzureRM::VirtualNetwork.new(
294
- name: 'fog-test-virtual-network',
295
- location: 'westus',
296
- resource_group: 'fog-test-rg',
297
- subnets: [{
298
- name: 'fog-test-subnet',
299
- address_prefix: '10.1.0.0/24',
300
- network_security_group_id: '/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/myNSG1',
301
- route_table_id: '/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/myRT1'
302
- }],
303
- dns_servers: ['10.1.0.0', '10.2.0.0'],
304
- address_prefixes: ['10.1.0.0/16', '10.2.0.0/16'],
305
- service: service
306
- )
307
- end
308
-
309
- def network_interface(service)
310
- Fog::Network::AzureRM::NetworkInterface.new(
311
- name: 'fog-test-network-interface',
312
- location: 'West US',
313
- resource_group: 'fog-test-rg',
314
- subnet_id: '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/virtualNetworks/fog-test-virtual-network/subnets/fog-test-subnet',
315
- public_ip_address_id: '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/publicIPAddresses/fog-test-public-ip',
316
- network_security_group_id: '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/networkSecurityGroups/fog-test-nsg',
317
- ip_configuration_name: 'fog-test-ip-configuration',
318
- private_ip_allocation_method: 'fog-test-private-ip-allocation-method',
319
- properties: nil,
320
- service: service
321
- )
322
- end
323
-
324
- def load_balancer(service)
325
- Fog::Network::AzureRM::LoadBalancer.new(
326
- name: 'lb',
327
- resource_group: 'fogRM-rg',
328
- location: 'westus',
329
- frontend_ip_configurations:
330
- [
331
- {
332
- name: 'fic',
333
- private_ipallocation_method: 'Dynamic',
334
- public_ipaddress_id: '/subscriptions/########-####-####-####-############/resourcegroups/fogRM-rg/providers/Microsoft.Network/publicIPAddresses/pip',
335
- subnet_id: '/subscriptions/########-####-####-####-############/resourcegroups/fogRM-rg/providers/Microsoft.Network/virtualNetworks/vnet/subnets/sb1'
336
- }
337
- ],
338
- backend_address_pool_names:
339
- [
340
- 'pool1'
341
- ],
342
- load_balancing_rules:
343
- [
344
- {
345
- name: 'lb_rule_1',
346
- frontend_ip_configuration_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fic',
347
- backend_address_pool_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/pool1',
348
- protocol: 'Tcp',
349
- frontend_port: '80',
350
- backend_port: '8080',
351
- enable_floating_ip: false,
352
- idle_timeout_in_minutes: 4,
353
- load_distribution: 'Default'
354
- }
355
- ],
356
- inbound_nat_rules:
357
- [
358
- {
359
- name: 'RDP-Traffic',
360
- frontend_ip_configuration_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fic',
361
- protocol: 'Tcp',
362
- frontend_port: 3389,
363
- backend_port: 3389
364
- }
365
- ],
366
- probes:
367
- [
368
- {
369
- name: 'probe1',
370
- protocol: 'Tcp',
371
- port: 8080,
372
- request_path: 'myprobeapp1/myprobe1.svc',
373
- interval_in_seconds: 5,
374
- number_of_probes: 16
375
- }
376
- ],
377
- inbound_nat_pools:
378
- [
379
- {
380
- name: 'RDPForVMSS1',
381
- protocol: 'Tcp',
382
- frontend_port_range_start: 500,
383
- frontend_port_range_end: 505,
384
- backend_port: 3389
385
- }
386
- ],
387
- service: service
388
- )
389
- end
390
-
391
- def zone(service)
392
- Fog::DNS::AzureRM::Zone.new(
393
- name: 'fog-test-zone.com',
394
- location: 'global',
395
- id: '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/dnszones/fog-test-zone.com',
396
- resource_group: 'fog-test-rg',
397
- service: service
398
- )
399
- end
400
-
401
- def record_set(service)
402
- Fog::DNS::AzureRM::RecordSet.new(
403
- name: 'fog-test-record_set',
404
- resource_group: 'fog-test-rg',
405
- zone_name: 'fog-test-zone.com',
406
- records: %w(1.2.3.4 1.2.3.3),
407
- type: 'A',
408
- ttl: 60,
409
- service: service
410
- )
411
- end
412
-
413
- def record_set_cname(service)
414
- Fog::DNS::AzureRM::RecordSet.new(
415
- name: 'fog-test-record_set',
416
- resource_group: 'fog-test-rg',
417
- zone_name: 'fog-test-zone.com',
418
- records: %w(1.2.3.4 1.2.3.3),
419
- type: 'CNAME',
420
- ttl: 60,
421
- service: service
422
- )
423
- end
424
-
425
- def network_security_group(service)
426
- Fog::Network::AzureRM::NetworkSecurityGroup.new(
427
- name: 'fog-test-nsg',
428
- resource_group: 'fog-test-rg',
429
- location: 'West US',
430
- security_rules: [{
431
- name: 'fog-test-rule',
432
- protocol: 'tcp',
433
- source_port_range: '22',
434
- destination_port_range: '22',
435
- source_address_prefix: '0.0.0.0/0',
436
- destination_address_prefix: '0.0.0.0/0',
437
- access: 'Allow',
438
- priority: '100',
439
- direction: 'Inbound'
440
- }],
441
- service: service
442
- )
443
- end
444
-
445
- def network_security_rule(service)
446
- Fog::Network::AzureRM::NetworkSecurityRule.new(
447
- name: 'fog-test-nsr',
448
- resource_group: 'fog-test-rg',
449
- network_security_group_name: 'fog-test-nsr',
450
- protocol: 'tcp',
451
- source_port_range: '22',
452
- destination_port_range: '22',
453
- source_address_prefix: '0.0.0.0/0',
454
- destination_address_prefix: '0.0.0.0/0',
455
- access: 'Allow',
456
- priority: '100',
457
- direction: 'Inbound',
458
- service: service
459
- )
460
- end
461
-
462
- def gateway(service)
463
- Fog::ApplicationGateway::AzureRM::Gateway.new(
464
- name: 'gateway',
465
- location: 'eastus',
466
- resource_group: 'fogRM-rg',
467
- sku_name: 'Standard_Medium',
468
- sku_tier: 'Standard',
469
- sku_capacity: '2',
470
- gateway_ip_configurations:
471
- [
472
- {
473
- name: 'gatewayIpConfigName',
474
- subnet_id: '/subscriptions/########-####-####-####-############/resourcegroups/fogRM-rg/providers/Microsoft.Network/virtualNetworks/vnet/subnets/subnetName'
475
- }
476
- ],
477
- ssl_certificates:
478
- [
479
- {
480
- name: 'certificate',
481
- data: 'data',
482
- password: '123',
483
- public_cert_data: 'MIIDiDCCAnACCQCwYkR0Mxy+QTANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wHhcNMTYwMzAyMTE0NTM2WhcNMTcwMzAyMTE0NTM2WjCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCuJrPbvOG+4oXQRamkOALlpdK98m+atJue9zOcCCagY8IJI4quYL13d8VItmrZf7erA+siqpYlWEuk1+lmmUY7T4AWAL8mXeR2vc7hWF601WDUjeVPK19+IcC8emMLOlBpvjXC9nbvADLQuR0PGitfjCqFoG66EOqJmLDNBsyHWmy+qhb8J4WXitruNAJDPe/20h6L23vD6z4tvwBjh4zkrfskGlKCNcAuvG1NI0FAS8261Jvs3lf+8oFyI+oSXGtknrkeQv3PbXyeEe3KO5a/M61Uebo04Uwd4yCvdu6H0sF+YYA4bfFdanuFmrZvf9cZSwknQid+vOdzyGkTHTPFAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAKtPhYpfvn5OxP+BcChsWaQA4KZQj0THGdiAjHsvfjsgteFvhkzqZBkhKYtsAWV5tB5/GDl+o4c6PQJ2/TXhOJn3pSNaUzrCJIGtKS5DknbqTQxCwVlxyBtPHLAYWqKcPMlH282rw3VY0OYTL96XOgZ/WZjcN6A7ku+uWsNCql443FoWL+N3Gpaab45OyIluFUOH+yc0ToHNlP3iOpI3rVpi2xwmGrSyUKsGUma3nrBq7TWjkDE1E+oJoybaMNZzgXGIPSJC1HYIF1U8GSoFkZpAFxXecD0FinXWDRwUP6K54iti3i6a/Ox73WhwfI4mVCqsOy1WYWtKYhMVe6Kj4Nw='
484
- }
485
- ],
486
- frontend_ip_configurations:
487
- [
488
- {
489
- name: 'frontendIpConfig',
490
- private_ip_allocation_method: 'Dynamic',
491
- public_ip_address_id: '/subscriptions/########-####-####-####-############/resourcegroups/fogRM-rg/providers/Microsoft.Network/publicIPAddresses/publicIp',
492
- private_ip_address: '10.0.1.5'
493
- }
494
- ],
495
- frontend_ports:
496
- [
497
- {
498
- name: 'frontendPort',
499
- port: 443
500
- }
501
- ],
502
- probes:
503
- [
504
- {
505
- name: 'probe1',
506
- protocol: 'tcp',
507
- host: 'localhost',
508
- path: '/usr/',
509
- interval: 30,
510
- timeout: 20,
511
- unhealthy_threshold: 20
512
- }
513
- ],
514
- backend_address_pools:
515
- [
516
- {
517
- name: 'backendAddressPool',
518
- ip_addresses: [
519
- {
520
- ipAddress: '10.0.1.6'
521
- }
522
- ]
523
- }
524
- ],
525
- backend_http_settings_list:
526
- [
527
- {
528
- name: 'gateway_settings',
529
- port: 80,
530
- protocol: 'Http',
531
- cookie_based_affinity: 'Enabled',
532
- request_timeout: '30',
533
- probe: ''
534
- }
535
- ],
536
- http_listeners:
537
- [
538
- {
539
- name: 'gateway_listener',
540
- frontend_ip_config_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/frontendIPConfigurations/frontend_ip_config',
541
- frontend_port_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/frontendPorts/gateway_front_port',
542
- protocol: 'Https',
543
- host_name: '',
544
- ssl_certificate_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/sslCertificates/ssl_certificate',
545
- require_server_name_indication: 'false'
546
- }
547
- ],
548
- url_path_maps:
549
- [
550
- {
551
- name: 'map1',
552
- default_backend_address_pool_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool',
553
- default_backend_http_settings_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings',
554
- path_rules: [
555
- {
556
- backend_address_pool_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool',
557
- backend_http_settings_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings',
558
- paths: [
559
- %w(/usr /etc)
560
- ]
561
- }
562
- ]
563
- }
564
- ],
565
- request_routing_rules:
566
- [
567
- {
568
- name: 'gateway_request_route_rule',
569
- type: 'Basic',
570
- http_listener_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/httpListeners/gateway_listener',
571
- backend_address_pool_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool',
572
- backend_http_settings_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings',
573
- url_path_map: ''
574
- }
575
- ],
576
- service: service
577
- )
578
- end
579
-
580
- def traffic_manager_end_point(service)
581
- Fog::TrafficManager::AzureRM::TrafficManagerEndPoint.new(
582
- name: 'fog-test-end-point',
583
- traffic_manager_profile_name: 'fog-test-profile',
584
- resource_group: 'fog-test-rg',
585
- type: 'external',
586
- target: 'test.com',
587
- endpoint_location: 'West US',
588
- service: service
589
- )
590
- end
591
-
592
- def traffic_manager_profile(service)
593
- Fog::TrafficManager::AzureRM::TrafficManagerProfile.new(
594
- name: 'fog-test-profile',
595
- resource_group: 'fog-test-rg',
596
- traffic_routing_method: 'Performance',
597
- relative_name: 'fog-test-app',
598
- ttl: '30',
599
- protocol: 'http',
600
- port: '80',
601
- path: '/monitorpage.aspx',
602
- service: service
603
- )
604
- end
605
-
606
- def virtual_network_gateway(service)
607
- Fog::Network::AzureRM::VirtualNetworkGateway.new(
608
- name: 'testNetworkGateway',
609
- location: 'eastus',
610
- tags: {
611
- key1: 'value1',
612
- key2: 'value2'
613
- },
614
- resource_group: 'learn_fog',
615
- sku_name: 'HighPerformance',
616
- sku_tier: 'Standard',
617
- sku_capacity: 100,
618
- gateway_type: 'ExpressRoute',
619
- enable_bgp: true,
620
- gateway_size: 'Default',
621
- vpn_client_address_pool: ['vpnClientAddressPoolPrefix'],
622
- default_sites: ['mysite1'],
623
- gateway_default_site: '/subscriptions/{subscription-id}/resourceGroups/fog-rg/providers/microsoft.network/localNetworkGateways/{local-network-gateway-name}',
624
- service: service
625
- )
626
- end
627
-
628
- def local_network_gateway(service)
629
- Fog::Network::AzureRM::LocalNetworkGateway.new(
630
- name: 'testLocalNetworkGateway',
631
- location: 'eastus',
632
- tags: {
633
- key1: 'value1',
634
- key2: 'value2'
635
- },
636
- resource_group: 'learn_fog',
637
- gateway_ip_address: '192.168.1.1',
638
- local_network_address_space_prefixes: [],
639
- asn: 100,
640
- bgp_peering_address: '192.168.1.2',
641
- peer_weight: 3,
642
- service: service
643
- )
644
- end
645
-
646
- def express_route_circuit(service)
647
- Fog::Network::AzureRM::ExpressRouteCircuit.new(
648
- name: 'testCircuit',
649
- location: 'eastus',
650
- resource_group: 'HaiderRG',
651
- tags: {
652
- key1: 'value1'
653
- },
654
- sku_name: 'Standard_MeteredData',
655
- sku_tier: 'Standard',
656
- sku_family: 'MeteredData',
657
- service_provider_name: 'Telenor',
658
- peering_location: 'London',
659
- bandwidth_in_mbps: 100,
660
- peerings: [
661
- {
662
- name: 'AzurePublicPeering',
663
- peering_type: 'AzurePublicPeering',
664
- peer_asn: 100,
665
- primary_peer_address_prefix: '192.168.1.0/30',
666
- secondary_peer_address_prefix: '192.168.2.0/30',
667
- vlan_id: 200
668
- }
669
- ],
670
- service: service
671
- )
672
- end
673
-
674
- def express_route_circuit_peering(service)
675
- Fog::Network::AzureRM::ExpressRouteCircuitPeering.new(
676
- name: 'AzurePublicPeering',
677
- circuit_name: 'testCircuit',
678
- resource_group: 'HaiderRG',
679
- peering_type: 'AzurePublicPeering',
680
- peer_asn: 100,
681
- primary_peer_address_prefix: '192.168.1.0/30',
682
- secondary_peer_address_prefix: '192.168.2.0/30',
683
- vlan_id: 200,
684
- service: service
685
- )
686
- end
687
-
688
- def express_route_circuit_authorization(service)
689
- Fog::Network::AzureRM::ExpressRouteCircuitAuthorization.new(
690
- name: 'UniqueAuthorizationName',
691
- circuit_name: 'testCircuit',
692
- resource_group: 'HaiderRG',
693
- authorization_use_status: 'Available',
694
- authorization_name: 'circuit-auth-name',
695
- service: service
696
- )
697
- end
698
-
699
- def virtual_network_gateway_connection(service)
700
- Fog::Network::AzureRM::VirtualNetworkGatewayConnection.new(
701
- name: 'testNetworkGateway',
702
- location: 'eastus',
703
- tags: {
704
- key1: 'value1',
705
- key2: 'value2'
706
- },
707
- resource_group: 'learn_fog',
708
- virtual_network_gateway1: {
709
- name: 'firstgateway'
710
- },
711
- virtual_network_gateway2: {
712
- name: 'secondgateway'
713
- },
714
- enable_bgp: true,
715
- connection_type: 'VNet-to-VNet',
716
- routing_weight: 2,
717
- shared_key: 'shared_key',
718
- service: service
719
- )
720
- end
721
-
722
- def database(service)
723
- Fog::Sql::AzureRM::SqlDatabase.new(
724
- name: 'fog-test-zone.com',
725
- id: '/subscriptions/########-####-####-####-############/resourceGroups/vm_custom_image/providers/Microsoft.Sql/servers/test-sql-server-confiz123/databases/confiztestdatab98',
726
- resource_group: 'fog-test-rg',
727
- server_name: 'fog-test-server-name',
728
- location: 'eastus',
729
- service: service
730
- )
731
- end
732
-
733
- def databases(service)
734
- Fog::Sql::AzureRM::SqlDatabases.new(
735
- resource_group: 'fog-test-rg',
736
- server_name: 'fog-test-server-name',
737
- name: 'database-name',
738
- location: 'eastus',
739
- service: service
740
- )
741
- end
742
-
743
- def sql_server(service)
744
- Fog::Sql::AzureRM::SqlServer.new(
745
- name: 'fog-test-zone.com',
746
- id: '/subscriptions/########-####-####-####-############/resourceGroups/vm_custom_image/providers/Microsoft.Sql/servers/test-sql-server-confiz123',
747
- resource_group: 'fog-test-rg',
748
- location: 'eastus',
749
- version: '2.0',
750
- administrator_login: 'test-admin@3',
751
- administrator_login_password: 'pass@swe',
752
- service: service
753
- )
754
- end
755
-
756
- def sql_servers(service)
757
- Fog::Sql::AzureRM::SqlServers.new(
758
- name: 'fog-test-zone.com',
759
- id: '/subscriptions/########-####-####-####-############/resourceGroups/vm_custom_image/providers/Microsoft.Sql/servers/test-sql-server-confiz123',
760
- resource_group: 'fog-test-rg',
761
- location: 'eastus',
762
- version: '2.0',
763
- administrator_login: 'test-admin@3',
764
- administrator_login_password: 'pass@swe',
765
- service: service
766
- )
767
- end
768
-
769
- def sql_server_firewall_rule(service)
770
- Fog::Sql::AzureRM::FirewallRule.new(
771
- name: 'fog-test-firewall-rule-name',
772
- id: '/subscriptions/########-####-####-####-############/resourceGroups/vm_custom_image/providers/Microsoft.Sql/servers/test-sql-server-confiz123/firewallRules/rule-name',
773
- resource_group: 'fog-test-rg',
774
- server_name: 'server-name',
775
- start_ip: '10.10.10.10',
776
- end_ip: '10.10.10.10',
777
- service: service
778
- )
779
- end
780
-
781
- def sql_server_firewall_rules(service)
782
- Fog::Sql::AzureRM::FirewallRules.new(
783
- name: 'fog-test-firewall-rule-name',
784
- id: '/subscriptions/########-####-####-####-############/resourceGroups/vm_custom_image/providers/Microsoft.Sql/servers/test-sql-server-confiz123/firewallRules/rule-name',
785
- resource_group: 'fog-test-rg',
786
- server_name: 'server-name',
787
- start_ip: '10.10.10.10',
788
- end_ip: '10.10.10.10',
789
- service: service
790
- )
791
- end
792
-
793
- def managed_disk(service)
794
- Fog::Compute::AzureRM::ManagedDisk.new(
795
- name: 'managed-disk',
796
- location: 'East US',
797
- resource_group_name: 'fog-test-rg',
798
- account_type: 'Premium_LRS',
799
- disk_size_gb: 1023,
800
- creation_data: {
801
- create_option: 'Empty'
802
- },
803
- service: service
804
- )
805
- end
806
-
807
- def snapshot(service)
808
- Fog::Compute::AzureRM::Snapshot.new(
809
- name: 'snapshot',
810
- location: 'East US',
811
- resource_group_name: 'fog-test-rg',
812
- account_type: 'Premium_LRS',
813
- disk_size_gb: 1023,
814
- creation_data: {
815
- create_option: 'Copy',
816
- source_uri: 'source uri on azure'
817
- },
818
- service: service
819
- )
820
- end
821
-
822
- def key_vault(service)
823
- Fog::KeyVault::AzureRM::Vault.new(
824
- name: 'key-vault',
825
- location: 'East US',
826
- resource_group_name: 'fog-test-rg',
827
- sku_family: 'A',
828
- sku_name: 'Standard',
829
- access_policies: [
830
- {
831
- tenant_id: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
832
- object_id: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
833
- permissions: {
834
- keys: ['all'],
835
- secrets: ['all']
836
- }
837
- }
838
- ],
839
- service: service
840
- )
841
- end
842
-
843
- def create_mock_response
844
- response_headers = { 'status' => HTTP_NOT_FOUND }
845
- Faraday::Response.new(response_headers)
846
- end