Skip to content

Commit

Permalink
Merge pull request #2 from veena-udayabhanu/master
Browse files Browse the repository at this point in the history
Storage Client Library - 0.2.0
  • Loading branch information
vinaysh-msft committed Jun 16, 2014
2 parents 097f90e + 5e24729 commit ee626b6
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 7 deletions.
7 changes: 6 additions & 1 deletion ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
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.06.XX Version 0.1.0
2014.06.16 Version 0.2.0

ALL
* Updated storage service version to 2014-02-14. The SAS tokens generated will therefore contain a signed version of 2014-02-14 and all the requests using SAS credentials have the api-version query parameter appended to the URI.

2014.06.12 Version 0.1.0

ALL
* The package has been renamed to azure-storage.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Microsoft Azure Storage SDK for Node.js

[![NPM version](https://badge.fury.io/js/azure-storage.svg)](http://badge.fury.io/js/azure-storage)

This project provides a Node.js package that makes it easy to consume and manage Microsoft Azure Storage Services.

> If you are looking for documentation for the Azure SDK for Node.js, see [http://dl.windowsazure.com/nodedocs/index.html](http://dl.windowsazure.com/nodedocs/index.html) or visit [https://github.com/Azure/azure-sdk-for-node](https://github.com/Azure/azure-sdk-for-node). While the Azure SDK for Node.js provides support for working with Azure Storage, you should consider using the Azure Storage SDK as it supports features not available in the Azure SDK for Node.js
Expand Down
3 changes: 3 additions & 0 deletions lib/common/lib/services/sharedaccesssignature.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
//
var HmacSha256Sign = require('./hmacsha256sign');
var Constants = require('./../util/constants');

/**
* Creates a new SharedAccessSignature object.
Expand Down Expand Up @@ -43,6 +44,8 @@ SharedAccessSignature.prototype.signRequest = function (webResource, callback) {

webResource.uri += this.sasToken;

// Add the api-version
webResource.uri += '&' + Constants.QueryStringConstants.API_VERSION + '=' + Constants.HeaderConstants.TARGET_STORAGE_VERSION;
callback(null);
};

Expand Down
10 changes: 9 additions & 1 deletion lib/common/lib/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ var Constants = {
* @const
* @type {string}
*/
TARGET_STORAGE_VERSION: '2013-08-15',
TARGET_STORAGE_VERSION: '2014-02-14',

/**
* The UserAgent header.
Expand Down Expand Up @@ -1394,6 +1394,14 @@ var Constants = {
},

QueryStringConstants: {

/**
* Query component for SAS API version.
* @const
* @type {string}
*/
API_VERSION: 'api-version',

/**
* The Comp value.
*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "azure-storage",
"author": "Microsoft Corporation",
"version": "0.1.0",
"version": "0.2.0",
"description": "Microsoft Azure Storage Client Library for Node.js",
"tags": [
"azure",
Expand Down
2 changes: 1 addition & 1 deletion test/common/sharedkey-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('sharedkey-tests', function () {
webResource.withHeader(HeaderConstants.DATE_HEADER, 'Fri, 23 Sep 2011 01:37:34 GMT');

sharedkey.signRequest(webResource, function () {
assert.equal(webResource.headers[HeaderConstants.AUTHORIZATION], 'SharedKey devstoreaccount1:IB4RSGc63bIKUYeaMwbW1lF90fO7EVzR8pxa7byqq14=');
assert.equal(webResource.headers[HeaderConstants.AUTHORIZATION], 'SharedKey devstoreaccount1:/Nzbqsmrbb107sFMOfcMFuK2TdkGCUUY4TjPspfeCTc=');

done();
});
Expand Down
58 changes: 55 additions & 3 deletions test/services/blob/blobservice-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var qs = require('querystring');
var path = require('path');
var util = require('util');
var url = require('url');
var extend = require('extend');

var request = require('request');

Expand Down Expand Up @@ -1048,7 +1049,7 @@ describe('BlobService', function () {
assert.strictEqual(parsedUrl.port, '80');
assert.strictEqual(parsedUrl.hostname, 'host.com');
assert.strictEqual(parsedUrl.pathname, '/' + containerName + '/' + blobName);
assert.strictEqual(parsedUrl.query, 'se=2011-10-12T11%3A53%3A40Z&sv=2013-08-15&sr=b&sig=Lb4Vj4NfcvbX%2F7Eoq%2FmzjCciWkh5Ve9d6ODKaLqD%2B24%3D');
assert.strictEqual(parsedUrl.query, 'se=2011-10-12T11%3A53%3A40Z&sv=2014-02-14&sr=b&sig=KAewjRdjdHO6gBSe0R0xqGrEwdGf1Ua%2FhnUfjxOhY7w%3D');

done();
});
Expand Down Expand Up @@ -1123,8 +1124,8 @@ describe('BlobService', function () {
assert.equal(sasQueryString[QueryStringConstants.SIGNED_EXPIRY], '2011-10-12T11:53:40Z');
assert.equal(sasQueryString[QueryStringConstants.SIGNED_RESOURCE], Constants.BlobConstants.ResourceTypes.BLOB);
assert.equal(sasQueryString[QueryStringConstants.SIGNED_PERMISSIONS], BlobUtilities.SharedAccessPermissions.READ);
assert.equal(sasQueryString[QueryStringConstants.SIGNED_VERSION], '2013-08-15');
assert.equal(sasQueryString[QueryStringConstants.SIGNATURE], 'sVFelmZkt63VUuHYfzFk7itznw+/fkL1Z9zOzlhcNao=');
assert.equal(sasQueryString[QueryStringConstants.SIGNED_VERSION], '2014-02-14');
assert.equal(sasQueryString[QueryStringConstants.SIGNATURE], 'kXVNIN/SsiEQ1onxqp2bmxay8PFy0mCtEQE41lOyKy8=');

done();
});
Expand Down Expand Up @@ -1221,6 +1222,57 @@ describe('BlobService', function () {
});
});
});

it('should append api-version', function (done) {
var containerName = testutil.generateId(containerNamesPrefix, containerNames, false);
var blobName = testutil.generateId(blobNamesPrefix, blobNames, false);
var blobService = azure.createBlobService()
.withFilter(new azure.ExponentialRetryPolicyFilter());

blobService.createContainer(containerName, function (error) {
assert.equal(error, null);

blobService.createBlockBlobFromText(containerName, blobName, 'id1', function (error2) {
assert.equal(error2, null);

var startDate = new Date();
var expiryDate = new Date(startDate);
expiryDate.setMinutes(startDate.getMinutes() + 5);

var sharedAccessPolicy = {
AccessPolicy: {
Permissions: BlobUtilities.SharedAccessPermissions.READ,
Start: startDate,
Expiry: expiryDate
}
};

var token = blobService.generateSharedAccessSignature(containerName, blobName, sharedAccessPolicy);

var sharedAccessBlobService = azure.createBlobServiceWithSas(blobService.host, token);

var callback = function(webResource) {
var copy = extend(true, {}, webResource);
sharedAccessBlobService.storageCredentials.signRequest(copy, function() {
assert.notEqual(copy.uri.indexOf('api-version'), -1);
});
};

sharedAccessBlobService.on('sendingRequestEvent', callback);

sharedAccessBlobService.getBlobProperties(containerName, blobName, function (error, result) {
assert.equal(error, null);
assert.notEqual(result, null);
sharedAccessBlobService.removeAllListeners();

blobService.deleteContainer(containerName, function (deleteError) {
assert.equal(deleteError, null);
done();
});
});
});
});
});
});

it('responseEmits', function (done) {
Expand Down

0 comments on commit ee626b6

Please sign in to comment.