Skip to content

Commit

Permalink
Merge pull request #59 from yaxia/master
Browse files Browse the repository at this point in the history
Storage Client Library - 0.4.4
  • Loading branch information
slepox committed May 13, 2015
2 parents 39f8148 + 60ee6d9 commit d51a06d
Show file tree
Hide file tree
Showing 23 changed files with 4,814 additions and 3,847 deletions.
18 changes: 18 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
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.

2015.05 Version 0.4.4

ALL
* Updated the dependency of the 'validator' module to avoid the security vulnerability reported by the 'nsp' tool. (https://nodesecurity.io/advisories/validator-isurl-denial-of-service)
* Updated the error message when an argument is in a wrong type while it requires a string.
* Updated the grunt file to run test with mocha and generate jsDoc.

BLOB
* Fixed an issue that the metadata is duplicated when creating a page blob.
* Fixed an issue that the metadata is duplicated when setting blob's metadata with metadata in the options.
* Fixed an issue that cannot create an empty block blob with useTransactionalMD5 option.

FILE
* Fixed an issue that the result of file downloading contains wrong values for share, directory or file names.

TABLE
* Fixed an issue that it prompts "Cannot set property 'isSuccessful' of null" when TableService.createTableIfNotExists is called.

2015.03 Version 0.4.3

ALL
Expand Down
48 changes: 36 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This project provides a Node.js package that makes it easy to consume and manage

## Install

```
```shell
npm install azure-storage
```

Expand All @@ -39,7 +39,7 @@ var azure = require('azure-storage');

When using the Storage SDK, you must provide connection information for the storage account to use. This can be provided using:

* Environment variables - AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY, or AZURE_STORAGE_CONNECTION_STRING.
* Environment variables - **AZURE_STORAGE_ACCOUNT** and **AZURE_STORAGE_ACCESS_KEY**, or **AZURE_STORAGE_CONNECTION_STRING**.

* Constructors - For example, `var tableSvc = azure.createTableService(accountName, accountKey);`

Expand Down Expand Up @@ -302,39 +302,63 @@ How-Tos focused around accomplishing specific tasks are available on the [Micros

# Running Tests

In order to run the tests, the following environment variables need to be set up:
Unit tests can then be run from the module's root directory using:

```shell
npm test
```
AZURE_STORAGE_CONNECTION_STRING="valid storage connection string"

Running test is also supported by Grunt by:

```shell
grunt # mochaTest as the default task
```

or
By default the unit tests are ran with Nock recording data. To run tests against real storage account, please set environment variable to turn off Nock by:

```
AZURE_STORAGE_ACCOUNT="valid storage account name"
AZURE_STORAGE_ACCESS_KEY="valid storage account key"
set NOCK_OFF=true
```

In order to be able to use a proxy like fiddler, an additional environment variable should be set up:
and set up the following environment variables for storage account credentials by

```Batchfile
set AZURE_STORAGE_CONNECTION_STRING="valid storage connection string"
```
HTTP_PROXY=http://127.0.0.1:8888
or
```Batchfile
set AZURE_STORAGE_ACCOUNT="valid storage account name"
set AZURE_STORAGE_ACCESS_KEY="valid storage account key"
```

The tests can then be run from the module's root directory using:
To record the data in a test pass against real storage account for future Nock usage:

```Batchfile
set AZURE_NOCK_RECORD=true
```
npm test

In order to be able to use a proxy like fiddler, an additional environment variable should be set up:

```Batchfile
set HTTP_PROXY=http://127.0.0.1:8888
```

On Linux, please use `export` other than `set` to set the variables.

# JsDoc

JsDoc can be generated by `grunt jsdoc`.

To load the docs by devserver after generation, run `grunt doc` and then browse the docs at [http://localhost:8888](http://localhost:8888).

# Need Help?

Be sure to check out the Microsoft Azure [Developer Forums on MSDN](http://go.microsoft.com/fwlink/?LinkId=234489) if you have trouble with the provided code or use StackOverflow.

# Learn More

- [Microsoft Azure Node.js Developer Center](http://azure.microsoft.com/en-us/develop/nodejs/)
- [Azure Storage Team Blog] (http://blogs.msdn.com/b/windowsazurestorage/)
- [Azure Storage Team Blog](http://blogs.msdn.com/b/windowsazurestorage/)

# Contribute

Expand Down
82 changes: 47 additions & 35 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,61 @@
module.exports = function(grunt) {
//init stuff
grunt.initConfig({
downloadNuGet: {
path : '.nuget',
src : 'http://www.nuget.org/nuget.exe'
pkg: grunt.file.readJSON('package.json'),

mochaTest: {
test: {
options: {
reporter: 'spec',
quiet: false,
clearRequireCache: false
},
src: ['test/**/*.js']
}
},

//jsdoc config
jsdoc : {
dist : {
src: [
"README.md",
"lib/azure-storage.js",
"lib/common/filters/retrypolicyfilter.js",
"lib/common/filters/linearretrypolicyfilter.js",
"lib/common/filters/exponentialretrypolicyfilter.js",
"lib/common/services/storageutilities.js",
"lib/common/util/date.js",
"lib/services/blob/blobservice.js",
"lib/services/blob/blobutilities.js",
"lib/services/queue/queueservice.js",
"lib/services/queue/queueutilities.js",
"lib/services/table/tableservice.js",
"lib/services/table/tablebatch.js",
"lib/services/table/tablequery.js",
"lib/services/table/tableutilities.js"
],
options: {
destination: 'docs',
template : 'node_modules/ink-docstrap/template',
configure: 'jsdoc/jsdoc.json'
}
jsdoc: {
dist: {
src: [
"README.md",
"lib/azure-storage.js",
"lib/common/filters/retrypolicyfilter.js",
"lib/common/filters/linearretrypolicyfilter.js",
"lib/common/filters/exponentialretrypolicyfilter.js",
"lib/common/services/storageutilities.js",
"lib/services/blob/blobservice.js",
"lib/services/blob/blobutilities.js",
"lib/services/queue/queueservice.js",
"lib/services/queue/queueutilities.js",
"lib/services/table/tableservice.js",
"lib/services/table/tablebatch.js",
"lib/services/table/tablequery.js",
"lib/services/table/tableutilities.js",
"lib/services/file/fileservice.js",
"lib/services/file/fileutilities.js",
],
options: {
destination: 'docs',
template: "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template",
configure: "jsdoc/jsdoc.json"
}
}
},
devserver: { options:
{ 'type' : 'http',
'port' : 8888,
'base' : 'docs'

// devserver config
devserver: {
server : {},
options: {
'base': 'docs'
}
}
});

grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-devserver');

grunt.loadTasks('tasks');

grunt.registerTask('publishdocs', ['githubPages:target']);
};
grunt.registerTask('default', ['mochaTest']);
grunt.registerTask('doc', ['jsdoc', 'devserver']);
};
35 changes: 19 additions & 16 deletions jsdoc/jsdoc.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
{
"tags" : {
"tags" : {
"allowUnknownTags" : true
},
"plugins" : [ "plugins/markdown" ],
"plugins" : ["plugins/markdown"],

"templates" : {
"cleverLinks" : false,
"monospaceLinks" : false,
"default" : {
"outputSourceFiles" : true
},
"systemName" : "Azure Storage SDK",
"footer" : "",
"navType" : "horizontal",
"theme" : "cerulean",
"linenums" : true,
"collapseSymbols" : false,
"inverseNav" : true,
"cleverLinks" : false,
"monospaceLinks" : false,
"dateFormat" : "ddd MMM Do YYYY",
"outputSourceFiles" : true,
"outputSourcePath" : true,
"systemName" : "Microsoft Azure Storage Client Library for node.js",
"footer" : "",
"navType" : "vertical",
"theme" : "cosmo",
"linenums" : true,
"collapseSymbols" : false,
"inverseNav" : true,
"highlightTutorialCode" : false,
"protocol": "fred://"
},
"markdown" : {
"parser" : "gfm",
"markdown" : {
"parser" : "gfm",
"hardwrap" : true
}
}
3 changes: 3 additions & 0 deletions lib/common/signing/sharedaccesssignature.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//
var HmacSha256Sign = require('./hmacsha256sign');
var Constants = require('./../util/constants');
var SR = require('./../util/sr');

/**
* Creates a new SharedAccessSignature object.
Expand Down Expand Up @@ -47,6 +48,8 @@ SharedAccessSignature.prototype.signRequest = function (webResource, callback) {
// Add the api-version
if (this.sasToken.indexOf('api-version') == -1) {
webResource.uri += '&' + Constants.QueryStringConstants.API_VERSION + '=' + Constants.HeaderConstants.TARGET_STORAGE_VERSION;
} else {
throw new Error(SR.INVALID_SAS_TOKEN);
}
callback(null);
};
Expand Down
6 changes: 3 additions & 3 deletions lib/common/signing/sharedkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var Constants = require('../util/constants');
var HeaderConstants = Constants.HeaderConstants;
var QueryStringConstants = Constants.QueryStringConstants;
var HeaderConstants = Constants.HeaderConstants;
var VersionConstants = Constants.VersionConstants;
var CompatibleVersionConstants = Constants.CompatibleVersionConstants;

/**
* Creates a new SharedKey object.
Expand Down Expand Up @@ -188,7 +188,7 @@ SharedKey.prototype.generateSignedQueryString = function (path, sharedAccessPoli
if (azureutil.objectIsNull(sasVersion)) {
return HeaderConstants.TARGET_STORAGE_VERSION;
} else {
var values = _.values(VersionConstants);
var values = _.values(CompatibleVersionConstants);
if (values.some(function(version) {
return version.toLowerCase() === sasVersion.toLowerCase();
})) {
Expand Down Expand Up @@ -333,7 +333,7 @@ SharedKey.prototype._generateSignature = function (path, sharedAccessPolicy, sas
getvalueToAppend(sharedAccessPolicy.Id) +
sasVersion;

if(sasVersion == VersionConstants.FEBRUARY_2012) {
if(sasVersion == CompatibleVersionConstants.FEBRUARY_2012) {
if(headers) {
throw new Error(SR.INVALID_HEADERS);
}
Expand Down
12 changes: 2 additions & 10 deletions 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.4.3',
USER_AGENT_PRODUCT_VERSION: '0.4.4',

/**
* The number of default concurrent requests for parallel operation.
Expand Down Expand Up @@ -1995,15 +1995,7 @@ var Constants = {
}
},

VersionConstants: {
/**
* Constant for the 2014-02-14 version.
*
* @const
* @type {string}
*/
FEBRUARY_2014: '2014-02-14',

CompatibleVersionConstants: {
/**
* Constant for the 2013-08-15 version.
*
Expand Down
1 change: 1 addition & 0 deletions lib/common/util/sr.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var SR = {
INVALID_PROPERTY_RESOLVER: 'The specified property resolver returned an invalid type. %s:{_:%s,$:%s }',
INVALID_RANGE_FOR_MD5: 'The requested range should be less than 4MB when contentMD5 is expected from the server',
INVALID_SAS_VERSION: 'SAS Version ? is invalid. Valid versions include: ?.',
INVALID_SAS_TOKEN: 'The SAS token should not contain api-version.',
INVALID_SIGNED_IDENTIFIERS: 'Signed identifiers need to be an array.',
INVALID_STREAM_LENGTH: 'The length of the provided stream is invalid.',
INVALID_STRING_ERROR: 'Invalid string error.',
Expand Down
8 changes: 4 additions & 4 deletions lib/common/util/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,20 @@ function ArgumentValidator(functionName) {
_.extend(ArgumentValidator.prototype, {
string: function (val, name) {
this.exists(val, name);
if (typeof val != 'string') {
if (typeof val !== 'string') {
throw new Error('Parameter ' + name + ' for function ' + this.func + ' should be a non-empty string');
}
},

stringAllowEmpty: function (val, name) {
if (typeof val != 'string') {
throwMissingArgument(name, this.func);
if (typeof val !== 'string') {
throw new Error('Parameter ' + name + ' for function ' + this.func + ' should be a string');
}
},

object: function (val, name) {
this.exists(val, name);
if (typeof val != 'object') {
if (typeof val !== 'object') {
throw new Error('Parameter ' + name + ' for function ' + this.func + ' should be an object');
}
},
Expand Down
Loading

0 comments on commit d51a06d

Please sign in to comment.