Permalink
Browse files

Deprecating usePathUri

  • Loading branch information...
1 parent ef43ac4 commit 05631910fccc0da51d4adc05319193e2f0bfbc78 Andre Rodrigues committed Oct 12, 2012
@@ -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) {
@@ -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);
}
@@ -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);
}
@@ -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) {
@@ -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;
@@ -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);
@@ -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];
}
@@ -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
};
@@ -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.
@@ -201,10 +196,6 @@ StorageServiceClient.prototype._getPath = function (path) {
path = '/' + path;
}
- if (this.usePathStyleUri) {
- path = '/' + this.storageAccount + path;
- }
-
return path;
};
@@ -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);
}
}
@@ -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);
}
@@ -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);
}
@@ -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);
}
}
@@ -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);
@@ -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();
});
@@ -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);

0 comments on commit 0563191

Please sign in to comment.