Skip to content

Commit

Permalink
Merge pull request #20 from asorrin-msft/master
Browse files Browse the repository at this point in the history
Storage Client Library - 0.3.3
  • Loading branch information
vinaysh-msft committed Aug 21, 2014
2 parents e68bc07 + 77acd4f commit 341df62
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 93 deletions.
10 changes: 10 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
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.08.20 Version 0.3.3

BLOB
* Fixed an issue where SAS tokens were being incorrectly generated for the root container and when the blob name required encoding.
* Documented the 'parallelOperationThreadCount' option as input to various uploadBlob APIs.

FILE
* Fixed an issue where signing was incorrect when the URI contained '.' or '..'.
* Fixed an issue where "getURI" was requiring a file parameter, although the parameter should be optional.

2014.07.25 Version 0.3.2

ALL
Expand Down
1 change: 1 addition & 0 deletions lib/common/services/storageserviceclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ StorageServiceClient.prototype._setRequestUrl = function (webResource, options)
}

webResource.uri = url.resolve(host, url.format({pathname: webResource.path, query: webResource.queryString}));
webResource.path = url.parse(webResource.uri).pathname;
};

/**
Expand Down
9 changes: 8 additions & 1 deletion lib/common/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var Constants = {
/*
* Specifies the value to use for UserAgent header.
*/
USER_AGENT_PRODUCT_VERSION: '0.3.2',
USER_AGENT_PRODUCT_VERSION: '0.3.3',

/**
* The number of default concurrent requests for parallel operation.
Expand Down Expand Up @@ -653,6 +653,13 @@ var Constants = {
*/
ODATA_TYPE_MARKER: '$',

/**
* The value to set the maximum data service version header.
* @const
* @type {string}
*/
DEFAULT_DATA_SERVICE_VERSION: '3.0;NetFx',

/**
* The name of the property that stores the table name.
*
Expand Down
167 changes: 85 additions & 82 deletions lib/services/blob/blobservice.js

Large diffs are not rendered by default.

9 changes: 1 addition & 8 deletions lib/services/file/fileservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,6 @@ FileService.prototype.getUrl = function (share, directory, file, primary) {
validate.validateArgs('getUrl', function (v) {
v.string(share, 'share');
v.stringAllowEmpty(directory, 'directory');
v.string(file, 'file');
v.shareNameIsValid(share);
});

Expand All @@ -1081,13 +1080,7 @@ FileService.prototype.getUrl = function (share, directory, file, primary) {
host = this.host.primaryHost;
}

var name;
if (!directory && !file) {
name = createResourceName(share, directory);
} else {
name = createResourceName(share, directory, file);
}

var name = createResourceName(share, directory, file);
return url.resolve(host, url.format({pathname: this._getPath('/' + name)}));
};

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.3.2",
"version": "0.3.3",
"description": "Microsoft Azure Storage Client Library for Node.js",
"tags": [
"azure",
Expand Down
88 changes: 88 additions & 0 deletions test/services/blob/blobservice-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,94 @@ describe('BlobService', function () {
});
});
});

describe('SasStrangeChars', function() {
it('SasStrangeCharsBlobName', function (done) {
var containerName = testutil.generateId(containerNamesPrefix, containerNames, false);
var blobName = 'def@#/abef?def/& &/abcde+=-';
var blobService = azure.createBlobService().withFilter(new azure.ExponentialRetryPolicyFilter());
var blobText = 'sampletext!';

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

blobService.createBlockBlobFromText(containerName, blobName, blobText, 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,
Expiry: expiryDate
}
};

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

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

sharedAccessBlobService.getBlobToText(containerName, blobName, function (downloadErr, blobTextResponse) {
assert.equal(downloadErr, null);
assert.equal(blobTextResponse, blobText);

done();
});
});
});
});

describe('SasRootContainer', function() {
var containerName = '$root';
var blobName = 'sampleBlobName';
var blobService = azure.createBlobService().withFilter(new azure.ExponentialRetryPolicyFilter());
var blobText = 'sampletext!';

// This is testing the root container functionality, which we don't want to pollute with random blobs.
// Thus, trying to delete blob both before and after the actual test.
before(function (done) {
blobService.deleteBlobIfExists(containerName, blobName, function() {
done();
});
});

after(function (done) {
blobService.deleteBlobIfExists(containerName, blobName, function() {
done();
});
});

it('should work', function(done) {
blobService.createBlockBlobFromText(containerName, blobName, blobText, 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,
Expiry: expiryDate
}
};

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

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

sharedAccessBlobService.getBlobToText(containerName, blobName, function (downloadErr, blobTextResponse) {
assert.equal(downloadErr, null);
assert.equal(blobTextResponse, blobText);

done();
});
});
});
});
});
});

it('responseEmits', function (done) {
Expand Down
32 changes: 31 additions & 1 deletion test/services/file/fileservice-directory-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ describe('FileDirectory', function () {
directories.push.apply(directories, result.entries.directories);
var token = result.continuationToken;
if(token) {
listFilesAndDirectoriesWithoutPrefix(shareName, directoryName, token, callback);
listFilesAndDirectories(shareName, directoryName, token, callback);
}
else {
callback();
Expand Down Expand Up @@ -343,6 +343,36 @@ describe('FileDirectory', function () {
});
});
});

it('multipleLevelsDirectory', function (done) {
fileService.createFile(shareName, directoryName, fileName1, 0, function (fileErr1) {
assert.equal(fileErr1, null);

var nextDirectory = directoryName + "/next";
var dotdotDirectory = nextDirectory + "/..";

listFilesAndDirectories(shareName, dotdotDirectory, null, function() {
assert.equal(directories.length, 0);
assert.equal(files.length, 1);
assert.equal(files[0].name, fileName1);

files = [];
directories = [];

fileService.createDirectory(shareName, nextDirectory, function(dirErr2) {
assert.equal(dirErr2, null);

listFilesAndDirectories(shareName, dotdotDirectory, null, function() {
assert.equal(directories.length, 1);
assert.equal(directories[0].name, "next");
assert.equal(files.length, 1);
assert.equal(files[0].name, fileName1);
done();
});
});
});
});
});
});
});

Expand Down
39 changes: 39 additions & 0 deletions test/services/file/fileservice-file-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,45 @@ describe('File', function () {
done();
});

describe('getUrl', function() {
var share = 'share';
var directory = 'directory';
var file = 'file'
it('Directory and file', function(done) {
var url = fileService.getUrl(share, directory, file, true);
var host = fileService.host.primaryHost;
assert.strictEqual(url, host + share + '/' + directory + '/' + file);

url = fileService.getUrl(share, directory, file, false);
host = fileService.host.secondaryHost;
assert.strictEqual(url, host + share + '/' + directory + '/' + file);

done();
});

it('No file', function(done) {
var url = fileService.getUrl(share, directory, null, true);
var host = fileService.host.primaryHost;
assert.strictEqual(url, host + share + '/' + directory);
url = fileService.getUrl(share, directory, '', true);
assert.strictEqual(url, host + share + '/' + directory);

done();
});

it('No directory', function(done) {
var url = fileService.getUrl(share, '', null, true);
var host = fileService.host.primaryHost;
assert.strictEqual(url, host + share);

var url = fileService.getUrl(share, '', file, true);
var host = fileService.host.primaryHost;
assert.strictEqual(url, host + share + '/' + file);

done();
});
});

describe('doesFileExist', function () {
it('should work', function (done) {
fileService.doesFileExist(shareName, directoryName, fileName, function (existsError, exists) {
Expand Down

0 comments on commit 341df62

Please sign in to comment.