Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Hooking service bus settings

  • Loading branch information...
commit 4136f0ddacda2c960cb05cb46a08abc0ca729dda 1 parent 952421e
@andrerod andrerod authored
View
20 lib/services/blob/blobservice.js
@@ -36,6 +36,8 @@ var QueryStringConstants = Constants.QueryStringConstants;
var BlobConstants = Constants.BlobConstants;
var HttpConstants = Constants.HttpConstants;
+var StorageServiceSettings = require('../core/storageservicesettings');
+
// Models requires
var ServicePropertiesResult = require('./models/servicepropertiesresult');
var ContainerAclResult = require('./models/containeraclresult');
@@ -76,8 +78,24 @@ BlobService.incorrectEndByteOffsetErr = 'End byte offset must be a modulus of 51
* @param {object} [authenticationProvider] The authentication provider.
*/
function BlobService(storageAccountOrConnectionString, storageAccessKey, host, authenticationProvider) {
+ if (storageAccountOrConnectionString && !storageAccessKey) {
+ // If namespaceOrConnectionString was passed and no accessKey was passed, assume connection string
+ var storageServiceSettings = StorageServiceSettings.createFromConnectionString(storageAccountOrConnectionString);
+ if (storageServiceSettings._name) {
+ storageAccount = storageServiceSettings._name;
+ }
+
+ if (storageServiceSettings._key) {
+ storageAccessKey = storageServiceSettings._key;
+ }
+
+ if (storageServiceSettings._blobEndpointUri) {
+ host = storageServiceSettings._blobEndpointUri;
+ }
+ }
+
if (!host) {
- if (ServiceClient.isEmulated()) {
+ if (!(storageAccountOrConnectionString && storageAccessKey) && ServiceClient.isEmulated()) {
host = ServiceClient.DEVSTORE_BLOB_HOST;
} else {
host = ServiceClient.CLOUD_BLOB_HOST;
View
43 lib/services/core/servicebusserviceclient.js
@@ -33,49 +33,18 @@ exports = module.exports = ServiceBusServiceClient;
* Creates a new ServiceBusServiceClient object.
*
* @constructor
+* @param {string} accessKey The password.
+* @param {string} issuer The issuer.
* @param {string} host The host for the service.
-* @param {string} [namespace] The service bus namespace.
-* @param {string} [accessKey] The password.
-* @param {string} [issuer] The issuer.
-* @param {string} [acsNamespace] The acs namespace. Usually the same as the sb namespace with "-sb" suffix.
+* @param {string} acsHost The acs host. Usually the same as the sb namespace with "-sb" suffix.
* @param {object} [authenticationProvider] The authentication provider.
*/
-function ServiceBusServiceClient(host, namespace, accessKey, issuer, acsNamespace, authenticationProvider) {
- this.namespace = namespace;
- if (!this.namespace) {
- this.namespace = process.env[ServiceClient.EnvironmentVariables.AZURE_SERVICEBUS_NAMESPACE];
- }
-
- this.acsNamespace = acsNamespace;
- if (!this.acsNamespace) {
- this.acsNamespace = process.env[ServiceClient.EnvironmentVariables.AZURE_WRAP_NAMESPACE];
-
- if (!this.acsNamespace) {
- this.acsNamespace = this.namespace + ServiceClient.DEFAULT_WRAP_NAMESPACE_SUFFIX;
- }
- }
-
- this.issuer = issuer;
- if (!this.issuer) {
- this.issuer = process.env[ServiceClient.EnvironmentVariables.AZURE_SERVICEBUS_ISSUER];
-
- if (!this.issuer) {
- this.issuer = ServiceClient.DEFAULT_SERVICEBUS_ISSUER;
- }
- }
-
- this.accessKey = accessKey;
- if (!this.accessKey) {
- this.accessKey = process.env[ServiceClient.EnvironmentVariables.AZURE_SERVICEBUS_ACCESS_KEY];
- }
-
+function ServiceBusServiceClient(accessKey, issuer, host, acsHost, authenticationProvider) {
ServiceBusServiceClient.super_.call(this, host, authenticationProvider);
- this.protocol = 'https://';
- this.port = 443;
-
+ this.authenticationProvider = authenticationProvider;
if (!this.authenticationProvider) {
- this.authenticationProvider = new Wrap(this.acsNamespace, this.issuer, this.accessKey);
+ this.authenticationProvider = new Wrap(acsHost, issuer, accessKey);
}
}
View
35 lib/services/core/servicebussettings.js
@@ -52,17 +52,15 @@ function ServiceBusSettings(serviceBusEndpointUri, namespace, wrapName, wrapPass
}
/**
-* Creates a ServiceBusSettings object from the given connection string.
+* Creates a ServiceBusSettings object from a set of settings.
*
-* @param {string} connectionString The storage settings connection string.
+* @param {object} settings The settings object.
*
* @return {ServiceBusSettings}
*/
-ServiceBusSettings.createFromConnectionString = function (connectionString) {
- var tokenizedSettings = ServiceSettings.parseAndValidateKeys(connectionString, validKeys);
-
+ServiceBusSettings.createFromSettings = function (settings) {
var matchedSpecs = ServiceSettings.matchedSpecification(
- tokenizedSettings,
+ settings,
ServiceSettings.allRequired(
_serviceBusEndpointSetting,
_wrapNameSetting,
@@ -73,7 +71,7 @@ ServiceBusSettings.createFromConnectionString = function (connectionString) {
if (matchedSpecs) {
var endpoint = util.tryGetValueInsensitive(
ConnectionStringKeys.SERVICE_BUS_ENDPOINT_NAME,
- tokenizedSettings
+ settings
);
// Parse the namespace part from the URI
@@ -82,12 +80,12 @@ ServiceBusSettings.createFromConnectionString = function (connectionString) {
var issuerName = util.tryGetValueInsensitive(
ConnectionStringKeys.SHARED_SECRET_ISSUER_NAME,
- tokenizedSettings
+ settings
);
var issuerValue = util.tryGetValueInsensitive(
ConnectionStringKeys.SHARED_SECRET_VALUE_NAME,
- tokenizedSettings
+ settings
);
return new ServiceBusSettings(
@@ -98,5 +96,22 @@ ServiceBusSettings.createFromConnectionString = function (connectionString) {
);
}
- ServiceSettings.noMatch(connectionString);
+ ServiceSettings.noMatchSettings(settings);
+};
+
+/**
+* Creates a ServiceBusSettings object from the given connection string.
+*
+* @param {string} connectionString The storage settings connection string.
+*
+* @return {ServiceBusSettings}
+*/
+ServiceBusSettings.createFromConnectionString = function (connectionString) {
+ var tokenizedSettings = ServiceSettings.parseAndValidateKeys(connectionString, validKeys);
+ try {
+ ServiceBusSettings.createFromSettings(tokenizedSettings);
+ } catch (e) {
+ // Replace no match settings exception by no match connection string one.
+ ServiceSettings.noMatchConnectionString(connectionString);
+ }
};
View
14 lib/services/core/servicesettings.js
@@ -28,11 +28,23 @@ exports = module.exports;
*
* @return none
*/
-exports.noMatch = function (connectionString) {
+exports.noMatchConnectionString = function (connectionString) {
throw new Error('The provided connection string ' + connectionString + ' does not have complete configuration settings.');
};
/**
+* Throws an exception if the settings dont match any of the
+* available formats.
+*
+* @param {object} settings The invalid settings.
+*
+* @return none
+*/
+exports.noMatchSettings = function (settings) {
+ throw new Error('The provided settings ' + JSON.stringify(settings) + ' are not complete.');
+};
+
+/**
* Parses the connection string and then validate that the parsed keys belong to
* the $validSettingKeys
*
View
2  lib/services/core/storageserviceclient.js
@@ -23,8 +23,6 @@ var xml2js = require('xml2js');
var azureutil = require('../../util/util');
-var StorageServiceSettings = require('../core/storageservicesettings');
-
var ServiceClient = require('./serviceclient');
var Constants = require('../../util/constants');
var HeaderConstants = Constants.HeaderConstants;
View
20 lib/services/queue/queueservice.js
@@ -27,6 +27,8 @@ var QueryStringConstants = Constants.QueryStringConstants;
var HttpConstants = Constants.HttpConstants;
var HeaderConstants = Constants.HeaderConstants;
+var StorageServiceSettings = require('../core/storageservicesettings');
+
// Models requires
var ListQueuesResultContinuation = require('./models/listqueuesresultcontinuation');
var QueueResult = require('./models/queueresult');
@@ -50,8 +52,24 @@ exports = module.exports = QueueService;
* @param {object} [authenticationProvider] The authentication provider.
*/
function QueueService(storageAccountOrConnectionString, storageAccessKey, host, authenticationProvider) {
+ if (storageAccountOrConnectionString && !storageAccessKey) {
+ // If namespaceOrConnectionString was passed and no accessKey was passed, assume connection string
+ var storageServiceSettings = StorageServiceSettings.createFromConnectionString(storageAccountOrConnectionString);
+ if (storageServiceSettings._name) {
+ storageAccount = storageServiceSettings._name;
+ }
+
+ if (storageServiceSettings._key) {
+ storageAccessKey = storageServiceSettings._key;
+ }
+
+ if (storageServiceSettings._queueEndpointUri) {
+ host = storageServiceSettings._queueEndpointUri;
+ }
+ }
+
if (!host) {
- if (ServiceClient.isEmulated()) {
+ if (!(storageAccountOrConnectionString && storageAccessKey) && ServiceClient.isEmulated()) {
host = ServiceClient.DEVSTORE_QUEUE_HOST;
} else {
host = ServiceClient.CLOUD_QUEUE_HOST;
View
43 lib/services/serviceBus/servicebusservice.js
@@ -29,7 +29,7 @@ var QueryStringConstants = Constants.QueryStringConstants;
var HttpConstants = Constants.HttpConstants;
var HeaderConstants = Constants.HeaderConstants;
-var ConnectionStringParser = require('../core/connectionstringparser');
+var ServiceBusSettings = require('../core/servicebussettings');
var QueueResult = require('./models/queueresult');
var QueueMessageResult = require('./models/queuemessageresult');
@@ -54,35 +54,28 @@ exports = module.exports = ServiceBusService;
* @param {object} [authenticationProvider] The authentication provider.
*/
function ServiceBusService(namespaceOrConnectionString, accessKey, issuer, acsNamespace, host, authenticationProvider) {
- if (!host) {
- host = ServiceClient.CLOUD_SERVICEBUS_HOST;
- }
-
- var namespace = namespaceOrConnectionString;
+ var serviceBusSettings;
if (namespaceOrConnectionString && !accessKey) {
// If namespaceOrConnectionString was passed and no accessKey was passed, assume connection string
- var connectionString = ConnectionStringParser.parse(namespaceOrConnectionString);
- if (connectionString['endpoint']) {
- var endpoint = url.parse(connectionString['endpoint']);
- namespace = endpoint.host.split('.')[0];
- host = endpoint.host.substring(namespace.length + 1);
- }
-
- if (connectionString['sharedsecretissuer']) {
- issuer = connectionString['sharedsecretissuer'];
- }
-
- if (connectionString['sharedsecretvalue']) {
- accessKey = connectionString['sharedsecretvalue'];
- }
+ serviceBusSettings = ServiceBusSettings.createFromConnectionString(namespaceOrConnectionString);
+ } else {
+ var settings = {
+ endpoint: namespaceOrConnectionString + '.' + ServiceClient.CLOUD_SERVICEBUS_HOST,
+ sharedsecretissuer: issuer,
+ sharedsecretvalue: accessKey,
+ stsendpoint: acsNamespace + '-sb.' + ServiceClient.CLOUD_ACCESS_CONTROL_HOST
+ };
- if (connectionString['stsendpoint']) {
- var endpoint = url.parse(connectionString['stsendpoint']);
- acsNamespace = endpoint.host.split('.')[0];
- }
+ console.log(settings);
+ serviceBusSettings = ServiceBusSettings.createFromSettings(settings);
}
- ServiceBusService.super_.call(this, host, namespace, accessKey, issuer, acsNamespace, authenticationProvider);
+ ServiceBusService.super_.call(this,
+ serviceBusSettings._wrapPassword,
+ serviceBusSettings._wrapName,
+ serviceBusSettings._serviceBusEndpointUri,
+ serviceBusSettings._wrapEndpointUri,
+ authenticationProvider);
}
util.inherits(ServiceBusService, ServiceBusServiceClient);
View
10 lib/services/table/tableservice.js
@@ -31,6 +31,8 @@ var HeaderConstants = Constants.HeaderConstants;
var TableConstants = Constants.TableConstants;
var HttpConstants = Constants.HttpConstants;
+var StorageServiceSettings = require('../core/storageservicesettings');
+
// Models requires
var TableResult = require('./models/tableresult');
var EntityResult = require('./models/entityresult');
@@ -73,9 +75,13 @@ function TableService(storageAccountOrConnectionString, storageAccessKey, host,
storageAccessKey = storageServiceSettings._key;
}
+ if (storageServiceSettings._tableEndpointUri) {
+ host = storageServiceSettings._tableEndpointUri;
+ }
+ }
- } else if (!host) {
- if (ServiceClient.isEmulated()) {
+ if (!host) {
+ if (!(storageAccountOrConnectionString && storageAccessKey) && ServiceClient.isEmulated()) {
host = ServiceClient.DEVSTORE_TABLE_HOST;
} else {
host = ServiceClient.CLOUD_TABLE_HOST;
View
37 test/testlist.txt
@@ -1,36 +1 @@
-cli/commands/generate-psm1-utils-test.js
-serviceruntime/roleenvironment-tests.js
-serviceruntime/runtimeversionmanager-tests.js
-serviceruntime/runtimeversionprotocolclient-tests.js
-services/blob/blobservice-tests.js
-services/blob/sharedaccesssignature-tests.js
-services/blob/sharedkey-tests.js
-services/blob/sharedkeylite-tests.js
-services/blob/filters-tests.js
-services/core/connectionstringparser-tests.js
-services/core/serviceclient-tests.js
-services/core/exponentialretrypolicyfilter-tests.js
-services/core/linearretrypolicyfilter-tests.js
-services/core/servicesettings-tests.js
-services/core/servicebussettings-tests.js
-services/core/servicemanagementsettings-tests.js
-services/core/storageservicesettings-tests.js
-services/queue/queueservice-tests.js
-services/table/batchserviceclient-tests.js
-services/table/sharedkeytable-tests.js
-services/table/sharedkeylitetable-tests.js
-services/serviceBus/servicebusservice-tests.js
-services/serviceBus/wrapservice-tests.js
-services/serviceBus/wraptokenmanager-tests.js
-services/table/tablequery-tests.js
-services/table/tableservice-batch-tests.js
-services/table/tableservice-tablequery-tests.js
-services/table/tableservice-tests.js
-util/atomhandler-tests.js
-util/iso8061date-tests.js
-util/util-tests.js
-util/validate-tests.js
-util/certificates/der.decoder-tests.js
-util/certificates/der.decoder.pfx.root-tests.js
-util/certificates/pkcs.filedecoder-tests.js
-azure-tests.js
+services/serviceBus/servicebusservice-tests.js
Please sign in to comment.
Something went wrong with that request. Please try again.