Permalink
Browse files

Adding tableservice tests for connection strings.

  • Loading branch information...
1 parent dc0068c commit da0a1658156593df0e0fe32e8fccec470ae485c8 Andre Rodrigues committed Oct 10, 2012
Showing with 21 additions and 0 deletions.
  1. +10 −0 lib/services/core/storageserviceclient.js
  2. +11 −0 test/services/table/tableservice-tests.js
@@ -23,6 +23,8 @@ var xml2js = require('xml2js');
var azureutil = require('../../util/util');
+var ConnectionStringParser = require('../core/connectionstringparser');
+
var ServiceClient = require('./serviceclient');
var Constants = require('../../util/constants');
var HeaderConstants = Constants.HeaderConstants;
@@ -50,13 +52,21 @@ function StorageServiceClient(storageAccountOrConnectionString, storageAccessKey
var storageAccount = storageAccountOrConnectionString;
if (storageAccountOrConnectionString && !storageAccessKey) {
+ // If namespaceOrConnectionString was passed and no accessKey was passed, assume connection string
+ var connectionString = ConnectionStringParser.parse(storageAccountOrConnectionString);
if (connectionString['accountname']) {
storageAccount = connectionString['accountname'];
}
if (connectionString['accountkey']) {
storageAccessKey = connectionString['accountkey'];
}
+
+ if (connectionString['defaultendpointsprotocol']) {
+ var hostUrl = url.parse(host);
+ hostUrl.protocol = connectionString['defaultendpointsprotocol'];
+ host = url.format(hostUrl);
+ }
}
this._setAccountCredentials(storageAccount, storageAccessKey);
@@ -766,4 +766,15 @@ suite('tableservice-tests', function () {
});
});
});
+
+ test('storageConnectionStrings', function (done) {
+ var connectionString = 'DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey';
+ var tableService = azure.createTableService(connectionString);
+
+ assert.equal(tableService.storageAccount, 'myaccount');
+ assert.equal(tableService.storageAccessKey, 'mykey');
+ assert.equal(tableService.protocol, 'https://');
+
+ done();
+ });
});

0 comments on commit da0a165

Please sign in to comment.