gitlab-fog-azure-rm 1.7.0 → 1.9.0

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