From 672e3900caf394c4ab91cad6adf9eb5ef4c0e84c Mon Sep 17 00:00:00 2001 From: veudayab Date: Tue, 22 Jul 2014 17:10:05 -0700 Subject: [PATCH] Storage Client Library - 0.3.1 --- ChangeLog.txt | 9 +++++++++ lib/azure-storage.js | 1 + lib/common/streams/batchoperation.js | 2 +- lib/common/util/constants.js | 2 +- lib/common/util/validate.js | 8 ++++---- package.json | 2 +- test/services/blob/blobservice-container-tests.js | 10 ++++++++++ test/services/table/tableservice-tests.js | 11 ++++++++++- 8 files changed, 37 insertions(+), 8 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index cd04c439..1cb4cbb8 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,15 @@ Note: This is an Azure Storage only package. The all up Azure node sdk still has the old storage bits in there. In a future release, those storage bits will be removed and an npm dependency to this storage node sdk will be taken. This is a CTP v1 release and the changes described below indicate the changes from the Azure node SDK 0.9.8 available here - https://github.com/Azure/azure-sdk-for-node. +2014.07.22 Version 0.3.1 + +ALL +* Fixed a bug which failed to validate special names for containers and tables. +* Exposed the Validation utility methods so users can use it to validate resource names. + +BLOB +* Fixed an issue which caused failures when an error was encountered while uploading big blobs. + 2014.07.07 Version 0.3.0 BLOB diff --git a/lib/azure-storage.js b/lib/azure-storage.js index 46798530..bd20a69f 100644 --- a/lib/azure-storage.js +++ b/lib/azure-storage.js @@ -207,6 +207,7 @@ exports.SR = azureCommon.SR; exports.StorageServiceClient = azureCommon.StorageServiceClient; exports.Logger = azureCommon.Logger; exports.WebResource = azureCommon.WebResource; +exports.Validate = azureCommon.validate; exports.date = azureCommon.date; // Other filters diff --git a/lib/common/streams/batchoperation.js b/lib/common/streams/batchoperation.js index 8f5d7863..7f1b653f 100644 --- a/lib/common/streams/batchoperation.js +++ b/lib/common/streams/batchoperation.js @@ -173,7 +173,7 @@ BatchOperation.prototype.getBatchOperationCallback = function (operation) { if (error) { operation.status = OperationState.ERROR; self.logger.debug(util.format('Operation %d failed. Error %s', operation.operationId, error)); - this._error = error; + self._error = error; } else { operation.status = OperationState.CALLBACK; self.logger.debug(util.format('Operation %d succeed', operation.operationId)); diff --git a/lib/common/util/constants.js b/lib/common/util/constants.js index 900db3c0..b465ff88 100644 --- a/lib/common/util/constants.js +++ b/lib/common/util/constants.js @@ -31,7 +31,7 @@ var Constants = { /* * Specifies the value to use for UserAgent header. */ - USER_AGENT_PRODUCT_VERSION: '0.3', + USER_AGENT_PRODUCT_VERSION: '0.3.1', /** * The number of default concurrent requests for parallel operation. diff --git a/lib/common/util/validate.js b/lib/common/util/validate.js index 854f312b..fc454c7e 100644 --- a/lib/common/util/validate.js +++ b/lib/common/util/validate.js @@ -104,7 +104,7 @@ exports.isValidUuid = function(uuid, callback) { * @return {function} */ exports.isBase64Encoded = function (key) { - var isValidBase64String = key.match('^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$'); + var isValidBase64String = key.match(/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/); if (isValidBase64String) { return true; @@ -137,7 +137,7 @@ var getNameError = function(name) { } // check if name follows naming rules - if (name.match('^([a-z0-9]+(-[a-z0-9]+)*)$') === null) { + if (name.match(/^([a-z0-9]+(-[a-z0-9]+)*)$/) === null) { return '%s name format is incorrect.'; } @@ -159,7 +159,7 @@ exports.containerNameIsValid = function (containerName, callback) { var nameErrorString = getNameError(containerName); - if (!nameErrorString || containerName.match('^(\$root|\$logs)')) { + if (!nameErrorString || containerName.match(/^(\$root|\$logs)$/)) { callback(); return true; } else { @@ -240,7 +240,7 @@ exports.tableNameIsValid = function (table, callback) { return fail('Table name cannot be \'Tables\'.'); } - if (table.match('^([A-Za-z][A-Za-z0-9]{2,62})$') !== null || table === '$MetricsCapacityBlob' || table.match('^(\$Metrics(Transactions|HourPrimary|MinutePrimary|HourSecondary|MinuteSecondary)(Blob|Queue|Table))$') !== null) + if (table.match(/^([A-Za-z][A-Za-z0-9]{2,62})$/) !== null || table === '$MetricsCapacityBlob' || table.match(/^(\$Metrics(HourPrimary|MinutePrimary|HourSecondary|MinuteSecondary)?(Transactions)(Blob|Queue|Table))$/) !== null) { callback(); return true; diff --git a/package.json b/package.json index 7c77abb5..13ae57c4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "azure-storage", "author": "Microsoft Corporation", - "version": "0.3.0", + "version": "0.3.1", "description": "Microsoft Azure Storage Client Library for Node.js", "tags": [ "azure", diff --git a/test/services/blob/blobservice-container-tests.js b/test/services/blob/blobservice-container-tests.js index fcded49f..a5f44f3c 100644 --- a/test/services/blob/blobservice-container-tests.js +++ b/test/services/blob/blobservice-container-tests.js @@ -61,6 +61,10 @@ describe('BlobContainer', function () { it('should work', function (done) { containerName = getName(containerNamesPrefix); + assert.doesNotThrow(function () { blobService.doesContainerExist('$root', function () { }); }); + + assert.doesNotThrow(function () { blobService.doesContainerExist('$logs', function () { }); }); + blobService.doesContainerExist(containerName, function (existsError, exists) { assert.equal(existsError, null); assert.strictEqual(exists, false); @@ -84,6 +88,12 @@ describe('BlobContainer', function () { it('should detect incorrect container names', function (done) { assert.throws(function () { blobService.createContainer(null, function () { }); }, /Required argument container for function createContainer is not defined/); + + assert.throws(function () { blobService.createContainer('$root1', function () { }); }, + /Container name format is incorrect./); + + assert.throws(function () { blobService.createContainer('$root$logs', function () { }); }, + /Container name format is incorrect./); assert.throws(function () { blobService.createContainer('', function () { }); }, /Required argument container for function createContainer is not defined/); diff --git a/test/services/table/tableservice-tests.js b/test/services/table/tableservice-tests.js index d1f3413f..8482acb3 100644 --- a/test/services/table/tableservice-tests.js +++ b/test/services/table/tableservice-tests.js @@ -125,6 +125,15 @@ describe('tableservice-tests', function () { done(); }); + describe('doesTableExist', function () { + it('should work', function (done) { + assert.doesNotThrow(function () { tableService.doesTableExist('$MetricsMinutePrimaryTransactionsBlob', function () { }); }); + assert.doesNotThrow(function () { tableService.doesTableExist('$MetricsTransactionsTable', function () { }); }); + + done(); + }); + }); + describe('CreateTable', function () { it('should detect incorrect table names', function (done) { assert.throws(function () { tableService.createTable(null, function () { }); }, @@ -147,7 +156,7 @@ describe('tableservice-tests', function () { assert.throws(function () { tableService.createTable('$Metrics', function () { }); }, /Table name format is incorrect./); - + done(); });