azure 0.6.4 → 0.7.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.env_sample +11 -0
  3. data/.gitignore +4 -1
  4. data/.travis.yml +3 -1
  5. data/ChangeLog.txt +17 -1
  6. data/LICENSE.txt +202 -0
  7. data/README.md +58 -20
  8. data/Rakefile +27 -35
  9. data/azure.gemspec +17 -13
  10. data/bin/pfxer +35 -0
  11. data/lib/azure.rb +8 -0
  12. data/lib/azure/base_management/base_management_service.rb +24 -26
  13. data/lib/azure/base_management/management_http_request.rb +17 -14
  14. data/lib/azure/base_management/serialization.rb +1 -0
  15. data/lib/azure/blob/auth/shared_access_signature.rb +141 -0
  16. data/lib/azure/blob/blob_service.rb +221 -217
  17. data/lib/azure/cloud_service_management/cloud_service_management_service.rb +27 -30
  18. data/lib/azure/cloud_service_management/serialization.rb +1 -0
  19. data/lib/azure/core.rb +17 -15
  20. data/lib/azure/core/configuration.rb +7 -0
  21. data/lib/azure/core/http/http_error.rb +1 -1
  22. data/lib/azure/core/http/http_request.rb +4 -1
  23. data/lib/azure/core/utility.rb +16 -1
  24. data/lib/azure/queue/queue_service.rb +13 -13
  25. data/lib/azure/service/cors.rb +11 -0
  26. data/lib/azure/service/cors_rule.rb +15 -0
  27. data/lib/azure/service/serialization.rb +69 -10
  28. data/lib/azure/service/storage_service.rb +10 -6
  29. data/lib/azure/service/storage_service_properties.rb +8 -3
  30. data/lib/azure/service_bus/brokered_message.rb +1 -1
  31. data/lib/azure/service_bus/relay.rb +88 -0
  32. data/lib/azure/service_bus/serialization.rb +1 -0
  33. data/lib/azure/service_bus/service_bus_service.rb +70 -4
  34. data/lib/azure/sql_database_management/serialization.rb +1 -0
  35. data/lib/azure/sql_database_management/sql_database_management_service.rb +22 -22
  36. data/lib/azure/storage_management/serialization.rb +34 -14
  37. data/lib/azure/storage_management/storage_account.rb +9 -1
  38. data/lib/azure/storage_management/storage_management_service.rb +74 -32
  39. data/lib/azure/table/batch.rb +6 -6
  40. data/lib/azure/table/table_service.rb +13 -13
  41. data/lib/azure/version.rb +3 -3
  42. data/lib/azure/virtual_machine_image_management/serialization.rb +19 -0
  43. data/lib/azure/virtual_machine_image_management/virtual_machine_image.rb +1 -1
  44. data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +30 -7
  45. data/lib/azure/virtual_machine_management/serialization.rb +32 -12
  46. data/lib/azure/virtual_machine_management/virtual_machine.rb +1 -0
  47. data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +92 -81
  48. data/lib/azure/virtual_network_management/serialization.rb +12 -5
  49. data/lib/azure/virtual_network_management/virtual_network.rb +1 -0
  50. data/lib/azure/virtual_network_management/virtual_network_management_service.rb +11 -11
  51. data/test/fixtures/get_storage_account_properties.xml +6 -4
  52. data/test/fixtures/{list_images.xml → list_os_images.xml} +1 -1
  53. data/test/fixtures/list_storage_accounts.xml +2 -0
  54. data/test/fixtures/list_vm_images.xml +21 -0
  55. data/test/fixtures/metrics.xml +2 -2
  56. data/test/fixtures/sb_default_create_relay_response.xml +15 -0
  57. data/test/fixtures/storage_service_keys.xml +8 -0
  58. data/test/fixtures/storage_service_properties.xml +35 -3
  59. data/test/fixtures/updated_storage_accounts.xml +2 -0
  60. data/test/fixtures/virtual_machine.xml +3 -1
  61. data/test/integration/affinity_group/Affinity_test.rb +1 -1
  62. data/test/integration/affinity_group/Create_Affinity_test.rb +8 -7
  63. data/test/integration/affinity_group/Delete_Affinity_test.rb +3 -3
  64. data/test/integration/affinity_group/List_Affinity_test.rb +1 -1
  65. data/test/integration/affinity_group/Update_Affinity_test.rb +9 -8
  66. data/test/integration/cloud_service/Cloud_Create_test.rb +3 -2
  67. data/test/integration/cloud_service/Cloud_Delete_test.rb +5 -4
  68. data/test/integration/database/create_sql_server_firewall_test.rb +1 -1
  69. data/test/integration/database/create_sql_server_test.rb +1 -1
  70. data/test/integration/database/delete_sql_server_firewall_test.rb +1 -1
  71. data/test/integration/database/delete_sql_server_test.rb +1 -1
  72. data/test/integration/database/list_sql_server_firewall_test.rb +1 -1
  73. data/test/integration/database/list_sql_servers_test.rb +1 -1
  74. data/test/integration/database/reset_password_sql_server_test.rb +1 -1
  75. data/test/integration/service_bus/queues_test.rb +22 -22
  76. data/test/integration/service_bus/relay_test.rb +132 -0
  77. data/test/integration/storage_management/storage_management_test.rb +58 -33
  78. data/test/integration/test_helper.rb +11 -15
  79. data/test/integration/vm/VM_Create_test.rb +17 -18
  80. data/test/integration/vm/VM_Delete_test.rb +2 -4
  81. data/test/integration/vm/VM_Operations_test.rb +1 -2
  82. data/test/integration/vnet/Virtual_Network_Create_test.rb +9 -15
  83. data/test/integration/vnet/Virtual_Network_list_test.rb +4 -9
  84. data/test/support/name_generator.rb +8 -0
  85. data/test/support/virtual_network_helper.rb +2 -2
  86. data/test/test_helper.rb +13 -24
  87. data/test/unit/affinity_group/affinity_group_test.rb +10 -13
  88. data/test/unit/affinity_group/serialization_test.rb +7 -8
  89. data/test/unit/base_management/location_test.rb +1 -2
  90. data/test/unit/blob/auth/shared_access_signature_test.rb +71 -0
  91. data/test/unit/blob/blob_service_test.rb +393 -371
  92. data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +16 -16
  93. data/test/unit/core/auth/shared_key_lite_test.rb +4 -4
  94. data/test/unit/core/auth/shared_key_test.rb +2 -2
  95. data/test/unit/core/http/http_error_test.rb +10 -5
  96. data/test/unit/core/http/http_request_test.rb +72 -25
  97. data/test/unit/database/serialization_test.rb +7 -7
  98. data/test/unit/database/sql_database_server_service_test.rb +43 -47
  99. data/test/unit/service/serialization_test.rb +40 -9
  100. data/test/unit/service/storage_service_test.rb +13 -11
  101. data/test/unit/storage_management/serialization_test.rb +26 -14
  102. data/test/unit/storage_management/storage_management_service_test.rb +48 -62
  103. data/test/unit/virtual_machine_image_management/serialization_test.rb +20 -5
  104. data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +78 -29
  105. data/test/unit/virtual_machine_management/serialization_test.rb +112 -43
  106. data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +123 -100
  107. data/test/unit/vnet/serialization_test.rb +7 -7
  108. data/test/unit/vnet/virtual_network_management_service_test.rb +1 -1
  109. metadata +70 -16
  110. data/test/fixtures/certificate.pem +0 -21
@@ -15,6 +15,7 @@
15
15
  require 'integration/test_helper'
16
16
 
17
17
  describe Azure::CloudServiceManagementService do
18
+ include Azure::Core::Utility
18
19
 
19
20
  subject { Azure::CloudServiceManagementService.new }
20
21
  let(:options) do
@@ -25,7 +26,7 @@ describe Azure::CloudServiceManagementService do
25
26
  end
26
27
 
27
28
  before do
28
- Loggerx.expects(:puts).returns(nil).at_least(0)
29
+ Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
29
30
  end
30
31
 
31
32
  describe '#create_cloud_service' do
@@ -34,7 +35,7 @@ describe Azure::CloudServiceManagementService do
34
35
  subject.create_cloud_service(@cloud_name, options)
35
36
  end
36
37
 
37
- it 'Creates a new cloud service in Windows Azure.' do
38
+ it 'Creates a new cloud service in Microsoft Azure.' do
38
39
  cloud_service = subject.get_cloud_service_properties(@cloud_name)
39
40
  assert cloud_service.name, @cloud_name
40
41
  assert cloud_service.location, options[:location]
@@ -15,6 +15,7 @@
15
15
  require 'integration/test_helper'
16
16
 
17
17
  describe Azure::CloudServiceManagementService do
18
+ include Azure::Core::Utility
18
19
 
19
20
  subject { Azure::CloudServiceManagementService.new }
20
21
 
@@ -26,7 +27,7 @@ describe Azure::CloudServiceManagementService do
26
27
  end
27
28
 
28
29
  before do
29
- Loggerx.expects(:puts).returns(nil).at_least(0)
30
+ Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
30
31
  end
31
32
 
32
33
  describe '#delete_cloud_service' do
@@ -35,10 +36,10 @@ describe Azure::CloudServiceManagementService do
35
36
  subject.create_cloud_service(@cloud_name, options)
36
37
  end
37
38
 
38
- it 'Deletes the cloud service in Windows Azure.' do
39
+ it 'Deletes the cloud service in Microsoft Azure.' do
39
40
  subject.delete_cloud_service(@cloud_name)
40
- present = subject.get_cloud_service(@cloud_name)
41
- assert_equal present, false
41
+ cloud_service = subject.get_cloud_service(@cloud_name)
42
+ cloud_service.must_equal nil
42
43
  end
43
44
  end
44
45
  end
@@ -23,7 +23,7 @@ describe Azure::SqlDatabaseManagementService do
23
23
  describe "#set_sql_server_firewall_rule" do
24
24
 
25
25
  before {
26
- Loggerx.expects(:puts).returns(nil).at_least(0)
26
+ Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
27
27
  }
28
28
 
29
29
  after {
@@ -21,7 +21,7 @@ describe Azure::SqlDatabaseManagementService do
21
21
  describe "#create_server" do
22
22
 
23
23
  before {
24
- Loggerx.expects(:puts).returns(nil).at_least(0)
24
+ Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
25
25
  }
26
26
 
27
27
  it "should be able to create a new sql database server." do
@@ -21,7 +21,7 @@ describe Azure::SqlDatabaseManagementService do
21
21
  subject { Azure::SqlDatabaseManagementService.new }
22
22
 
23
23
  before {
24
- Loggerx.expects(:puts).returns(nil).at_least(0)
24
+ Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
25
25
  subject.set_sql_server_firewall_rule(sql_server.name, "rule1")
26
26
  ip_range = {:start_ip_address => "10.20.30.0", :end_ip_address => "10.20.30.255"}
27
27
  subject.set_sql_server_firewall_rule(sql_server.name, "rule2", ip_range)
@@ -17,7 +17,7 @@ require "integration/test_helper"
17
17
  describe Azure::SqlDatabaseManagementService do
18
18
 
19
19
  before {
20
- Loggerx.expects(:puts).returns(nil).at_least(0)
20
+ Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
21
21
  }
22
22
 
23
23
  subject { Azure::SqlDatabaseManagementService.new }
@@ -22,7 +22,7 @@ describe Azure::SqlDatabaseManagementService do
22
22
  describe "#list_sql_server_firewall_rules" do
23
23
 
24
24
  before {
25
- Loggerx.expects(:puts).returns(nil).at_least(0)
25
+ Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
26
26
  ip_range = {:start_ip_address => "10.20.30.0", :end_ip_address => "10.20.30.255"}
27
27
  subject.set_sql_server_firewall_rule(sql_server.name, "rule1", ip_range)
28
28
  subject.set_sql_server_firewall_rule(sql_server.name, "rule2")
@@ -21,7 +21,7 @@ describe Azure::SqlDatabaseManagementService do
21
21
  describe "#list_servers" do
22
22
 
23
23
  before {
24
- Loggerx.expects(:puts).returns(nil).at_least(0)
24
+ Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
25
25
  }
26
26
 
27
27
  it "returns a list of SQL databse servers" do
@@ -23,7 +23,7 @@ describe Azure::SqlDatabaseManagementService do
23
23
  describe "#reset_password" do
24
24
 
25
25
  before {
26
- Loggerx.expects(:puts).returns(nil).at_least(0)
26
+ Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
27
27
  }
28
28
 
29
29
  after {
@@ -17,7 +17,7 @@ require "integration/test_helper"
17
17
  describe "ServiceBus Queues" do
18
18
 
19
19
  subject { Azure::ServiceBus::ServiceBusService.new }
20
- let(:name) { ServiceBusQueueNameHelper.name }
20
+ let(:queue_name) { ServiceBusQueueNameHelper.name }
21
21
  let(:name_alternative) { ServiceBusQueueNameHelper.name }
22
22
  let(:description) {{
23
23
  :default_message_time_to_live => 'P10675199DT2H48M5.4775807S',
@@ -44,15 +44,15 @@ describe "ServiceBus Queues" do
44
44
  after { ServiceBusQueueNameHelper.clean }
45
45
 
46
46
  it "should be able to create a new queue from a string" do
47
- queue = subject.create_queue name
47
+ queue = subject.create_queue queue_name
48
48
  queue.must_be_kind_of Azure::ServiceBus::Queue
49
- queue.name.must_equal name
49
+ queue.name.must_equal queue_name
50
50
  end
51
51
 
52
52
  it "should be able to create a new queue from a Queue" do
53
- queue = subject.create_queue Azure::ServiceBus::Queue.new(name)
53
+ queue = subject.create_queue Azure::ServiceBus::Queue.new(queue_name)
54
54
  queue.must_be_kind_of Azure::ServiceBus::Queue
55
- queue.name.must_equal name
55
+ queue.name.must_equal queue_name
56
56
  end
57
57
 
58
58
  it "should be able to create a new queue from a string and description Hash" do
@@ -88,7 +88,7 @@ describe "ServiceBus Queues" do
88
88
  end
89
89
 
90
90
  describe 'when a queue exists' do
91
- before { subject.create_queue name }
91
+ before { subject.create_queue queue_name }
92
92
 
93
93
  describe '#delete_queue' do
94
94
  it "should raise exception if the queue cannot be deleted" do
@@ -98,17 +98,17 @@ describe "ServiceBus Queues" do
98
98
  end
99
99
 
100
100
  it "should be able to delete the queue" do
101
- response = subject.delete_queue name
101
+ response = subject.delete_queue queue_name
102
102
  response.must_equal nil
103
103
  end
104
104
  end
105
105
 
106
106
  describe "#get_queue" do
107
107
  it "should be able to get a queue by name" do
108
- result = subject.get_queue name
108
+ result = subject.get_queue queue_name
109
109
 
110
110
  result.must_be_kind_of Azure::ServiceBus::Queue
111
- result.name.must_equal name
111
+ result.name.must_equal queue_name
112
112
  end
113
113
 
114
114
  it "if the queue doesn't exists it should throw" do
@@ -134,7 +134,7 @@ describe "ServiceBus Queues" do
134
134
  q1_found = false
135
135
  q2_found = false
136
136
  result.each { |q|
137
- q_found = true if q.name == name
137
+ q_found = true if q.name == queue_name
138
138
  q1_found = true if q.name == name1
139
139
  q2_found = true if q.name == name2
140
140
  }
@@ -168,7 +168,7 @@ describe "ServiceBus Queues" do
168
168
  msg = Azure::ServiceBus::BrokeredMessage.new("some text") do |m|
169
169
  m.to = "yo"
170
170
  end
171
- res = subject.send_queue_message name, msg
171
+ res = subject.send_queue_message queue_name, msg
172
172
  res.must_be_nil
173
173
  end
174
174
 
@@ -190,10 +190,10 @@ describe "ServiceBus Queues" do
190
190
  }}
191
191
  let(:msg) { m = Azure::ServiceBus::BrokeredMessage.new(messageContent, properties); m.to = 'me'; m }
192
192
 
193
- before { subject.send_queue_message name, msg }
193
+ before { subject.send_queue_message queue_name, msg }
194
194
 
195
195
  it "should be able to peek a message from a queue" do
196
- retrieved = subject.peek_lock_queue_message name
196
+ retrieved = subject.peek_lock_queue_message queue_name
197
197
  retrieved.must_be :kind_of?, Azure::ServiceBus::BrokeredMessage
198
198
 
199
199
  retrieved.body.must_equal msg.body
@@ -214,22 +214,22 @@ describe "ServiceBus Queues" do
214
214
  end
215
215
 
216
216
  it "should be able to read-delete a message from a queue" do
217
- retrieved = subject.read_delete_queue_message name
217
+ retrieved = subject.read_delete_queue_message queue_name
218
218
 
219
219
  retrieved.must_be :kind_of?, Azure::ServiceBus::BrokeredMessage
220
220
  retrieved.body.must_equal msg.body
221
221
  retrieved.to.must_equal msg.to
222
222
 
223
223
  # it should be deleted
224
- retrieved = subject.read_delete_queue_message name, { :timeout => 2 }
224
+ retrieved = subject.read_delete_queue_message queue_name, { :timeout => 2 }
225
225
  retrieved.must_be_nil
226
226
  end
227
227
 
228
228
  it "should be able to unlock a message from a queue" do
229
- retrieved = subject.peek_lock_queue_message name, { :timeout => 2 }
229
+ retrieved = subject.peek_lock_queue_message queue_name, { :timeout => 2 }
230
230
 
231
231
  # There shouldn't be an available message in the queue
232
- retrieved2 = subject.peek_lock_queue_message name, { :timeout => 2 }
232
+ retrieved2 = subject.peek_lock_queue_message queue_name, { :timeout => 2 }
233
233
  retrieved2.must_be_nil
234
234
 
235
235
  # Unlock the message
@@ -237,25 +237,25 @@ describe "ServiceBus Queues" do
237
237
  res.must_be_nil
238
238
 
239
239
  # The message should be available once again
240
- retrieved = subject.peek_lock_queue_message name, { :timeout => 2 }
240
+ retrieved = subject.peek_lock_queue_message queue_name, { :timeout => 2 }
241
241
  retrieved.body.must_equal msg.body
242
242
  end
243
243
 
244
244
  it "should be able to delete a message from a queue" do
245
245
 
246
- retrieved = subject.peek_lock_queue_message name
246
+ retrieved = subject.peek_lock_queue_message queue_name
247
247
  retrieved.body.must_equal msg.body
248
248
 
249
249
  subject.delete_queue_message retrieved
250
250
 
251
251
  # it should be deleted
252
- retrieved = subject.peek_lock_queue_message name, { :timeout => 2 }
252
+ retrieved = subject.peek_lock_queue_message queue_name, { :timeout => 2 }
253
253
  assert_nil retrieved
254
254
  end
255
255
 
256
256
  it "should be able to read a message from a queue" do
257
- subject.send_queue_message name, msg
258
- retrieved = subject.receive_queue_message name
257
+ subject.send_queue_message queue_name, msg
258
+ retrieved = subject.receive_queue_message queue_name
259
259
 
260
260
  retrieved.must_be :kind_of?, Azure::ServiceBus::BrokeredMessage
261
261
  retrieved.body.must_equal msg.body
@@ -0,0 +1,132 @@
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 "integration/test_helper"
16
+
17
+ describe "ServiceBus Relay" do
18
+
19
+ subject { Azure::ServiceBus::ServiceBusService.new }
20
+ let(:bus_name) { ServiceBusRelayNameHelper.name }
21
+ let(:name_alternative) { ServiceBusRelayNameHelper.name }
22
+ let(:description) {{
23
+ :relay_type => 'Http',
24
+ :requires_client_authorization => true,
25
+ :requires_transport_security => true
26
+ }}
27
+ let(:description_alternative) {{
28
+ :relay_type => 'NetTcp',
29
+ :requires_client_authorization => false,
30
+ :requires_transport_security => false
31
+ }}
32
+
33
+ after { ServiceBusRelayNameHelper.clean }
34
+
35
+ it "should be able to create a new relay endpoint from a string and description Hash" do
36
+ relay = subject.create_relay name_alternative, description_alternative
37
+ relay.must_be_kind_of Azure::ServiceBus::Relay
38
+ relay.name.must_equal name_alternative
39
+
40
+ relay.relay_type.must_equal description_alternative[:relay_type]
41
+ relay.requires_client_authorization.must_equal description_alternative[:requires_client_authorization]
42
+ relay.requires_transport_security.must_equal description_alternative[:requires_transport_security]
43
+ end
44
+
45
+ it "should be able to create a new relay from a Relay with a description Hash" do
46
+ relay = subject.create_relay Azure::ServiceBus::Relay.new(name_alternative, description_alternative)
47
+ relay.must_be_kind_of Azure::ServiceBus::Relay
48
+ relay.name.must_equal name_alternative
49
+
50
+ relay.relay_type.must_equal description_alternative[:relay_type]
51
+ relay.requires_client_authorization.must_equal description_alternative[:requires_client_authorization]
52
+ relay.requires_transport_security.must_equal description_alternative[:requires_transport_security]
53
+ end
54
+
55
+ describe 'when a relay exists' do
56
+ before { subject.create_relay bus_name, description }
57
+
58
+ describe "#get_relay" do
59
+ it "should be able to get a relay by name" do
60
+ result = subject.get_relay bus_name
61
+
62
+ result.must_be_kind_of Azure::ServiceBus::Relay
63
+ result.name.must_equal bus_name
64
+ end
65
+
66
+ it "if the relay endpoint doesn't exists it should throw" do
67
+ assert_raises(Azure::Core::Http::HTTPError) do
68
+ subject.get_relay ServiceBusRelayNameHelper.name
69
+ end
70
+ end
71
+ end
72
+
73
+ describe '#delete_relay' do
74
+ it "should raise exception if the relay endpoint cannot be deleted" do
75
+ assert_raises(Azure::Core::Http::HTTPError) do
76
+ subject.delete_relay ServiceBusRelayNameHelper.name
77
+ end
78
+ end
79
+
80
+ it "should be able to delete the relay endpoint" do
81
+ response = subject.delete_relay bus_name
82
+ response.must_equal nil
83
+ end
84
+ end
85
+
86
+ describe 'when there are multiple relay endpoints' do
87
+ let(:name1) { ServiceBusRelayNameHelper.name }
88
+ let(:name2) { ServiceBusRelayNameHelper.name }
89
+ before {
90
+ subject.create_relay name1, description
91
+ subject.create_relay name2, description_alternative
92
+ }
93
+
94
+ it "should be able to get a list of relays" do
95
+ result = subject.list_relays
96
+
97
+ result.must_be :kind_of?, Array
98
+ q_found = false
99
+ q1_found = false
100
+ q2_found = false
101
+ result.each { |q|
102
+ q_found = true if q.name == bus_name
103
+ q1_found = true if q.name == name1
104
+ q2_found = true if q.name == name2
105
+ }
106
+ assert (q_found and q1_found and q2_found), "list_relays did not return expected relay endpoints"
107
+ end
108
+
109
+ it "should be able to use $skip token with list_relays" do
110
+ result = subject.list_relays
111
+ result2 = subject.list_relays({ :skip => 1 })
112
+ result2.length.must_equal result.length - 1
113
+ result2[0].id.must_equal result[1].id
114
+ end
115
+
116
+ it "should be able to use $top token with list_relays" do
117
+ result = subject.list_relays
118
+ result.length.wont_equal 1
119
+
120
+ result2 = subject.list_relays({ :top => 1 })
121
+ result2.length.must_equal 1
122
+ end
123
+
124
+ it "should be able to use $skip and $top token together with list_relays" do
125
+ result = subject.list_relays
126
+ result2 = subject.list_relays({ :skip => 1, :top => 1 })
127
+ result2.length.must_equal 1
128
+ result2[0].id.must_equal result[1].id
129
+ end
130
+ end
131
+ end
132
+ end
@@ -15,14 +15,16 @@
15
15
  require 'integration/test_helper'
16
16
 
17
17
  describe Azure::StorageManagementService do
18
+
19
+ util = Class.new.extend(Azure::Core::Utility)
18
20
  subject { Azure::StorageManagementService.new }
19
- affinity_name = random_string('affinity-group-', 10)
21
+ affinity_name = util.random_string('affinity-group-', 10)
20
22
  Azure::BaseManagementService.new.create_affinity_group(
21
23
  affinity_name,
22
24
  'West US',
23
25
  'Label Name'
24
26
  )
25
- StorageName = random_string('storagetest', 10)
27
+ StorageName = util.random_string('storagetest', 10)
26
28
  opts = {
27
29
  affinity_group_name: affinity_name,
28
30
  label: 'storagelabel',
@@ -33,12 +35,11 @@ describe Azure::StorageManagementService do
33
35
 
34
36
  let(:affinity_group_name) { affinity_name }
35
37
  let(:storage_name) { Time.now.getutc.to_i.to_s }
36
- let(:location) { 'West US' }
37
38
  let(:label) { 'Label Name' }
38
39
  let(:options) { { description: 'sample description' } }
39
40
 
40
41
  before do
41
- Loggerx.expects(:puts).returns(nil).at_least(0)
42
+ Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
42
43
  end
43
44
 
44
45
  it 'list storage accounts' do
@@ -47,9 +48,9 @@ describe Azure::StorageManagementService do
47
48
  storagelist.must_be_kind_of Array
48
49
  end
49
50
 
50
- it 'get storage account' do
51
+ it 'get_storage_account return nil if storage account with given name not exists' do
51
52
  storage = subject.get_storage_account('nonexistentstorage')
52
- storage.must_equal false
53
+ storage.must_equal nil
53
54
  end
54
55
 
55
56
  it 'create storage account' do
@@ -60,18 +61,18 @@ describe Azure::StorageManagementService do
60
61
  geo_replication_enabled: 'false'
61
62
  }
62
63
  subject.create_storage_account(storage_name, options)
63
- present = subject.get_storage_account(storage_name)
64
- present.must_equal true
64
+ storage_account = subject.get_storage_account(storage_name)
65
+ storage_account.must_be_kind_of Azure::StorageManagement::StorageAccount
65
66
  # Test for delete storage account
66
67
  subject.delete_storage_account(storage_name)
67
- present = subject.get_storage_account(storage_name)
68
- present.must_equal false
68
+ storage_account = subject.get_storage_account(storage_name)
69
+ storage_account.must_equal nil
69
70
  end
70
71
 
71
72
  it 'get storage account' do
72
73
  storage_name = StorageName
73
- present = subject.get_storage_account(storage_name)
74
- present.must_equal true
74
+ storage_account = subject.get_storage_account(storage_name)
75
+ storage_account.must_be_kind_of Azure::StorageManagement::StorageAccount
75
76
  end
76
77
 
77
78
  it 'get storage account properties' do
@@ -79,20 +80,24 @@ describe Azure::StorageManagementService do
79
80
  storage = subject.get_storage_account_properties(storage_name)
80
81
  storage.name.must_equal storage_name
81
82
  storage.label.must_equal 'storagelabel'
82
- storage.geo_replication_enabled.must_equal 'true'
83
+ storage.account_type.must_equal 'Standard_GRS'
83
84
  end
84
85
 
85
- it 'update storage account' do
86
- options = {
87
- label: 'labelchanged',
88
- description: 'description changed'
89
- }
86
+ it 'regenerate storage account keys' do
90
87
  storage_name = StorageName
91
- subject.update_storage_account(storage_name, options)
92
- storage = subject.get_storage_account_properties(storage_name)
93
- storage.name.must_equal storage_name
94
- storage.label.must_equal 'labelchanged'
95
- subject.update_storage_account(storage_name, opts)
88
+ storage_keys1 = subject.regenerate_storage_account_keys(storage_name)
89
+ storage_keys1.primary_key.wont_be_nil
90
+ storage_keys1.secondary_key.wont_be_nil
91
+ storage_keys2 = subject.regenerate_storage_account_keys(storage_name, 'secondary')
92
+ storage_keys1.primary_key.must_equal storage_keys2.primary_key
93
+ storage_keys1.secondary_key.wont_equal storage_keys2.secondary_key
94
+ end
95
+
96
+ it 'get storage account keys' do
97
+ storage_name = StorageName
98
+ storage_keys1 = subject.get_storage_account_keys(storage_name)
99
+ storage_keys1.primary_key.wont_be_nil
100
+ storage_keys1.secondary_key.wont_be_nil
96
101
  end
97
102
 
98
103
  it 'get storage account properties error' do
@@ -143,18 +148,38 @@ describe Azure::StorageManagementService do
143
148
  assert_match('The affinity group does not exist.', exception.message)
144
149
  end
145
150
 
146
- it 'update storage account with non existent storage name' do
147
- options = {
148
- label: 'labelchanged',
149
- description: 'description changed'
150
- }
151
- storage_name = 'storage_nonexistent'
152
- storage = subject.update_storage_account(storage_name, options)
153
- assert_match(/Storage Account 'storage_nonexistent' does not exist. Skipped.../, storage)
154
- end
155
-
156
151
  it 'delete storage account that does not exist' do
157
152
  msg = subject.delete_storage_account('invalidstorageaccount')
158
153
  assert_match(/The storage account 'invalidstorageaccount' was not found./, msg)
159
154
  end
155
+
156
+ describe '#update_storage_account' do
157
+
158
+ it 'update storage account with non existent storage name' do
159
+ options = {
160
+ label: 'labelchanged',
161
+ description: 'description changed'
162
+ }
163
+ storage_name = 'storage_nonexistent'
164
+ storage = subject.update_storage_account(storage_name, options)
165
+ error_msg = "Storage Account 'storage_nonexistent' does not exist"
166
+ assert_match(/#{error_msg}/, storage)
167
+ end
168
+
169
+ it 'update existing storage account' do
170
+ options = {
171
+ label: 'labelchanged',
172
+ description: 'description changed',
173
+ account_type: 'Standard_LRS'
174
+ }
175
+ storage_name = StorageName
176
+ subject.update_storage_account(storage_name, options)
177
+ storage = subject.get_storage_account_properties(storage_name)
178
+ storage.name.must_equal storage_name
179
+ storage.label.must_equal 'labelchanged'
180
+ storage.account_type.must_equal 'Standard_LRS'
181
+ opts[:account_type] = 'Standard_GRS'
182
+ subject.update_storage_account(storage_name, opts)
183
+ end
184
+ end
160
185
  end