azure 0.7.1 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +31 -0
  3. data/azure.gemspec +2 -1
  4. data/lib/azure.rb +1 -0
  5. data/lib/azure/base_management/management_http_request.rb +3 -12
  6. data/lib/azure/blob/auth/shared_access_signature.rb +4 -0
  7. data/lib/azure/blob/blob_service.rb +2 -2
  8. data/lib/azure/client_services.rb +13 -13
  9. data/lib/azure/core/http/http_request.rb +3 -14
  10. data/lib/azure/core/service.rb +2 -1
  11. data/lib/azure/http_client.rb +1 -17
  12. data/lib/azure/http_response_helper.rb +38 -0
  13. data/lib/azure/sql_database_management/serialization.rb +4 -0
  14. data/lib/azure/sql_database_management/sql_database_management_service.rb +10 -9
  15. data/lib/azure/version.rb +1 -1
  16. data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +2 -2
  17. data/lib/azure/virtual_machine_management/serialization.rb +21 -12
  18. data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +8 -3
  19. metadata +17 -199
  20. data/test/fixtures/32px-fulls-black.jpg +0 -0
  21. data/test/fixtures/affinity_group.xml +0 -33
  22. data/test/fixtures/all_containers.xml +0 -20
  23. data/test/fixtures/all_tables.xml +0 -22
  24. data/test/fixtures/container_acl.xml +0 -11
  25. data/test/fixtures/create_sql_database_server.xml +0 -2
  26. data/test/fixtures/create_storage_desc_error.xml +0 -5
  27. data/test/fixtures/create_storage_extendedprop_error.xml +0 -8
  28. data/test/fixtures/create_storage_extendedpropname_error.xml +0 -6
  29. data/test/fixtures/create_storage_full_error.xml +0 -6
  30. data/test/fixtures/create_storage_label_error.xml +0 -5
  31. data/test/fixtures/create_storage_location_error.xml +0 -5
  32. data/test/fixtures/create_storage_name_error.xml +0 -6
  33. data/test/fixtures/create_table_response_entry.xml +0 -15
  34. data/test/fixtures/delete_storage_container_error.xml +0 -5
  35. data/test/fixtures/delete_storage_error.xml +0 -5
  36. data/test/fixtures/deployment_error.xml +0 -5
  37. data/test/fixtures/empty_xml_file +0 -0
  38. data/test/fixtures/get_storage_account_error.xml +0 -5
  39. data/test/fixtures/get_storage_account_properties.xml +0 -34
  40. data/test/fixtures/get_storage_account_properties_new.xml +0 -32
  41. data/test/fixtures/http_error.xml +0 -5
  42. data/test/fixtures/insert_entity_response_entry.xml +0 -25
  43. data/test/fixtures/list_affinity_groups.xml +0 -22
  44. data/test/fixtures/list_blobs.xml +0 -121
  45. data/test/fixtures/list_block_all_with_none_committed.xml +0 -22
  46. data/test/fixtures/list_blocks_all.xml +0 -23
  47. data/test/fixtures/list_blocks_committed.xml +0 -13
  48. data/test/fixtures/list_cloud_services.xml +0 -39
  49. data/test/fixtures/list_containers.xml +0 -38
  50. data/test/fixtures/list_firewall_management_endpoint.xml +0 -27
  51. data/test/fixtures/list_locations.xml +0 -212
  52. data/test/fixtures/list_os_images.xml +0 -110
  53. data/test/fixtures/list_page_ranges.xml +0 -11
  54. data/test/fixtures/list_sql_database.xml +0 -24
  55. data/test/fixtures/list_sql_server_firewall.xml +0 -23
  56. data/test/fixtures/list_storage_account_single.xml +0 -25
  57. data/test/fixtures/list_storage_accounts.xml +0 -48
  58. data/test/fixtures/list_virtual_networks.xml +0 -91
  59. data/test/fixtures/list_vm_images.xml +0 -21
  60. data/test/fixtures/logging.xml +0 -11
  61. data/test/fixtures/management_certificate.pem +0 -55
  62. data/test/fixtures/management_certificate.pfx +0 -0
  63. data/test/fixtures/management_certificate.publishsettings +0 -12
  64. data/test/fixtures/messages.xml +0 -12
  65. data/test/fixtures/metrics.xml +0 -10
  66. data/test/fixtures/privatekey.key +0 -28
  67. data/test/fixtures/query_entities_empty_response.xml +0 -7
  68. data/test/fixtures/query_entities_response.xml +0 -45
  69. data/test/fixtures/queue_service_properties.xml +0 -22
  70. data/test/fixtures/queue_service_properties_original.xml +0 -19
  71. data/test/fixtures/queues.xml +0 -16
  72. data/test/fixtures/retention_policy.xml +0 -5
  73. data/test/fixtures/sb_default_create_queue_response.xml +0 -23
  74. data/test/fixtures/sb_default_create_relay_response.xml +0 -15
  75. data/test/fixtures/sb_default_create_topic_response.xml +0 -18
  76. data/test/fixtures/sb_get_access_token_response.txt +0 -1
  77. data/test/fixtures/sb_queues_runtime_peek_message_response_headers.txt +0 -9
  78. data/test/fixtures/storage_service_keys.xml +0 -8
  79. data/test/fixtures/storage_service_properties.xml +0 -55
  80. data/test/fixtures/update_storage_account.xml +0 -16
  81. data/test/fixtures/update_storage_error.xml +0 -5
  82. data/test/fixtures/updated_storage_accounts.xml +0 -55
  83. data/test/fixtures/virtual_machine.xml +0 -116
  84. data/test/fixtures/windows_virtual_machine.xml +0 -106
  85. data/test/integration/affinity_group/Affinity_test.rb +0 -55
  86. data/test/integration/affinity_group/Create_Affinity_test.rb +0 -64
  87. data/test/integration/affinity_group/Delete_Affinity_test.rb +0 -56
  88. data/test/integration/affinity_group/List_Affinity_test.rb +0 -41
  89. data/test/integration/affinity_group/Update_Affinity_test.rb +0 -87
  90. data/test/integration/blob/blob_gb18030_test.rb +0 -199
  91. data/test/integration/blob/blob_metadata_test.rb +0 -75
  92. data/test/integration/blob/blob_pages_test.rb +0 -119
  93. data/test/integration/blob/blob_properties_test.rb +0 -77
  94. data/test/integration/blob/block_blob_test.rb +0 -303
  95. data/test/integration/blob/container/container_acl_test.rb +0 -69
  96. data/test/integration/blob/container/container_metadata_test.rb +0 -50
  97. data/test/integration/blob/container/create_container_test.rb +0 -60
  98. data/test/integration/blob/container/delete_container_test.rb +0 -39
  99. data/test/integration/blob/container/get_container_properties_test.rb +0 -48
  100. data/test/integration/blob/container/list_containers_test.rb +0 -79
  101. data/test/integration/blob/container/root_container_test.rb +0 -55
  102. data/test/integration/blob/copy_blob_test.rb +0 -113
  103. data/test/integration/blob/create_blob_snapshot_test.rb +0 -80
  104. data/test/integration/blob/create_page_blob_test.rb +0 -83
  105. data/test/integration/blob/delete_blob_test.rb +0 -159
  106. data/test/integration/blob/get_blob_test.rb +0 -65
  107. data/test/integration/blob/informative_errors_test.rb +0 -39
  108. data/test/integration/blob/lease/acquire_lease_test.rb +0 -36
  109. data/test/integration/blob/lease/break_lease_test.rb +0 -40
  110. data/test/integration/blob/lease/release_lease_test.rb +0 -40
  111. data/test/integration/blob/lease/renew_lease_test.rb +0 -42
  112. data/test/integration/blob/list_blobs_test.rb +0 -113
  113. data/test/integration/cloud_service/Cloud_Create_test.rb +0 -45
  114. data/test/integration/cloud_service/Cloud_Delete_test.rb +0 -45
  115. data/test/integration/database/create_sql_server_firewall_test.rb +0 -81
  116. data/test/integration/database/create_sql_server_test.rb +0 -53
  117. data/test/integration/database/delete_sql_server_firewall_test.rb +0 -63
  118. data/test/integration/database/delete_sql_server_test.rb +0 -44
  119. data/test/integration/database/list_sql_server_firewall_test.rb +0 -44
  120. data/test/integration/database/list_sql_servers_test.rb +0 -44
  121. data/test/integration/database/reset_password_sql_server_test.rb +0 -53
  122. data/test/integration/location/Location_List_test.rb +0 -38
  123. data/test/integration/location/RoleSize_List_test.rb +0 -34
  124. data/test/integration/queue/clear_messages_test.rb +0 -42
  125. data/test/integration/queue/create_message_test.rb +0 -75
  126. data/test/integration/queue/create_queue_test.rb +0 -50
  127. data/test/integration/queue/delete_message_test.rb +0 -67
  128. data/test/integration/queue/delete_queue_test.rb +0 -45
  129. data/test/integration/queue/informative_errors_test.rb +0 -42
  130. data/test/integration/queue/list_messages_encoded_test.rb +0 -79
  131. data/test/integration/queue/list_messages_test.rb +0 -79
  132. data/test/integration/queue/list_queues_test.rb +0 -43
  133. data/test/integration/queue/peek_messages_test.rb +0 -59
  134. data/test/integration/queue/queue_gb18030_test.rb +0 -131
  135. data/test/integration/queue/queue_metadata_test.rb +0 -40
  136. data/test/integration/queue/update_message_test.rb +0 -74
  137. data/test/integration/service_bus/informative_errors_test.rb +0 -37
  138. data/test/integration/service_bus/queues_scenario_test.rb +0 -200
  139. data/test/integration/service_bus/queues_test.rb +0 -266
  140. data/test/integration/service_bus/relay_test.rb +0 -132
  141. data/test/integration/service_bus/rules_test.rb +0 -145
  142. data/test/integration/service_bus/sb_queue_gb18030_test.rb +0 -182
  143. data/test/integration/service_bus/scenario_test.rb +0 -101
  144. data/test/integration/service_bus/subscriptions_test.rb +0 -211
  145. data/test/integration/service_bus/topics_scenario_test.rb +0 -406
  146. data/test/integration/service_bus/topics_test.rb +0 -129
  147. data/test/integration/storage_management/storage_management_test.rb +0 -185
  148. data/test/integration/table/create_table_test.rb +0 -36
  149. data/test/integration/table/delete_entity_batch_test.rb +0 -107
  150. data/test/integration/table/delete_entity_test.rb +0 -94
  151. data/test/integration/table/delete_table_test.rb +0 -40
  152. data/test/integration/table/get_table_test.rb +0 -37
  153. data/test/integration/table/informative_errors_test.rb +0 -39
  154. data/test/integration/table/insert_entity_batch_test.rb +0 -100
  155. data/test/integration/table/insert_entity_test.rb +0 -88
  156. data/test/integration/table/insert_or_merge_entity_batch_test.rb +0 -159
  157. data/test/integration/table/insert_or_merge_entity_test.rb +0 -143
  158. data/test/integration/table/insert_or_replace_entity_batch_test.rb +0 -152
  159. data/test/integration/table/insert_or_replace_entity_test.rb +0 -137
  160. data/test/integration/table/merge_entity_batch_test.rb +0 -128
  161. data/test/integration/table/merge_entity_test.rb +0 -113
  162. data/test/integration/table/query_entities_test.rb +0 -196
  163. data/test/integration/table/query_tables_test.rb +0 -43
  164. data/test/integration/table/query_test.rb +0 -251
  165. data/test/integration/table/table_acl_test.rb +0 -52
  166. data/test/integration/table/table_gb18030_test.rb +0 -355
  167. data/test/integration/table/update_entity_batch_test.rb +0 -149
  168. data/test/integration/table/update_entity_test.rb +0 -131
  169. data/test/integration/test_helper.rb +0 -40
  170. data/test/integration/vm/VM_Create_test.rb +0 -262
  171. data/test/integration/vm/VM_Delete_test.rb +0 -53
  172. data/test/integration/vm/VM_Operations_test.rb +0 -172
  173. data/test/integration/vm_image/virtual_machine_disk_test.rb +0 -37
  174. data/test/integration/vm_image/virtual_machine_image_test.rb +0 -37
  175. data/test/integration/vnet/Virtual_Network_Create_test.rb +0 -116
  176. data/test/integration/vnet/Virtual_Network_list_test.rb +0 -48
  177. data/test/support/env.rb +0 -19
  178. data/test/support/fixtures.rb +0 -36
  179. data/test/support/name_generator.rb +0 -168
  180. data/test/support/stubs.rb +0 -42
  181. data/test/support/virtual_machine_name_generator.rb +0 -102
  182. data/test/support/virtual_network_helper.rb +0 -73
  183. data/test/test_helper.rb +0 -47
  184. data/test/unit/affinity_group/affinity_group_test.rb +0 -189
  185. data/test/unit/affinity_group/serialization_test.rb +0 -87
  186. data/test/unit/base_management/base_management_service_test.rb +0 -19
  187. data/test/unit/base_management/location_test.rb +0 -56
  188. data/test/unit/base_management/role_size_test.rb +0 -50
  189. data/test/unit/blob/auth/shared_access_signature_test.rb +0 -71
  190. data/test/unit/blob/blob_service_test.rb +0 -1970
  191. data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +0 -94
  192. data/test/unit/cloud_service_management/serialization_test.rb +0 -169
  193. data/test/unit/config/azure_test.rb +0 -131
  194. data/test/unit/config/client_test.rb +0 -37
  195. data/test/unit/core/auth/shared_key_lite_test.rb +0 -51
  196. data/test/unit/core/auth/shared_key_test.rb +0 -58
  197. data/test/unit/core/auth/signer_test.rb +0 -30
  198. data/test/unit/core/http/http_error_test.rb +0 -61
  199. data/test/unit/core/http/http_request_test.rb +0 -138
  200. data/test/unit/core/http/http_response_test.rb +0 -20
  201. data/test/unit/core/http/retry_policy_test.rb +0 -23
  202. data/test/unit/core/utility_test.rb +0 -122
  203. data/test/unit/database/serialization_test.rb +0 -94
  204. data/test/unit/database/sql_database_server_service_test.rb +0 -341
  205. data/test/unit/http_client_test.rb +0 -74
  206. data/test/unit/service/serialization_test.rb +0 -533
  207. data/test/unit/service/storage_service_test.rb +0 -297
  208. data/test/unit/storage_management/serialization_test.rb +0 -244
  209. data/test/unit/storage_management/storage_management_service_test.rb +0 -247
  210. data/test/unit/table/edmtype_test.rb +0 -108
  211. data/test/unit/virtual_machine_image_management/serialization_test.rb +0 -50
  212. data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +0 -114
  213. data/test/unit/virtual_machine_management/serialization_test.rb +0 -316
  214. data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +0 -480
  215. data/test/unit/vnet/serialization_test.rb +0 -187
  216. data/test/unit/vnet/virtual_network_management_service_test.rb +0 -131
@@ -1,247 +0,0 @@
1
- #-------------------------------------------------------------------------
2
- # Copyright 2013 Microsoft Open Technologies, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #--------------------------------------------------------------------------
15
- require 'test_helper'
16
-
17
- describe Azure::StorageManagementService do
18
-
19
- subject { Azure::StorageManagementService.new }
20
- let(:request_path) { '/services/storageservices' }
21
- let(:storage_accounts_xml) { Fixtures['list_storage_accounts'] }
22
- let(:one_storage_account_xml) { Fixtures['list_storage_account_single'] }
23
- let(:verb) { :get }
24
- let(:mock_request) { mock() }
25
-
26
- let(:response) {
27
- response = mock()
28
- response.stubs(:body).returns(storage_accounts_xml)
29
- response
30
- }
31
-
32
- let(:single_response) {
33
- single_response = mock()
34
- single_response.stubs(:body).returns(one_storage_account_xml)
35
- single_response
36
- }
37
-
38
- let(:response_body) { Nokogiri::XML response.body }
39
- let(:single_response_body) { Nokogiri::XML single_response.body }
40
-
41
- before {
42
- Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
43
- }
44
-
45
- describe '#list_storage_accounts' do
46
- before {
47
- Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(verb, request_path, anything).returns(mock_request)
48
- mock_request.expects(:call).returns(response_body)
49
- }
50
-
51
- it 'assembles a URI for the request' do
52
- subject.list_storage_accounts
53
- end
54
-
55
- it 'sets the properties of the storage accounts' do
56
- storage_account = subject.list_storage_accounts.first
57
- storage_account.name.must_equal 'storage1'
58
- end
59
-
60
- it 'returns a list of storage accounts for the subscription' do
61
- results = subject.list_storage_accounts
62
- results.must_be_kind_of Array
63
- results.length.must_equal 2
64
- results.first.must_be_kind_of Azure::StorageManagement::StorageAccount
65
- end
66
- end
67
-
68
- describe '#list_storage_accounts_single' do
69
- before {
70
- Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(
71
- verb, request_path, anything
72
- ).returns(mock_request)
73
- mock_request.expects(:call).returns(single_response_body)
74
- }
75
-
76
- it 'returns an array even if single account exists' do
77
- results = subject.list_storage_accounts
78
- results.must_be_kind_of Array
79
- results.length.must_equal 1
80
- results.first.must_be_kind_of Azure::StorageManagement::StorageAccount
81
- results.first.name.must_equal 'storage1'
82
- end
83
- end
84
-
85
- describe '#get_storage_account' do
86
- before {
87
- Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(verb, request_path, anything).returns(mock_request)
88
- mock_request.expects(:call).returns(response_body)
89
- }
90
-
91
- it 'assembles a URI for the request' do
92
- subject.get_storage_account 'storage1'
93
- end
94
-
95
- it 'returns storage account instance' do
96
- storage_account_name = 'storage1'
97
- result = subject.get_storage_account storage_account_name
98
- result.must_be_kind_of Azure::StorageManagement::StorageAccount
99
- result.name.must_equal storage_account_name
100
- end
101
-
102
- it "returns false if storage account with given name doesn't exists" do
103
- result = subject.get_storage_account 'storage3'
104
- result.must_equal nil
105
- end
106
- end
107
-
108
- describe '#create_storage_account' do
109
- let(:options) {
110
- {
111
- location: 'East Asia',
112
- description: 'Test Storage Description'
113
- }
114
- }
115
-
116
- it 'Checks if name is provided' do
117
- exception = assert_raises(RuntimeError) do
118
- subject.create_storage_account(options)
119
- end
120
- assert_match('Name not specified', exception.message)
121
- end
122
-
123
- it 'Checks if name is not nil' do
124
- exception = assert_raises(RuntimeError) do
125
- subject.create_storage_account('', options)
126
- end
127
- assert_match('Name not specified', exception.message)
128
- end
129
-
130
- it 'Checks if name is not empty' do
131
- exception = assert_raises(RuntimeError) do
132
- subject.create_storage_account('', options)
133
- end
134
- assert_match('Name not specified', exception.message)
135
- end
136
-
137
- it 'Create storage account return message if storage account exists of given name.' do
138
- Azure::BaseManagement::ManagementHttpRequest.any_instance.expects(:call).returns response_body
139
- msg = subject.create_storage_account 'storage1'
140
- assert_match(/^Storage Account storage1 already exist.*/, msg)
141
- end
142
-
143
- it "Create storage account if storage account doesn't exists of given name." do
144
- Azure::StorageManagementService.any_instance.stubs(:get_storage_account).with('storage3').returns(false)
145
- Azure::BaseManagement::ManagementHttpRequest.any_instance.expects(:call).returns nil
146
- subject.create_storage_account 'storage3'
147
- end
148
-
149
- end
150
-
151
- describe '#update_storage_account' do
152
- let(:updated_accounts_xml) { Fixtures['updated_storage_accounts'] }
153
- let(:no_options_specified) { 'No options specified' }
154
- let(:sa_response) {
155
- res = mock()
156
- res.stubs(:body).returns(updated_accounts_xml)
157
- res
158
- Nokogiri::XML res.body
159
- }
160
-
161
- let(:update_request) {
162
- update_request = mock()
163
- update_request.stubs(:body).returns('')
164
- update_request
165
- }
166
-
167
- before {
168
- Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(verb, request_path, anything).returns(mock_request)
169
- mock_request.expects(:call).returns(response_body)
170
- }
171
-
172
- let(:options) { {
173
- description: 'Test Description',
174
- label: 'Test Label',
175
- geo_replication_enabled: false,
176
- extended_properties: {
177
- prop_1_name: 'prop_1_value',
178
- prop_2_name: 'prop_2_value'
179
- }
180
- }
181
- }
182
-
183
- it 'checks if empty options is provided' do
184
- exception = assert_raises RuntimeError do
185
- subject.update_storage_account 'storage2', Hash.new
186
- end
187
- assert_match no_options_specified, exception.message
188
- end
189
-
190
- it 'checks if account exists before updating' do
191
- ret_val = subject.update_storage_account 'storage3', Hash.new
192
- ret_val.must_equal "Storage Account 'storage3' does not exist. Skipped..."
193
- end
194
-
195
- it 'updates the specified account' do
196
- Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(
197
- :put,
198
- "#{request_path}/storage2",
199
- has_entries(body: Fixtures['update_storage_account'])
200
- ).returns(update_request)
201
- update_request.expects(:call)
202
- subject.update_storage_account 'storage2', options
203
- mock_request.expects(:call).returns(sa_response)
204
- storage_account = subject.list_storage_accounts.last
205
- storage_account.name.must_equal 'storage2'
206
- storage_account.label.must_equal options[:label]
207
- storage_account.geo_replication_enabled.must_equal "#{options[:geo_replication_enabled]}"
208
- storage_account.extended_properties.each { |prop|
209
- prop[:value].must_equal "#{options[:extended_properties][:"#{prop[:name]}"]}"
210
- }
211
- end
212
- end
213
-
214
- describe '#get_storage_account_properties' do
215
- let(:account_name) { 'storage2' }
216
- let(:label) { 'ValidLabel' }
217
- let(:request_path) { "/services/storageservices/#{account_name}" }
218
- let(:account_xml) { Fixtures['get_storage_account_properties'] }
219
-
220
- let(:get_account_mock_request) { mock() }
221
- let(:get_account_response) {
222
- get_account_response = mock()
223
- get_account_response.stubs(:body).returns(account_xml)
224
- get_account_response
225
- }
226
- let(:get_account_response_body) {
227
- Nokogiri::XML(get_account_response.body)
228
- }
229
-
230
- before {
231
- Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(
232
- :get, request_path, anything
233
- ).returns(get_account_mock_request)
234
- get_account_mock_request.expects(:call).returns(
235
- get_account_response_body
236
- )
237
- }
238
-
239
- it 'returns the label as a Base64 decoded string' do
240
- storage_account = subject.get_storage_account_properties(account_name)
241
- storage_account.label.must_be_kind_of(String)
242
- storage_account.label.must_equal(label)
243
- storage_account.account_type.must_equal 'Standard_GRS'
244
- storage_account.geo_primary_region.must_equal 'West US'
245
- end
246
- end
247
- end
@@ -1,108 +0,0 @@
1
- #-------------------------------------------------------------------------
2
- # # Copyright (c) Microsoft and contributors. All rights reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #--------------------------------------------------------------------------
15
- require "test_helper"
16
- require "azure/table/edmtype"
17
-
18
- require "azure/table/guid"
19
-
20
- describe Azure::Table::EdmType do
21
- describe "#serialize_query_value" do
22
- it "correctly serializes int64 query values" do
23
- value = 2**128 + 1256231
24
- serializedValue = Azure::Table::EdmType.serialize_query_value(value)
25
- serializedValue.must_equal value.to_s + "L"
26
- end
27
-
28
- it "correctly serializes int32 query values" do
29
- value = 2
30
- serializedValue = Azure::Table::EdmType.serialize_query_value(value)
31
- serializedValue.must_equal "2"
32
- end
33
-
34
- it "correctly serializes datetime query values" do
35
- value = DateTime.new(2001,2,3,4,5,6)
36
- serializedValue = Azure::Table::EdmType.serialize_query_value(value)
37
- serializedValue.must_equal "datetime'2001-02-03T04:05:06+00:00'"
38
- end
39
-
40
- it "correctly serializes guid query values" do
41
- value = Azure::Table::GUID.new("81425519-6394-43e4-ac6e-28d91f5c3921")
42
- serializedValue = Azure::Table::EdmType.serialize_query_value(value)
43
- serializedValue.must_equal "guid'81425519-6394-43e4-ac6e-28d91f5c3921'"
44
- end
45
-
46
- it "correctly serializes float query values" do
47
- value = 1.2
48
- serializedValue = Azure::Table::EdmType.serialize_query_value(value)
49
- serializedValue.must_equal "1.2"
50
- end
51
-
52
- it "correctly serializes string query values" do
53
- value = "string"
54
- serializedValue = Azure::Table::EdmType.serialize_query_value(value)
55
- serializedValue.must_equal "string"
56
- end
57
-
58
- it "correctly serializes binary query values" do
59
- value = "1".force_encoding("BINARY")
60
- serializedValue = Azure::Table::EdmType.serialize_query_value(value)
61
- serializedValue.must_equal "X'31'"
62
- end
63
- end
64
-
65
- describe "#unserialize_query_value" do
66
- it "correctly unserializes int64 query values" do
67
- value = "340282366920938463463374607431769467687"
68
- unserializedValue = Azure::Table::EdmType.unserialize_query_value(value, "Edm.Int64")
69
- unserializedValue.must_equal (2**128 + 1256231)
70
- end
71
-
72
- it "correctly unserializes int32 query values" do
73
- value = "2"
74
- unserializedValue = Azure::Table::EdmType.unserialize_query_value(value, "Edm.Int32")
75
- unserializedValue.must_equal 2
76
- end
77
-
78
- it "correctly unserializes datetime query values" do
79
- value = "2001-02-03T04:05:06+00:00"
80
- unserializedValue = Azure::Table::EdmType.unserialize_query_value(value, "Edm.DateTime")
81
- unserializedValue.must_equal Time.new(2001, 2, 3, 4, 5, 6, "+00:00")
82
- end
83
-
84
- it "correctly unserializes guid query values" do
85
- value = "81425519-6394-43e4-ac6e-28d91f5c3921"
86
- unserializedValue = Azure::Table::EdmType.unserialize_query_value(value, "Edm.Guid")
87
- unserializedValue.must_equal Azure::Table::GUID.new("81425519-6394-43e4-ac6e-28d91f5c3921")
88
- end
89
-
90
- it "correctly unserializes float query values" do
91
- value = "1.2"
92
- unserializedValue = Azure::Table::EdmType.unserialize_query_value(value, "Edm.Double")
93
- unserializedValue.must_equal 1.2
94
- end
95
-
96
- it "correctly unserializes string query values" do
97
- value = "string"
98
- unserializedValue = Azure::Table::EdmType.unserialize_query_value(value, "Edm.String")
99
- unserializedValue.must_equal "string"
100
- end
101
-
102
- it "correctly unserializes binary query values" do
103
- value = "MTIzNDU=".force_encoding("BINARY")
104
- unserializedValue = Azure::Table::EdmType.unserialize_query_value(value, "Edm.Binary")
105
- unserializedValue.must_equal "12345"
106
- end
107
- end
108
- end
@@ -1,50 +0,0 @@
1
- #-------------------------------------------------------------------------
2
- # Copyright 2013 Microsoft Open Technologies, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #--------------------------------------------------------------------------
15
- require 'test_helper'
16
-
17
- describe Azure::VirtualMachineImageManagement::Serialization do
18
- subject { Azure::VirtualMachineImageManagement::Serialization }
19
-
20
- describe '#virtual_machine_images_from_xml' do
21
- let(:os_images_xml) { Fixtures['list_os_images'] }
22
-
23
- it 'accepts an XML string' do
24
- subject.virtual_machine_images_from_xml Nokogiri::XML(os_images_xml)
25
- end
26
-
27
- it 'returns an Array of VirtualMachineImageService instances' do
28
- results = subject.virtual_machine_images_from_xml Nokogiri::XML(os_images_xml)
29
- results.must_be_kind_of Array
30
- results[0].must_be_kind_of VirtualMachineImage
31
- results.count.must_equal 12
32
- end
33
- end
34
-
35
- describe '#virtual_machine_vm_images_from_xml' do
36
- let(:vm_images_xml) { Fixtures['list_vm_images'] }
37
-
38
- it 'accepts an XML string' do
39
- subject.virtual_machine_vm_images_from_xml Nokogiri::XML(vm_images_xml)
40
- end
41
-
42
- it 'returns an Array of VirtualMachineImageService instances' do
43
- results = subject.virtual_machine_vm_images_from_xml Nokogiri::XML(vm_images_xml)
44
- results.must_be_kind_of Array
45
- results[0].must_be_kind_of VirtualMachineImage
46
- results.count.must_equal 1
47
- end
48
- end
49
-
50
- end
@@ -1,114 +0,0 @@
1
- #-------------------------------------------------------------------------
2
- # Copyright 2013 Microsoft Open Technologies, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #--------------------------------------------------------------------------
15
- require 'test_helper'
16
-
17
- describe Azure::VirtualMachineImageManagementService do
18
-
19
- subject { Azure::VirtualMachineImageManagementService.new }
20
-
21
- let(:os_image_request_path) { '/services/images' }
22
- let(:vm_image_request_path) { '/services/vmimages' }
23
- let(:os_images_xml) { Fixtures['list_os_images'] }
24
- let(:vm_images_xml) { Fixtures['list_vm_images'] }
25
- let(:verb) { :get }
26
- let(:os_images_response) do
27
- response = mock
28
- response.stubs(:body).returns(os_images_xml)
29
- Nokogiri::XML response.body
30
- end
31
- let(:vm_images_response) do
32
- response = mock
33
- response.stubs(:body).returns(vm_images_xml)
34
- Nokogiri::XML response.body
35
- end
36
-
37
- before {
38
- Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
39
- }
40
-
41
- describe '#list_os_images' do
42
- let(:verb) { :get }
43
- before do
44
- os_images_request = mock
45
- subject.client.stubs(:management_request).with(
46
- verb,
47
- os_image_request_path,
48
- nil
49
- ).returns(os_images_request)
50
- os_images_request.expects(:call).returns(os_images_response)
51
- end
52
-
53
- it 'returns a list of os images from server' do
54
- os_images = subject.list_os_images
55
- os_images.must_be_kind_of Array
56
- image_klass = VirtualMachineImage
57
- os_images.length.must_equal 12
58
- image = os_images.first
59
- image.must_be_kind_of image_klass
60
- image.image_type.must_equal 'OS'
61
- end
62
- end
63
-
64
- describe '#list_vm_images' do
65
- let(:verb) { :get }
66
- before do
67
- vm_images_request = mock
68
- subject.client.stubs(:management_request).with(
69
- verb,
70
- vm_image_request_path,
71
- nil
72
- ).returns(vm_images_request)
73
- vm_images_request.expects(:call).returns(vm_images_response)
74
- end
75
-
76
- it 'returns a list of vm images from server' do
77
- vm_images = subject.list_vm_images
78
- vm_images.must_be_kind_of Array
79
- vm_images.length.must_equal 1
80
- image_klass = VirtualMachineImage
81
- image = vm_images.first
82
- image.must_be_kind_of image_klass
83
- image.image_type.must_equal 'VM'
84
- end
85
- end
86
-
87
- describe '#list_images' do
88
- let(:verb) { :get }
89
- before do
90
- vm_images_request = mock
91
- subject.client.stubs(:management_request).with(
92
- verb,
93
- vm_image_request_path,
94
- nil
95
- ).returns(vm_images_request)
96
- vm_images_request.expects(:call).returns(vm_images_response)
97
- os_images_request = mock
98
- subject.client.stubs(:management_request).with(
99
- verb,
100
- os_image_request_path,
101
- nil
102
- ).returns(os_images_request)
103
- os_images_request.expects(:call).returns(os_images_response)
104
- end
105
-
106
- it 'returns a list of virtual machine images' do
107
- images = subject.list_virtual_machine_images
108
- images.must_be_kind_of Array
109
- images.length.must_equal 13
110
- images.last.image_type.must_equal 'VM'
111
- images.first.image_type.must_equal 'OS'
112
- end
113
- end
114
- end