Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improving port defaulting code.

  • Loading branch information...
commit 4090ee1051a298f7f820cf73494de2bcf8bbb711 1 parent 89d4261
André Rodrigues andrerod authored
26 lib/services/core/servicebussettings.js
View
@@ -48,32 +48,10 @@ var validKeys = [
*/
function ServiceBusSettings(serviceBusEndpointUri, wrapEndpointUri, namespace, wrapName, wrapPassword) {
this._namespace = namespace;
-
- var parsedServiceBusEndpointUri = url.parse(serviceBusEndpointUri);
- if (parsedServiceBusEndpointUri.protocol === 'https:' &&
- !parsedServiceBusEndpointUri.port) {
- parsedServiceBusEndpointUri.port = 443;
- }
-
- this._serviceBusEndpointUri = url.format({
- protocol: parsedServiceBusEndpointUri.protocol,
- port: parsedServiceBusEndpointUri.port,
- hostname: parsedServiceBusEndpointUri.hostname
- });
+ this._serviceBusEndpointUri = serviceBusEndpointUri;
if (wrapEndpointUri) {
- var parsedWrapEndpointUri = url.parse(wrapEndpointUri);
- if (parsedWrapEndpointUri.protocol === 'https:' &&
- !parsedWrapEndpointUri.port) {
- parsedWrapEndpointUri.port = 443;
- }
-
- this._wrapEndpointUri = url.format({
- protocol: parsedWrapEndpointUri.protocol,
- port: parsedWrapEndpointUri.port,
- hostname: parsedWrapEndpointUri.hostname,
- path: parsedWrapEndpointUri.path
- });
+ this._wrapEndpointUri = wrapEndpointUri;
} else {
this._wrapEndpointUri = 'https://' + namespace + '-sb.accesscontrol.windows.net:443/WRAPv0.9';
}
17 lib/services/core/serviceclient.js
View
@@ -108,7 +108,15 @@ function ServiceClient(host, authenticationProvider) {
if (host) {
var parsedHost = ServiceClient._parseHost(host);
this.host = parsedHost.hostname;
- this.port = parsedHost.port;
+
+ if (parsedHost.port) {
+ this.port = parsedHost.port;
+ } else if (parsedHost.protocol === 'https:') {
+ this.port = 443;
+ } else {
+ this.port = 80;
+ }
+
if (!this.protocol) {
this.protocol = parsedHost.protocol + '//';
}
@@ -385,12 +393,7 @@ ServiceClient._parseHost = function (host) {
fullHost = ServiceClient.DEFAULT_PROTOCOL + fullHost;
}
- var parsedUrl = url.parse(fullHost);
- if (!parsedUrl.port) {
- parsedUrl.port = ServiceClient.DEFAULT_PORT;
- }
-
- return parsedUrl;
+ return url.parse(fullHost);
};
/*
7 lib/services/core/storageserviceclient.js
View
@@ -117,12 +117,7 @@ StorageServiceClient._getStorageSettingsExplicitOrEnvironment = function (storag
if (host) {
var parsedHost = ServiceClient._parseHost(host);
- if (parsedHost.protocol === 'https:' &&
- !parsedHost.port) {
- parsedHost.port = 443;
- }
-
- var parsedHostUrl = url.format({ protocol: parsedHost.protocol, port: parsedHost.port, hostname: parsedHost.hostname });
+ var parsedHostUrl = url.format(parsedHost);
if (parsedHostUrl === url.format(ServiceClient._parseHost(ServiceClient.DEVSTORE_BLOB_HOST)) ||
parsedHostUrl === url.format(ServiceClient._parseHost(ServiceClient.DEVSTORE_TABLE_HOST)) ||
parsedHostUrl === url.format(ServiceClient._parseHost(ServiceClient.DEVSTORE_QUEUE_HOST))) {
8 lib/services/core/storageservicesettings.js
View
@@ -71,6 +71,7 @@ var validKeys = [
function StorageServiceSettings(name, key, blobEndpointUri, queueEndpointUri, tableEndpointUri, usePathStyleUri) {
this._name = name;
this._key = key;
+
this._blobEndpointUri = blobEndpointUri;
this._queueEndpointUri = queueEndpointUri;
this._tableEndpointUri = tableEndpointUri;
@@ -144,12 +145,7 @@ StorageServiceSettings._getDefaultServiceEndpoint = function (settings, dns) {
settings
);
- var port = '80';
- if (scheme.toLowerCase() === 'https') {
- port = '443';
- }
-
- return url.format({ protocol: scheme, hostname: accountName + '.' + dns, port: port });
+ return url.format({ protocol: scheme, hostname: accountName + '.' + dns });
};
4 test/services/core/servicebussettings-tests.js
View
@@ -37,7 +37,7 @@ suite('servicebussettings-tests', function () {
// Assert
actual._namespace.should.equal(expectedNamespace);
- actual._serviceBusEndpointUri.should.equal(expectedServiceBusEndpoint + ':443');
+ actual._serviceBusEndpointUri.should.equal(expectedServiceBusEndpoint);
actual._wrapName.should.equal(expectedWrapName);
actual._wrapPassword.should.equal(expectedWrapPassword);
actual._wrapEndpointUri.should.equal(expectedWrapEndpointUri);
@@ -78,7 +78,7 @@ suite('servicebussettings-tests', function () {
// Assert
actual._namespace.should.equal(expectedNamespace);
- actual._serviceBusEndpointUri.should.equal(expectedServiceBusEndpoint + ':443');
+ actual._serviceBusEndpointUri.should.equal(expectedServiceBusEndpoint);
actual._wrapName.should.equal(expectedWrapName);
actual._wrapPassword.should.equal(expectedWrapPassword);
actual._wrapEndpointUri.should.equal(expectedWrapEndpointUri);
26 test/services/core/storageservicesettings-tests.js
View
@@ -105,9 +105,9 @@ suite('storageservicesettings-tests', function () {
// Assert
actual._name.should.equal(expectedName);
actual._key.should.equal(expectedKey);
- actual._blobEndpointUri.should.equal(expectedBlobEndpoint + ':443');
- actual._queueEndpointUri.should.equal(expectedQueueEndpoint + ':443');
- actual._tableEndpointUri.should.equal(expectedTableEndpoint + ':443');
+ actual._blobEndpointUri.should.equal(expectedBlobEndpoint);
+ actual._queueEndpointUri.should.equal(expectedQueueEndpoint);
+ actual._tableEndpointUri.should.equal(expectedTableEndpoint);
});
test('testCreateFromConnectionStringWithTableEndpointSpecified', function () {
@@ -126,8 +126,8 @@ suite('storageservicesettings-tests', function () {
// Assert
actual._name.should.equal(expectedName);
actual._key.should.equal(expectedKey);
- actual._blobEndpointUri.should.equal(expectedBlobEndpoint + ':443');
- actual._queueEndpointUri.should.equal(expectedQueueEndpoint + ':443');
+ actual._blobEndpointUri.should.equal(expectedBlobEndpoint);
+ actual._queueEndpointUri.should.equal(expectedQueueEndpoint);
actual._tableEndpointUri.should.equal(expectedTableEndpoint);
});
@@ -148,8 +148,8 @@ suite('storageservicesettings-tests', function () {
actual._name.should.equal(expectedName);
actual._key.should.equal(expectedKey);
actual._blobEndpointUri.should.equal(expectedBlobEndpoint);
- actual._queueEndpointUri.should.equal(expectedQueueEndpoint + ':443');
- actual._tableEndpointUri.should.equal(expectedTableEndpoint + ':443');
+ actual._queueEndpointUri.should.equal(expectedQueueEndpoint);
+ actual._tableEndpointUri.should.equal(expectedTableEndpoint);
});
test('testCreateFromConnectionStringWithQueueEndpointSpecified', function () {
@@ -168,9 +168,9 @@ suite('storageservicesettings-tests', function () {
// Assert
actual._name.should.equal(expectedName);
actual._key.should.equal(expectedKey);
- actual._blobEndpointUri.should.equal(expectedBlobEndpoint + ':443');
+ actual._blobEndpointUri.should.equal(expectedBlobEndpoint);
actual._queueEndpointUri.should.equal(expectedQueueEndpoint);
- actual._tableEndpointUri.should.equal(expectedTableEndpoint + ':443');
+ actual._tableEndpointUri.should.equal(expectedTableEndpoint);
});
test('testCreateFromConnectionStringWithQueueAndBlobEndpointSpecified', function () {
@@ -191,7 +191,7 @@ suite('storageservicesettings-tests', function () {
actual._key.should.equal(expectedKey);
actual._blobEndpointUri.should.equal(expectedBlobEndpoint);
actual._queueEndpointUri.should.equal(expectedQueueEndpoint);
- actual._tableEndpointUri.should.equal(expectedTableEndpoint + ':443');
+ actual._tableEndpointUri.should.equal(expectedTableEndpoint);
});
test('testCreateFromConnectionStringWithAutomaticMissingProtocolFail', function () {
@@ -292,9 +292,9 @@ suite('storageservicesettings-tests', function () {
// Assert
actual._name.should.equal(expectedName);
actual._key.should.equal(expectedKey);
- actual._blobEndpointUri.should.equal(expectedBlobEndpoint + ':443');
- actual._queueEndpointUri.should.equal(expectedQueueEndpoint + ':443');
- actual._tableEndpointUri.should.equal(expectedTableEndpoint + ':443');
+ actual._blobEndpointUri.should.equal(expectedBlobEndpoint);
+ actual._queueEndpointUri.should.equal(expectedQueueEndpoint);
+ actual._tableEndpointUri.should.equal(expectedTableEndpoint);
});
test('getDevelopmentStorageAccount', function () {
4 test/services/serviceBus/servicebusservice-tests.js
View
@@ -1630,7 +1630,7 @@ suite('servicebusservice-tests', function () {
assert.equal(err, null);
assert.equal(serviceBusService.host, process.env[ServiceClient.EnvironmentVariables.AZURE_SERVICEBUS_NAMESPACE] + '.servicebus.windows.net');
- assert.equal(serviceBusService.port, '80');
+ assert.equal(serviceBusService.port, 80);
assert.equal(serviceBusService.authenticationProvider.issuer, 'owner');
assert.equal(serviceBusService.authenticationProvider.accessKey, expectedKey);
assert.equal(serviceBusService.authenticationProvider.acsHost, 'https://' + process.env[ServiceClient.EnvironmentVariables.AZURE_SERVICEBUS_NAMESPACE] + '-sb.accesscontrol.windows.net:443');
@@ -1649,7 +1649,7 @@ suite('servicebusservice-tests', function () {
assert.equal(err, null);
assert.equal(serviceBusService.host, process.env[ServiceClient.EnvironmentVariables.AZURE_SERVICEBUS_NAMESPACE] + '.servicebus.windows.net');
- assert.equal(serviceBusService.port, '443');
+ assert.equal(serviceBusService.port, 443);
assert.equal(serviceBusService.authenticationProvider.issuer, 'owner');
assert.equal(serviceBusService.authenticationProvider.accessKey, expectedKey);
assert.equal(serviceBusService.authenticationProvider.acsHost, 'https://' + process.env[ServiceClient.EnvironmentVariables.AZURE_SERVICEBUS_NAMESPACE] + '-sb.accesscontrol.windows.net:443');
Please sign in to comment.
Something went wrong with that request. Please try again.