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.
- checksums.yaml +4 -4
- data/.env_sample +11 -0
- data/.gitignore +4 -1
- data/.travis.yml +3 -1
- data/ChangeLog.txt +17 -1
- data/LICENSE.txt +202 -0
- data/README.md +58 -20
- data/Rakefile +27 -35
- data/azure.gemspec +17 -13
- data/bin/pfxer +35 -0
- data/lib/azure.rb +8 -0
- data/lib/azure/base_management/base_management_service.rb +24 -26
- data/lib/azure/base_management/management_http_request.rb +17 -14
- data/lib/azure/base_management/serialization.rb +1 -0
- data/lib/azure/blob/auth/shared_access_signature.rb +141 -0
- data/lib/azure/blob/blob_service.rb +221 -217
- data/lib/azure/cloud_service_management/cloud_service_management_service.rb +27 -30
- data/lib/azure/cloud_service_management/serialization.rb +1 -0
- data/lib/azure/core.rb +17 -15
- data/lib/azure/core/configuration.rb +7 -0
- data/lib/azure/core/http/http_error.rb +1 -1
- data/lib/azure/core/http/http_request.rb +4 -1
- data/lib/azure/core/utility.rb +16 -1
- data/lib/azure/queue/queue_service.rb +13 -13
- data/lib/azure/service/cors.rb +11 -0
- data/lib/azure/service/cors_rule.rb +15 -0
- data/lib/azure/service/serialization.rb +69 -10
- data/lib/azure/service/storage_service.rb +10 -6
- data/lib/azure/service/storage_service_properties.rb +8 -3
- data/lib/azure/service_bus/brokered_message.rb +1 -1
- data/lib/azure/service_bus/relay.rb +88 -0
- data/lib/azure/service_bus/serialization.rb +1 -0
- data/lib/azure/service_bus/service_bus_service.rb +70 -4
- data/lib/azure/sql_database_management/serialization.rb +1 -0
- data/lib/azure/sql_database_management/sql_database_management_service.rb +22 -22
- data/lib/azure/storage_management/serialization.rb +34 -14
- data/lib/azure/storage_management/storage_account.rb +9 -1
- data/lib/azure/storage_management/storage_management_service.rb +74 -32
- data/lib/azure/table/batch.rb +6 -6
- data/lib/azure/table/table_service.rb +13 -13
- data/lib/azure/version.rb +3 -3
- data/lib/azure/virtual_machine_image_management/serialization.rb +19 -0
- data/lib/azure/virtual_machine_image_management/virtual_machine_image.rb +1 -1
- data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +30 -7
- data/lib/azure/virtual_machine_management/serialization.rb +32 -12
- data/lib/azure/virtual_machine_management/virtual_machine.rb +1 -0
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +92 -81
- data/lib/azure/virtual_network_management/serialization.rb +12 -5
- data/lib/azure/virtual_network_management/virtual_network.rb +1 -0
- data/lib/azure/virtual_network_management/virtual_network_management_service.rb +11 -11
- data/test/fixtures/get_storage_account_properties.xml +6 -4
- data/test/fixtures/{list_images.xml → list_os_images.xml} +1 -1
- data/test/fixtures/list_storage_accounts.xml +2 -0
- data/test/fixtures/list_vm_images.xml +21 -0
- data/test/fixtures/metrics.xml +2 -2
- data/test/fixtures/sb_default_create_relay_response.xml +15 -0
- data/test/fixtures/storage_service_keys.xml +8 -0
- data/test/fixtures/storage_service_properties.xml +35 -3
- data/test/fixtures/updated_storage_accounts.xml +2 -0
- data/test/fixtures/virtual_machine.xml +3 -1
- data/test/integration/affinity_group/Affinity_test.rb +1 -1
- data/test/integration/affinity_group/Create_Affinity_test.rb +8 -7
- data/test/integration/affinity_group/Delete_Affinity_test.rb +3 -3
- data/test/integration/affinity_group/List_Affinity_test.rb +1 -1
- data/test/integration/affinity_group/Update_Affinity_test.rb +9 -8
- data/test/integration/cloud_service/Cloud_Create_test.rb +3 -2
- data/test/integration/cloud_service/Cloud_Delete_test.rb +5 -4
- data/test/integration/database/create_sql_server_firewall_test.rb +1 -1
- data/test/integration/database/create_sql_server_test.rb +1 -1
- data/test/integration/database/delete_sql_server_firewall_test.rb +1 -1
- data/test/integration/database/delete_sql_server_test.rb +1 -1
- data/test/integration/database/list_sql_server_firewall_test.rb +1 -1
- data/test/integration/database/list_sql_servers_test.rb +1 -1
- data/test/integration/database/reset_password_sql_server_test.rb +1 -1
- data/test/integration/service_bus/queues_test.rb +22 -22
- data/test/integration/service_bus/relay_test.rb +132 -0
- data/test/integration/storage_management/storage_management_test.rb +58 -33
- data/test/integration/test_helper.rb +11 -15
- data/test/integration/vm/VM_Create_test.rb +17 -18
- data/test/integration/vm/VM_Delete_test.rb +2 -4
- data/test/integration/vm/VM_Operations_test.rb +1 -2
- data/test/integration/vnet/Virtual_Network_Create_test.rb +9 -15
- data/test/integration/vnet/Virtual_Network_list_test.rb +4 -9
- data/test/support/name_generator.rb +8 -0
- data/test/support/virtual_network_helper.rb +2 -2
- data/test/test_helper.rb +13 -24
- data/test/unit/affinity_group/affinity_group_test.rb +10 -13
- data/test/unit/affinity_group/serialization_test.rb +7 -8
- data/test/unit/base_management/location_test.rb +1 -2
- data/test/unit/blob/auth/shared_access_signature_test.rb +71 -0
- data/test/unit/blob/blob_service_test.rb +393 -371
- data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +16 -16
- data/test/unit/core/auth/shared_key_lite_test.rb +4 -4
- data/test/unit/core/auth/shared_key_test.rb +2 -2
- data/test/unit/core/http/http_error_test.rb +10 -5
- data/test/unit/core/http/http_request_test.rb +72 -25
- data/test/unit/database/serialization_test.rb +7 -7
- data/test/unit/database/sql_database_server_service_test.rb +43 -47
- data/test/unit/service/serialization_test.rb +40 -9
- data/test/unit/service/storage_service_test.rb +13 -11
- data/test/unit/storage_management/serialization_test.rb +26 -14
- data/test/unit/storage_management/storage_management_service_test.rb +48 -62
- data/test/unit/virtual_machine_image_management/serialization_test.rb +20 -5
- data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +78 -29
- data/test/unit/virtual_machine_management/serialization_test.rb +112 -43
- data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +123 -100
- data/test/unit/vnet/serialization_test.rb +7 -7
- data/test/unit/vnet/virtual_network_management_service_test.rb +1 -1
- metadata +70 -16
- data/test/fixtures/certificate.pem +0 -21
@@ -19,7 +19,7 @@ describe Azure::CloudServiceManagementService do
|
|
19
19
|
subject { Azure::CloudServiceManagementService.new }
|
20
20
|
let(:request_path) { '/services/hostedservices' }
|
21
21
|
let(:cloud_services_xml) { Fixtures['list_cloud_services'] }
|
22
|
-
let(:
|
22
|
+
let(:verb) { :get }
|
23
23
|
let(:mock_request) { mock }
|
24
24
|
let(:response) do
|
25
25
|
response = mock
|
@@ -28,13 +28,13 @@ describe Azure::CloudServiceManagementService do
|
|
28
28
|
end
|
29
29
|
let(:response_body) { Nokogiri::XML response.body }
|
30
30
|
|
31
|
-
before
|
32
|
-
Loggerx.expects(:puts).returns(nil).at_least(0)
|
33
|
-
|
31
|
+
before{
|
32
|
+
Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
|
33
|
+
}
|
34
34
|
|
35
|
-
describe
|
35
|
+
describe "#list_cloud_services" do
|
36
36
|
before do
|
37
|
-
ManagementHttpRequest.stubs(:new).with(
|
37
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(verb, request_path, nil).returns(mock_request)
|
38
38
|
mock_request.expects(:call).returns(response_body)
|
39
39
|
end
|
40
40
|
|
@@ -55,9 +55,9 @@ describe Azure::CloudServiceManagementService do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
describe
|
58
|
+
describe "#get_cloud_service" do
|
59
59
|
before do
|
60
|
-
ManagementHttpRequest.stubs(:new).with(
|
60
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(verb, request_path, nil).returns(mock_request)
|
61
61
|
mock_request.expects(:call).returns(response_body)
|
62
62
|
end
|
63
63
|
|
@@ -65,28 +65,28 @@ describe Azure::CloudServiceManagementService do
|
|
65
65
|
subject.get_cloud_service 'cloud-service-1'
|
66
66
|
end
|
67
67
|
|
68
|
-
it '
|
68
|
+
it 'return cloud service instance if found cloud service with given name' do
|
69
69
|
result = subject.get_cloud_service 'cloud-service-1'
|
70
|
-
result.
|
70
|
+
result.must_be_kind_of Azure::CloudServiceManagement::CloudService
|
71
71
|
end
|
72
72
|
|
73
|
-
it "returns
|
73
|
+
it "returns nil if cloud service with given name doesn't exists" do
|
74
74
|
result = subject.get_cloud_service 'cloud-service-3'
|
75
|
-
result.must_equal
|
75
|
+
result.must_equal nil
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
describe
|
79
|
+
describe "#create_cloud_service" do
|
80
80
|
|
81
|
-
it
|
82
|
-
ManagementHttpRequest.any_instance.expects(:call).returns response_body
|
81
|
+
it "Create cloud service return message if cloud service exists of given name." do
|
82
|
+
Azure::BaseManagement::ManagementHttpRequest.any_instance.expects(:call).returns response_body
|
83
83
|
msg = subject.create_cloud_service 'cloud-service-1'
|
84
84
|
assert_match(/^Cloud service cloud-service-1 already exists*/, msg)
|
85
85
|
end
|
86
86
|
|
87
87
|
it "Create cloud service if cloud service doesn't exists of given name." do
|
88
88
|
Azure::CloudServiceManagementService.any_instance.stubs(:get_cloud_service).with('cloud-service-3').returns(false)
|
89
|
-
ManagementHttpRequest.any_instance.expects(:call).returns nil
|
89
|
+
Azure::BaseManagement::ManagementHttpRequest.any_instance.expects(:call).returns nil
|
90
90
|
subject.create_cloud_service 'cloud-service-3'
|
91
91
|
end
|
92
92
|
|
@@ -18,7 +18,7 @@ require "azure/core/auth/shared_key_lite"
|
|
18
18
|
describe Azure::Core::Auth::SharedKeyLite do
|
19
19
|
subject { Azure::Core::Auth::SharedKeyLite.new "account-name", "YWNjZXNzLWtleQ==" }
|
20
20
|
|
21
|
-
let(:
|
21
|
+
let(:verb) { "POST" }
|
22
22
|
let(:uri) { URI.parse "http://dummy.uri/resource" }
|
23
23
|
let(:headers) do
|
24
24
|
{
|
@@ -35,16 +35,16 @@ describe Azure::Core::Auth::SharedKeyLite do
|
|
35
35
|
|
36
36
|
describe "sign" do
|
37
37
|
it "creates a signature from the provided HTTP method, uri, and reduced set of standard headers" do
|
38
|
-
subject.sign(
|
38
|
+
subject.sign(verb, uri, headers).must_equal "account-name:vVFnj/+27JFABZgpt5H8g/JVU2HuWFnjv5aeUIxQvBE="
|
39
39
|
end
|
40
40
|
|
41
41
|
it "ignores standard headers other than Content-MD5, Content-Type, and Date" do
|
42
|
-
subject.sign(
|
42
|
+
subject.sign(verb, uri, headers.merge({"Content-Encoding"=> "foo"})).must_equal "account-name:vVFnj/+27JFABZgpt5H8g/JVU2HuWFnjv5aeUIxQvBE="
|
43
43
|
end
|
44
44
|
|
45
45
|
it "throws IndexError when there is no Date header" do
|
46
46
|
assert_raises IndexError do
|
47
|
-
subject.sign(
|
47
|
+
subject.sign(verb, uri, headers_without_date)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -18,7 +18,7 @@ require "azure/core/auth/shared_key"
|
|
18
18
|
describe Azure::Core::Auth::SharedKey do
|
19
19
|
subject { Azure::Core::Auth::SharedKey.new "account-name", "YWNjZXNzLWtleQ==" }
|
20
20
|
|
21
|
-
let(:
|
21
|
+
let(:verb) { "POST" }
|
22
22
|
let(:uri) { URI.parse "http://dummy.uri/resource" }
|
23
23
|
let(:headers) do
|
24
24
|
{
|
@@ -40,7 +40,7 @@ describe Azure::Core::Auth::SharedKey do
|
|
40
40
|
|
41
41
|
describe "sign" do
|
42
42
|
it "creates a signature from the provided HTTP method, uri, and a specific set of standard headers" do
|
43
|
-
subject.sign(
|
43
|
+
subject.sign(verb, uri, headers).must_equal "account-name:vcdxlDVoE1QvJerkg0ci3Wlnj2Qq8yzlsrkRf5dEU/I="
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -17,7 +17,7 @@ require "azure/core/http/http_error"
|
|
17
17
|
|
18
18
|
describe Azure::Core::Http::HTTPError do
|
19
19
|
let :http_response do
|
20
|
-
|
20
|
+
stub(:body => Fixtures[:http_error], :status_code => 409, :uri => 'http://dummy.uri')
|
21
21
|
end
|
22
22
|
|
23
23
|
subject do
|
@@ -48,10 +48,15 @@ describe Azure::Core::Http::HTTPError do
|
|
48
48
|
subject.message.must_equal "TableAlreadyExists (409): The table specified already exists."
|
49
49
|
end
|
50
50
|
|
51
|
-
|
52
|
-
http_response.body = "\r\nInvalid request\r\n"
|
51
|
+
describe 'with invalid http_response body' do
|
53
52
|
|
54
|
-
|
55
|
-
|
53
|
+
let :http_response do
|
54
|
+
stub(:body => "\r\nInvalid request\r\n", :status_code => 409, :uri => 'http://dummy.uri')
|
55
|
+
end
|
56
|
+
|
57
|
+
it "sets the type to unknown if the response body is not an XML" do
|
58
|
+
subject.type.must_equal "Unknown"
|
59
|
+
subject.description.must_equal "Invalid request"
|
60
|
+
end
|
56
61
|
end
|
57
62
|
end
|
@@ -12,54 +12,101 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
#--------------------------------------------------------------------------
|
15
|
-
require
|
16
|
-
require
|
15
|
+
require 'test_helper'
|
16
|
+
require 'azure/core/http/http_request'
|
17
17
|
|
18
18
|
describe Azure::Core::Http::HttpRequest do
|
19
|
-
describe
|
19
|
+
describe ' default_headers ' do
|
20
20
|
subject do
|
21
|
-
Azure::Core::Http::HttpRequest.new(:get, URI(
|
21
|
+
Azure::Core::Http::HttpRequest.new(:get, URI('/'), nil, 'Thu, 04 Oct 2012 06:38:27 GMT')
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
25
|
-
subject.headers[
|
24
|
+
it 'sets the x-ms-date header to the current_time' do
|
25
|
+
subject.headers['x-ms-date'] = 'Thu, 04 Oct 2012 06:38:27 GMT'
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
29
|
-
subject.headers[
|
28
|
+
it 'sets the x-ms-version header to the current API version' do
|
29
|
+
subject.headers['x-ms-version'] = '2011-08-18'
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
33
|
-
subject.headers[
|
32
|
+
it 'sets the DataServiceVersion header to the current API version' do
|
33
|
+
subject.headers['DataServiceVersion'] = '1.0;NetFx'
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
37
|
-
subject.headers[
|
36
|
+
it 'sets the MaxDataServiceVersion header to the current max` API version' do
|
37
|
+
subject.headers['MaxDataServiceVersion'] = '2.0;NetFx'
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
let :http do
|
41
|
+
mock = Minitest::Mock.new
|
42
|
+
mock.expect(:use_ssl=, true, [true])
|
43
|
+
mock.expect(:verify_mode=, OpenSSL::SSL::VERIFY_PEER, [1])
|
44
|
+
mock.expect(:request, Net::HTTPResponse.new(1.1, 200, '<body/>'), [Net::HTTP::Get])
|
45
|
+
mock
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'when not using a ca_file' do
|
49
|
+
subject do
|
50
|
+
Azure::Core::Http::HttpRequest.new(:get, URI('https://manage.windowsazure.com'), nil, 'Thu, 04 Oct 2012 06:38:27 GMT')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should set the ca_file on the http request' do
|
54
|
+
Net::HTTP.stub(:new, http) do
|
55
|
+
subject.call
|
56
|
+
end
|
57
|
+
http.verify
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'when using a ca_file' do
|
62
|
+
before do
|
63
|
+
Azure.config.ca_file = './blah.pem'
|
64
|
+
end
|
65
|
+
|
66
|
+
after do
|
67
|
+
Azure.config.ca_file = nil
|
68
|
+
end
|
69
|
+
|
70
|
+
subject do
|
71
|
+
Azure::Core::Http::HttpRequest.new(:get, URI('https://manage.windowsazure.com'), nil, 'Thu, 04 Oct 2012 06:38:27 GMT')
|
72
|
+
end
|
73
|
+
|
74
|
+
let :ca_http do
|
75
|
+
http.expect(:ca_file=, Azure.config.ca_file, [String])
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should set the ca_file on the http request' do
|
79
|
+
Net::HTTP.stub(:new, ca_http) do
|
80
|
+
subject.call
|
81
|
+
end
|
82
|
+
ca_http.verify
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
describe ' when passed a body ' do
|
41
88
|
subject do
|
42
|
-
Azure::Core::Http::HttpRequest.new(:get, URI(
|
89
|
+
Azure::Core::Http::HttpRequest.new(:get, URI('/'), '<body/>')
|
43
90
|
end
|
44
91
|
|
45
|
-
it
|
46
|
-
subject.headers[
|
92
|
+
it 'sets the default Content-Type header' do
|
93
|
+
subject.headers['Content-Type'].must_equal 'application/atom+xml; charset=utf-8'
|
47
94
|
end
|
48
95
|
|
49
|
-
it
|
50
|
-
subject.headers[
|
96
|
+
it 'sets the Content-Length header' do
|
97
|
+
subject.headers['Content-Length'].must_equal '7'
|
51
98
|
end
|
52
99
|
|
53
|
-
it
|
54
|
-
subject.headers[
|
100
|
+
it 'sets the Content-MD5 header to a Base64 encoded representation of the MD5 hash of the body' do
|
101
|
+
subject.headers['Content-MD5'].must_equal 'PNeJy7qyzV4XUoBBHkVu0g=='
|
55
102
|
end
|
56
103
|
end
|
57
104
|
|
58
|
-
describe
|
59
|
-
it
|
60
|
-
subject.headers[
|
61
|
-
subject.headers[
|
62
|
-
subject.headers[
|
105
|
+
describe ' when the body is nil ' do
|
106
|
+
it 'leaves the Content-Type, Content-Length, and Content-MD5 headers blank' do
|
107
|
+
subject.headers['Content-Type'].must_equal ''
|
108
|
+
subject.headers['Content-Length'].must_equal '0'
|
109
|
+
subject.headers['Content-MD5'].must_be_nil
|
63
110
|
end
|
64
111
|
end
|
65
112
|
end
|
@@ -38,18 +38,18 @@ describe Azure::SqlDatabaseManagement::Serialization do
|
|
38
38
|
describe '#database_to_xml' do
|
39
39
|
let(:login) { 'administrator' }
|
40
40
|
let(:password) { 'Password@123' }
|
41
|
-
let(:
|
41
|
+
let(:geo_location) { 'West US' }
|
42
42
|
|
43
43
|
it 'accepts an name and options hash' do
|
44
|
-
subject.database_to_xml(login, password,
|
44
|
+
subject.database_to_xml(login, password, geo_location)
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'serializes the argument to xml' do
|
48
|
-
results = subject.database_to_xml login, password,
|
48
|
+
results = subject.database_to_xml login, password, geo_location
|
49
49
|
doc = Nokogiri::XML results
|
50
50
|
doc.css('AdministratorLogin').text.must_equal login
|
51
51
|
doc.css('AdministratorLoginPassword').text.must_equal password
|
52
|
-
doc.css('Location').text.must_equal
|
52
|
+
doc.css('Location').text.must_equal geo_location
|
53
53
|
results.must_be_kind_of String
|
54
54
|
end
|
55
55
|
|
@@ -58,8 +58,8 @@ describe Azure::SqlDatabaseManagement::Serialization do
|
|
58
58
|
describe '#firewall_rule_to_xml' do
|
59
59
|
let(:options) do
|
60
60
|
{
|
61
|
-
|
62
|
-
|
61
|
+
start_ip_address: '10.0.0.1',
|
62
|
+
end_ip_address: '10.0.0.255'
|
63
63
|
}
|
64
64
|
end
|
65
65
|
|
@@ -86,7 +86,7 @@ describe Azure::SqlDatabaseManagement::Serialization do
|
|
86
86
|
|
87
87
|
it 'returns an Array of SqlDatabaseServer instances with firewall' do
|
88
88
|
results = subject.database_firewall_from_xml(
|
89
|
-
|
89
|
+
Nokogiri::XML(sql_server_firewall_xml)
|
90
90
|
)
|
91
91
|
results.must_be_kind_of Array
|
92
92
|
results[0].must_be_kind_of Hash
|
@@ -24,7 +24,7 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
24
24
|
|
25
25
|
describe 'SQL Server authentication Endpoint' do
|
26
26
|
before do
|
27
|
-
Loggerx.expects(:puts).returns(nil).at_least(0)
|
27
|
+
Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
|
28
28
|
mock_request.stubs(:headers).returns(response_headers)
|
29
29
|
mock_request.expects(:call).returns(Nokogiri::XML response_xml).at_least(0)
|
30
30
|
Azure.config.sql_database_authentication_mode = :sql_server
|
@@ -32,14 +32,14 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
32
32
|
|
33
33
|
describe '#list_servers' do
|
34
34
|
let(:response_xml) { Fixtures['list_sql_database'] }
|
35
|
-
let(:
|
35
|
+
let(:verb) { :get }
|
36
36
|
let(:request_path) { '/servers' }
|
37
37
|
|
38
38
|
before do
|
39
|
-
SqlManagementHttpRequest.stubs(:new).with(
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
Azure::BaseManagement::SqlManagementHttpRequest.stubs(:new).with(
|
40
|
+
verb,
|
41
|
+
request_path,
|
42
|
+
nil
|
43
43
|
).returns(mock_request)
|
44
44
|
end
|
45
45
|
|
@@ -64,7 +64,7 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
64
64
|
describe '#delete_server' do
|
65
65
|
before do
|
66
66
|
Azure::SqlDatabaseManagementService.any_instance.stubs(
|
67
|
-
|
67
|
+
:list_servers
|
68
68
|
).returns([])
|
69
69
|
end
|
70
70
|
|
@@ -82,7 +82,7 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
82
82
|
|
83
83
|
describe '#list_sql_server_firewall_rules' do
|
84
84
|
let(:response_xml) { Fixtures['list_sql_server_firewall'] }
|
85
|
-
let(:
|
85
|
+
let(:verb) { :get }
|
86
86
|
let(:sql_server_name) { 'server1' }
|
87
87
|
let(:request_path) { "/servers/#{sql_server_name}/firewallrules" }
|
88
88
|
|
@@ -91,13 +91,13 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
91
91
|
server.name = sql_server_name
|
92
92
|
end
|
93
93
|
Azure::SqlDatabaseManagementService.any_instance.stubs(
|
94
|
-
|
94
|
+
:list_servers
|
95
95
|
).returns([sql_server])
|
96
96
|
|
97
|
-
SqlManagementHttpRequest.stubs(:new).with(
|
98
|
-
|
99
|
-
|
100
|
-
|
97
|
+
Azure::BaseManagement::SqlManagementHttpRequest.stubs(:new).with(
|
98
|
+
verb,
|
99
|
+
request_path,
|
100
|
+
nil
|
101
101
|
).returns(mock_request)
|
102
102
|
end
|
103
103
|
|
@@ -115,36 +115,36 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
115
115
|
|
116
116
|
describe '#create_server' do
|
117
117
|
let(:response_xml) { Fixtures['create_sql_database_server'] }
|
118
|
-
let(:
|
118
|
+
let(:verb) { :post }
|
119
119
|
let(:request_path) { '/servers' }
|
120
120
|
let(:password) { 'User@123' }
|
121
121
|
let(:login) { 'ms_open_tech' }
|
122
|
-
let(:
|
122
|
+
let(:geo_location) { 'West US' }
|
123
123
|
|
124
124
|
before do
|
125
|
-
SqlManagementHttpRequest.stubs(:new).with(
|
126
|
-
|
127
|
-
|
128
|
-
|
125
|
+
Azure::BaseManagement::SqlManagementHttpRequest.stubs(:new).with(
|
126
|
+
verb,
|
127
|
+
request_path,
|
128
|
+
anything
|
129
129
|
).returns(mock_request)
|
130
130
|
|
131
131
|
mock_request.stubs(:headers).returns(response_headers)
|
132
132
|
mock_request.expects(:call).returns(
|
133
|
-
|
133
|
+
Nokogiri::XML response_xml
|
134
134
|
).at_least(0)
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'create sql server' do
|
138
|
-
sql_server = subject.create_server(login, password,
|
138
|
+
sql_server = subject.create_server(login, password, geo_location)
|
139
139
|
sql_server.name.must_equal 'gxyfzrhx2c'
|
140
140
|
sql_server.administrator_login.must_equal login
|
141
|
-
sql_server.location.must_equal
|
141
|
+
sql_server.location.must_equal geo_location
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
145
|
describe '#set_sql_server_firewall_rule' do
|
146
146
|
it 'create sql server' do
|
147
|
-
ip_range = {
|
147
|
+
ip_range = {start_ip_address: '0.0.0.1', end_ip_address: '0.0.0.5'}
|
148
148
|
exception = assert_raises(RuntimeError) do
|
149
149
|
subject.set_sql_server_firewall_rule('zv2nfoah2t1', ip_range)
|
150
150
|
end
|
@@ -156,7 +156,7 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
156
156
|
|
157
157
|
describe 'Management Certificate authentication Endpoint' do
|
158
158
|
before do
|
159
|
-
Loggerx.expects(:puts).returns(nil).at_least(0)
|
159
|
+
Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
|
160
160
|
mock_request.stubs(:headers).returns(response_headers)
|
161
161
|
mock_request.expects(:call).returns(Nokogiri::XML response_xml).at_least(0)
|
162
162
|
Azure.config.sql_database_authentication_mode = :management_certificate
|
@@ -164,15 +164,11 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
164
164
|
|
165
165
|
describe '#list_servers' do
|
166
166
|
let(:response_xml) { Fixtures['list_sql_database'] }
|
167
|
-
let(:
|
167
|
+
let(:verb) { :get }
|
168
168
|
let(:request_path) { '/servers' }
|
169
169
|
|
170
170
|
before do
|
171
|
-
SqlManagementHttpRequest.stubs(:new).with(
|
172
|
-
method,
|
173
|
-
request_path,
|
174
|
-
nil
|
175
|
-
).returns(mock_request)
|
171
|
+
Azure::BaseManagement::SqlManagementHttpRequest.stubs(:new).with(verb, request_path, nil).returns(mock_request)
|
176
172
|
end
|
177
173
|
|
178
174
|
it 'assembles a URI for the request' do
|
@@ -196,7 +192,7 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
196
192
|
describe '#delete_server' do
|
197
193
|
before do
|
198
194
|
Azure::SqlDatabaseManagementService.any_instance.stubs(
|
199
|
-
|
195
|
+
:list_servers
|
200
196
|
).returns([])
|
201
197
|
end
|
202
198
|
|
@@ -214,7 +210,7 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
214
210
|
|
215
211
|
describe '#list_sql_server_firewall_rules' do
|
216
212
|
let(:response_xml) { Fixtures['list_firewall_management_endpoint'] }
|
217
|
-
let(:
|
213
|
+
let(:verb) { :get }
|
218
214
|
let(:sql_server_name) { 'server1' }
|
219
215
|
let(:request_path) { "/servers/#{sql_server_name}/firewallrules" }
|
220
216
|
|
@@ -223,13 +219,13 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
223
219
|
server.name = sql_server_name
|
224
220
|
end
|
225
221
|
Azure::SqlDatabaseManagementService.any_instance.stubs(
|
226
|
-
|
222
|
+
:list_servers
|
227
223
|
).returns([sql_server])
|
228
224
|
|
229
|
-
SqlManagementHttpRequest.stubs(:new).with(
|
230
|
-
|
231
|
-
|
232
|
-
|
225
|
+
Azure::BaseManagement::SqlManagementHttpRequest.stubs(:new).with(
|
226
|
+
verb,
|
227
|
+
request_path,
|
228
|
+
nil
|
233
229
|
).returns(mock_request)
|
234
230
|
end
|
235
231
|
|
@@ -247,36 +243,36 @@ describe 'Azure::SqlDatabaseManagementService' do
|
|
247
243
|
|
248
244
|
describe '#create_server' do
|
249
245
|
let(:response_xml) { Fixtures['create_sql_database_server'] }
|
250
|
-
let(:
|
246
|
+
let(:verb) { :post }
|
251
247
|
let(:request_path) { '/servers' }
|
252
248
|
let(:password) { 'User@123' }
|
253
249
|
let(:login) { 'ms_open_tech' }
|
254
|
-
let(:
|
250
|
+
let(:geo_location) { 'West US' }
|
255
251
|
|
256
252
|
before do
|
257
|
-
SqlManagementHttpRequest.stubs(:new).with(
|
258
|
-
|
259
|
-
|
260
|
-
|
253
|
+
Azure::BaseManagement::SqlManagementHttpRequest.stubs(:new).with(
|
254
|
+
verb,
|
255
|
+
request_path,
|
256
|
+
anything
|
261
257
|
).returns(mock_request)
|
262
258
|
|
263
259
|
mock_request.stubs(:headers).returns(response_headers)
|
264
260
|
mock_request.expects(:call).returns(
|
265
|
-
|
261
|
+
Nokogiri::XML response_xml
|
266
262
|
).at_least(0)
|
267
263
|
end
|
268
264
|
|
269
265
|
it 'create sql server' do
|
270
|
-
sql_server = subject.create_server(login, password,
|
266
|
+
sql_server = subject.create_server(login, password, geo_location)
|
271
267
|
sql_server.name.must_equal 'gxyfzrhx2c'
|
272
268
|
sql_server.administrator_login.must_equal login
|
273
|
-
sql_server.location.must_equal
|
269
|
+
sql_server.location.must_equal geo_location
|
274
270
|
end
|
275
271
|
end
|
276
272
|
|
277
273
|
describe '#set_sql_server_firewall_rule' do
|
278
274
|
it 'create sql server' do
|
279
|
-
ip_range = {
|
275
|
+
ip_range = {start_ip_address: '0.0.0.1', end_ip_address: '0.0.0.5'}
|
280
276
|
exception = assert_raises(RuntimeError) do
|
281
277
|
subject.set_sql_server_firewall_rule('zv2nfoah2t1', ip_range)
|
282
278
|
end
|