Skip to content

Commit

Permalink
Deprecating usePathUri
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Rodrigues committed Oct 12, 2012
1 parent ef43ac4 commit 0563191
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 49 deletions.
2 changes: 1 addition & 1 deletion lib/services/blob/blobservice.js
Expand Up @@ -86,7 +86,7 @@ function BlobService(storageAccountOrConnectionString, storageAccessKey, host, a
authenticationProvider);

if (!this.authenticationProvider) {
this.authenticationProvider = new SharedKey(this.storageAccount, this.storageAccessKey, this.usePathStyleUri);
this.authenticationProvider = new SharedKey(this.storageAccount, this.storageAccessKey);
}

if (!this.sharedAccessSignatureCredentials) {
Expand Down
4 changes: 1 addition & 3 deletions lib/services/blob/sharedkey.js
Expand Up @@ -29,12 +29,10 @@ exports = module.exports = SharedKey;
* @constructor
* @param {string} storageAccount The storage account.
* @param {string} storageAccessKey The storage account's access key.
* @param {bool} usePathStyleUri Boolean value indicating if the path, or the hostname, should include the storage account.
*/
function SharedKey(storageAccount, storageAccessKey, usePathStyleUri) {
function SharedKey(storageAccount, storageAccessKey) {
this.storageAccount = storageAccount;
this.storageAccessKey = storageAccessKey;
this.usePathStyleUri = usePathStyleUri;
this.signer = new HmacSha256Sign(storageAccessKey);
}

Expand Down
4 changes: 1 addition & 3 deletions lib/services/blob/sharedkeylite.js
Expand Up @@ -31,12 +31,10 @@ exports = module.exports = SharedKeyLite;
* @constructor
* @param {string} storageAccount The storage account.
* @param {string} storageAccessKey The storage account's access key.
* @param {bool} usePathStyleUri Boolean value indicating if the path, or the hostname, should include the storage account.
*/
function SharedKeyLite(storageAccount, storageAccessKey, usePathStyleUri) {
function SharedKeyLite(storageAccount, storageAccessKey) {
this.storageAccount = storageAccount;
this.storageAccessKey = storageAccessKey;
this.usePathStyleUri = usePathStyleUri;
this.signer = new HmacSha256Sign(storageAccessKey);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/services/core/serviceclient.js
Expand Up @@ -106,7 +106,7 @@ function ServiceClient(host, authenticationProvider) {
this._initDefaultFilter();

if (host) {
var parsedHost = this._parseHost(host);
var parsedHost = ServiceClient._parseHost(host);
this.host = parsedHost.hostname;
this.port = parsedHost.port;
if (!this.protocol) {
Expand Down Expand Up @@ -379,7 +379,7 @@ ServiceClient.prototype._setRequestOptionsProxy = function (requestOptions) {
* @param {string} host The full host to be parsed.
* @return {object} THe parsed host as returned by the method "url.parse".
*/
ServiceClient.prototype._parseHost = function (host) {
ServiceClient._parseHost = function (host) {
var fullHost = host;
if (fullHost.indexOf(Constants.HTTP) === -1) {
fullHost = ServiceClient.DEFAULT_PROTOCOL + fullHost;
Expand Down
29 changes: 10 additions & 19 deletions lib/services/core/storageserviceclient.js
Expand Up @@ -51,7 +51,6 @@ StorageServiceClient.incorrectStorageAccessKeyErr = 'You must supply an account
function StorageServiceClient(storageAccount, storageAccessKey, host, authenticationProvider) {
this._setAccountCredentials(storageAccount, storageAccessKey);
this.apiVersion = HeaderConstants.TARGET_STORAGE_VERSION;
this.usePathStyleUri = ServiceClient.isEmulated(host);

StorageServiceClient.super_.call(this, host, authenticationProvider);

Expand Down Expand Up @@ -80,7 +79,6 @@ StorageServiceClient.getStorageSettings = function (storageAccountOrConnectionSt
storageServiceSettings = StorageServiceSettings.developmentStorageAccount();
} else {
// Explicit credentials scenario

if (!storageAccountOrConnectionString) {
storageAccountOrConnectionString = process.env[ServiceClient.EnvironmentVariables.AZURE_STORAGE_ACCOUNT];
}
Expand All @@ -90,22 +88,23 @@ StorageServiceClient.getStorageSettings = function (storageAccountOrConnectionSt
}

// Default endpoints
var blobendpoint: url.format({ protocol: 'http:', host: storageAccountOrConnectionString + '.' + ServiceClient.CLOUD_BLOB_HOST });
var tableendpoint: url.format({ protocol: 'http:', host: storageAccountOrConnectionString + '.' + ServiceClient.CLOUD_TABLE_HOST });
var queueendpoint: url.format({ protocol: 'http:', host: storageAccountOrConnectionString + '.' + ServiceClient.CLOUD_QUEUE_HOST });
var blobendpoint = url.format({ protocol: 'http:', host: storageAccountOrConnectionString + '.' + ServiceClient.CLOUD_BLOB_HOST });
var tableendpoint = url.format({ protocol: 'http:', host: storageAccountOrConnectionString + '.' + ServiceClient.CLOUD_TABLE_HOST });
var queueendpoint = url.format({ protocol: 'http:', host: storageAccountOrConnectionString + '.' + ServiceClient.CLOUD_QUEUE_HOST });

if (host) {
var parsedHost = this._parseHost(host);
blobendpoint: url.format({ protocol: parsedHost.protocol, port: parsedHost.port, host: storageAccountOrConnectionString + '.' + ServiceClient.CLOUD_BLOB_HOST });
tableendpoint: url.format({ protocol: parsedHost.protocol, port: parsedHost.port, host: storageAccountOrConnectionString + '.' + ServiceClient.CLOUD_TABLE_HOST });
queueendpoint: url.format({ protocol: parsedHost.protocol, port: parsedHost.port, host: storageAccountOrConnectionString + '.' + ServiceClient.CLOUD_QUEUE_HOST });
var parsedHost = ServiceClient._parseHost(host);

blobendpoint = url.format({ protocol: parsedHost.protocol, port: parsedHost.port, host: storageAccountOrConnectionString + '.' + parsedHost.host });
tableendpoint = url.format({ protocol: parsedHost.protocol, port: parsedHost.port, host: storageAccountOrConnectionString + '.' + parsedHost.host });
queueendpoint = url.format({ protocol: parsedHost.protocol, port: parsedHost.port, host: storageAccountOrConnectionString + '.' + parsedHost.host });
}

var settings = {
accountname: storageAccountOrConnectionString,
accountkey: storageAccessKey,
blobendpoint: blobendpoint
tableendpoint: tableendpoint
blobendpoint: blobendpoint,
tableendpoint: tableendpoint,
queueendpoint: queueendpoint
};

Expand Down Expand Up @@ -186,10 +185,6 @@ StorageServiceClient.prototype._buildRequestOptions = function (webResource, opt

/**
* Retrieves the normalized path to be used in a request.
* This takes into consideration the usePathStyleUri object field
* which specifies if the request is against the emulator or against
* the live service. It also adds a leading "/" to the path in case
* it's not there before.
*
* @param {string} path The path to be normalized.
* @return {string} The normalized path.
Expand All @@ -201,10 +196,6 @@ StorageServiceClient.prototype._getPath = function (path) {
path = '/' + path;
}

if (this.usePathStyleUri) {
path = '/' + this.storageAccount + path;
}

return path;
};

Expand Down
2 changes: 1 addition & 1 deletion lib/services/queue/queueservice.js
Expand Up @@ -60,7 +60,7 @@ function QueueService(storageAccountOrConnectionString, storageAccessKey, host,
authenticationProvider);

if (!this.authenticationProvider) {
this.authenticationProvider = new SharedKey(this.storageAccount, this.storageAccessKey, this.usePathStyleUri);
this.authenticationProvider = new SharedKey(this.storageAccount, this.storageAccessKey);
}
}

Expand Down
4 changes: 1 addition & 3 deletions lib/services/table/sharedkeylitetable.js
Expand Up @@ -31,12 +31,10 @@ exports = module.exports = SharedKeyLiteTable;
* @constructor
* @param {string} storageAccount The storage account.
* @param {string} storageAccessKey The storage account's access key.
* @param {bool} usePathStyleUri Boolean value indicating if the path, or the hostname, should include the storage account.
*/
function SharedKeyLiteTable(storageAccount, storageAccessKey, usePathStyleUri) {
function SharedKeyLiteTable(storageAccount, storageAccessKey) {
this.storageAccount = storageAccount;
this.storageAccessKey = storageAccessKey;
this.usePathStyleUri = usePathStyleUri;
this.signer = new HmacSha256Sign(storageAccessKey);
}

Expand Down
4 changes: 1 addition & 3 deletions lib/services/table/sharedkeytable.js
Expand Up @@ -31,12 +31,10 @@ exports = module.exports = SharedKeyTable;
* @constructor
* @param {string} storageAccount The storage account.
* @param {string} storageAccessKey The storage account's access key.
* @param {bool} usePathStyleUri Boolean value indicating if the path, or the hostname, should include the storage account.
*/
function SharedKeyTable(storageAccount, storageAccessKey, usePathStyleUri) {
function SharedKeyTable(storageAccount, storageAccessKey) {
this.storageAccount = storageAccount;
this.storageAccessKey = storageAccessKey;
this.usePathStyleUri = usePathStyleUri;
this.signer = new HmacSha256Sign(storageAccessKey);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/services/table/tableservice.js
Expand Up @@ -70,7 +70,7 @@ function TableService(storageAccountOrConnectionString, storageAccessKey, host,
authenticationProvider);

if (!this.authenticationProvider) {
this.authenticationProvider = new SharedKeyTable(this.storageAccount, this.storageAccessKey, this.usePathStyleUri);
this.authenticationProvider = new SharedKeyTable(this.storageAccount, this.storageAccessKey);
}
}

Expand Down
18 changes: 5 additions & 13 deletions test/services/blob/blobservice-tests.js
Expand Up @@ -58,7 +58,7 @@ suite('blobservice-tests', function () {
teardown(function (done) {
blobtestutil.tearDownTest(numberTests, blobService, testPrefix, done);
});

/*
test('IncorrectContainerNames', function (done) {
assert.throws(function () { blobService.createContainer(null, function () { }); },
BlobService.incorrectContainerNameErr);
Expand Down Expand Up @@ -1164,21 +1164,13 @@ suite('blobservice-tests', function () {
var containerName = testutil.generateId(containerNamesPrefix, containerNames, blobtestutil.isMocked);
var blobName = testutil.generateId(blobNamesPrefix, blobNames, blobtestutil.isMocked);
var blobServiceassert = azure.createBlobService('storageAccount', 'storageAccessKey', 'host:80');
blobServiceassert.usePathStyleUri = false;
var blobServiceassert = azure.createBlobService('storageAccount', 'storageAccessKey', 'host.com:80');
var urlParts = blobServiceassert.getBlobUrl(containerName);
assert.equal(urlParts.url(), 'http://storageAccount.host:80/' + containerName);

urlParts = blobServiceassert.getBlobUrl(containerName, blobName);
assert.equal(urlParts.url(), 'http://storageAccount.host:80/' + containerName + '/' + blobName);

blobServiceassert.usePathStyleUri = true;
urlParts = blobServiceassert.getBlobUrl(containerName);
assert.equal(urlParts.url(), 'http://host:80/storageAccount/' + containerName);
assert.equal(urlParts.url(), 'http://storageaccount.host.com:80/' + containerName);
urlParts = blobServiceassert.getBlobUrl(containerName, blobName);
assert.equal(urlParts.url(), 'http://host:80/storageAccount/' + containerName + '/' + blobName);
assert.equal(urlParts.url(), 'http://storageaccount.host.com:80/' + containerName + '/' + blobName);
done();
});
Expand Down Expand Up @@ -1272,7 +1264,7 @@ suite('blobservice-tests', function () {
});
});
});

*/
test('storageConnectionStrings', function (done) {
var connectionString = 'DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey';
var blobService = azure.createBlobService(connectionString);
Expand Down

0 comments on commit 0563191

Please sign in to comment.