Permalink
Browse files

Fixes test runner index.js file, now it runs the 3rd auth tests witho…

…ut problems; Increased documentation and License FreeBSD set
  • Loading branch information...
1 parent ce8ca50 commit 0c8b2259c3d0dd6de84b4b4747afa87ae38435a2 @Rendez committed Oct 24, 2011
Showing with 97 additions and 22 deletions.
  1. +30 −4 Readme.md
  2. BIN dump.rdb
  3. +4 −5 lib/auth.js
  4. +4 −3 lib/client.js
  5. +1 −1 lib/util.js
  6. +2 −2 package.json
  7. +11 −1 test/dropbox/auth.js
  8. +7 −0 test/dropbox/client.js
  9. +17 −4 test/helpers.js
  10. +21 −2 test/index.js
View
@@ -10,10 +10,36 @@ Fully tested against Dropbox API (http://api.dropbox.com & http://api-content.dr
Running Tests
===
Two options:
- * Running $node test/index.js [testfile]
- * Running $node/test dropbox/[testfile]
-__Notes:__ To run the test file __client.js__ two arguments are required: the base64-encoded tokens key and token secret.
+ * `$node test/index.js [testfile]`
+ * `$node/test dropbox/[testfile]`
+
+__Notes:__ To run the test file __client.js__ 2 arguments are required: the base64-encoded tokens key and token secret.
+
+Usage
+===
+`var Auth = require('./node-dropbox/lib/auth');
+var Client = require('./node-dropbox');`
+
+`Auth.loadConfig('myConfigFile.json', function(err, config) {
+ var options = {[...]};
+ var oa = Auth.getInstance(options);
+ var dropbox = new Client(apiHost, contentHost, port, oa, accessToken, accessTokenSecret);`
+`
+ dropbox.getFile(..., callback);
+});`
+
+Public methods
+===
+`* accountInfo(callback)
+* getFile(root, path, callback)
+* putFile(root, path, content, [ctype], [callback])
+* metadata(root, path, fileLimit, hash, list, callback)
+* thumbnail(root, path, size, format, callback)
+* copy(root, fromPath, toPath, callback)
+* createFolder(root, path, callback)
+* delete(root, path, callback)
+* move(root, fromPath, toPath, callback)`
Node Compatibility
===
@@ -27,4 +53,4 @@ Luis Merino <mail AT luismerino DOT name>
License
===
-[FreeBSD License](./License.md)
+[FreeBSD License](License.md)
View
BIN dump.rdb
Binary file not shown.
View
@@ -1,11 +1,11 @@
-/**
+/*!
* Node Dropbox 'Auth' module.
*
* Wrapper for OAuth module instances. Includes utility function for loading
* JSON file containing configuration parameters.
*
- * @copyright Copyright(c) 2011 Luis merino <mail@luismerino.name>
- * @license MIT
+ * Copyright(c) 2011 Luis merino <mail AT luismerino DOT name>
+ * FreeBSD License
*/
/**
@@ -15,7 +15,7 @@
var OAuth = require('node-oauth').OAuth;
/**
- * Fix for POST requests which facilitates sending a body as a string, e.g.
+ * Fixes for POST requests which facilitates sending a body as a string, e.g.
* 'multipart' and add extra oauth parameters at the same time. It removes the
* previous blocking logic limited to just one or the other behavior.
*/
@@ -43,7 +43,6 @@ OAuth.prototype.post = function(url, oauth_token, oauth_token_secret, post_body,
* Returns a new oauth instance using the passed configuration options.
*
* @param {options} object.
- *
* @return {OAuth} object
*/
View
@@ -1,7 +1,8 @@
-/**
+/*!
* Node Dropbox 'Client' module
- * Copyright(c) 2011 Luis merino <mail@luismerino.name>
- * MIT Licensed
+ *
+ * Copyright(c) 2011 Luis merino <mail AT luismerino DOT name>
+ * FreeBSD License
*/
module.exports.VERSION = '0.1.0';
View
@@ -1,7 +1,7 @@
/**
* Node Dropbox 'Util' module
* Copyright(c) 2011 Luis merino <mail@luismerino.name>
- * MIT Licensed
+ * FreeBSD License
*/
/**
View
@@ -3,15 +3,15 @@
description: 'A node.js client for the dropbox API with OAuth 1.0',
keywords: ['dropbox','dropbox-api', 'oauth', 'rest', 'api'],
'dist-tags': {
- latest: '0.1.0'
+ latest: '0.1.1'
},
maintainers: 'Luis Merino <mail@luismerino.name>',
author: 'Luis Merino <mail@luismerino.name>',
repository: {
type: 'git',
url: 'git://github.com/Rendez/node-dropbox.git'
},
- version: '0.1.0',
+ version: '0.1.1',
main: 'index',
engines: {
node: '>=0.4.0'
View
@@ -1,3 +1,10 @@
+/*!
+ * Node Dropbox 'Auth' test module
+ *
+ * Copyright(c) 2011 Luis merino <mail AT luismerino DOT name>
+ * FreeBSD License
+ */
+
require.paths.unshift(__dirname + '/../../support');
var Path = require('path');
@@ -6,6 +13,9 @@ var Auth = require('../../lib/auth');
var Helpers = require('../helpers');
var assert = require('assert');
+/**
+ * Test suite
+ */
var tests = {
name: 'auth',
@@ -102,7 +112,7 @@ var tests = {
}
};
-module.exports = AsyncTest.testcase(tests, 'node-dropbox', 20000);
+var testcase = module.exports = AsyncTest.testcase(tests, 'node-dropbox', 20000);
if (require.main === module) {
module.exports.exec();
View
@@ -1,3 +1,10 @@
+/*!
+ * Node Dropbox 'Client' test module
+ *
+ * Copyright(c) 2011 Luis merino <mail AT luismerino DOT name>
+ * FreeBSD License
+ */
+
require.paths.unshift(__dirname + '/../../support');
var Path = require('path');
View
@@ -1,3 +1,10 @@
+/*!
+ * Node Dropbox test 'Helpers' module
+ *
+ * Copyright(c) 2011 Luis merino <mail AT luismerino DOT name>
+ * FreeBSD License
+ */
+
//var Zombie = require('zombie/lib');
var Auth = require('../lib/auth');
var Client = require('../lib/client');
@@ -31,7 +38,10 @@ module.exports = {
return new Client(apiHost, contentHost, port, auth, accessToken, accessTokenSecret);
},
- // Python's headless browser: uses module 'mechanize.Browser'.
+ /**
+ * Python's headless browser: uses module 'mechanize.Browser'.
+ * @ref Dropbox Python implementation tests.
+ */
loginAndAuthorize: function(authorizationUrl, config, callback) {
Path.exists(__dirname + '/token_authorize.py', function(exists) {
if (!exists)
@@ -52,12 +62,15 @@ module.exports = {
callback(new Error(stream + ''));
});
child.on('exit', function() {
- if (child) callback()
+ if (child) {
+ child.kill();
+ callback();
+ }
});
});
}
- // Zombie (not working, throws JS compiling errors).
+ // Zombie (not working so far, throws JS compiling errors).
/*loginAndAuthorize: function(token, config, callback) {
var url = config.authorizationUrl + '?oauth_token=' + token;
var parsedUrl = Url.parse(config.authorizationUrl);
@@ -93,7 +106,7 @@ module.exports = {
});
}*/
- // Custom mode (unknown mechanism, @todo dropbox team must reveal what requests really need for this to work).
+ // Custom mode (unknown mechanism, @todo dropbox team must reveal what their request really needs, in order for this to work).
/*loginAndAuthorize: function(token, config, callback) {
var url = Url.parse(config.authorizationUrl);
console.log('AUTHORIZING', config.authorizationUrl, token);
View
@@ -1,4 +1,17 @@
-#!/usr/bin/env node
+#!/usr/local/bin/node
+
+/*!
+ * Node Dropbox test runner
+ *
+ * Copyright(c) 2011 Luis merino <mail AT luismerino DOT name>
+ * FreeBSD License
+ */
+
+try {
+ process.chdir(__dirname);
+} catch(e) {
+ throw e;
+}
if (process.argv.length < 3)
return console.error('\n1 argument required. Please, pass the test\'s name as first argument.\n');
@@ -9,7 +22,13 @@ var testName = args.shift().replace(/\-/g, '').trim().toLowerCase();
try {
var testcase = require('./dropbox/' + testName);
} catch(e) {
- return console.error('\nArgument does not match with any named test.\n');
+ console.error('\n\033[33mError: first argument does not match with any named test.');
+ var dirs = require('fs').readdirSync(__dirname + '/dropbox').filter(function(f) {
+ return /\.js$/.test(f);
+ });
+ console.log('\n\033[36m- Available tests:\n\n \033[37m* ' + dirs.join('\n * '));
+ console.log('\nExample: \033[32mnode [test|index.js] ' + dirs.shift() + '\n\033[0m');
+ return;
}
testcase.argv = args;

0 comments on commit 0c8b225

Please sign in to comment.