Permalink
Browse files

API bugs. Fixes GH-35.

Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
  • Loading branch information...
1 parent 8429696 commit c4b6318a730e9de45d6f90492f84201af68fd37e @ncb000gt ncb000gt committed Sep 26, 2011
Showing with 11 additions and 5 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 package.json
  3. +4 −3 src/bcrypt_node.cc
  4. +5 −1 test/async.js
View
@@ -2,3 +2,4 @@
build
*.node
*.sw[a-z]
+node_modules
View
@@ -3,7 +3,7 @@
"description": "A bcrypt library for NodeJS.",
"keywords": ["bcrypt","password","auth","authentication","encryption","crypt","crypto"],
"main": "./bcrypt",
- "version": "0.3.1",
+ "version": "0.3.2",
"author": "Nick Campbell (http://github.com/ncb000gt)",
"engines": { "node": ">= 0.4.0" },
"repository": {
View
@@ -215,8 +215,6 @@ Handle<Value> GenerateSalt(const Arguments &args) {
} else {
return ThrowException(Exception::Error(String::New("No callback supplied.")));
}
- } else {
- return ThrowException(Exception::Error(String::New("No callback supplied.")));
}
salt_request *s_req = (salt_request *)malloc(sizeof(*s_req));
@@ -239,13 +237,16 @@ Handle<Value> GenerateSaltSync(const Arguments& args) {
HandleScope scope;
int size = 20;
+ ssize_t rounds = 10;
if (args.Length() < 1) {
return ThrowException(Exception::Error(String::New("Must give number of rounds.")));
} else if (!args[0]->IsNumber()) {
return ThrowException(Exception::Error(String::New("Param must be a number.")));
}
- ssize_t rounds = args[0]->Int32Value();
+ if (args.Length() > 0 && args[0]->IsNumber()) {
+ rounds = args[0]->Int32Value();
+ }
if (args.Length() > 1 && args[1]->IsNumber()) {
size = args[1]->Int32Value();
}
View
@@ -10,7 +10,11 @@ module.exports = testCase({
});
},
test_salt_no_params: function(assert) {
- assert.throws(function() {bcrypt.gen_salt();}, "Should throw an Error. gen_salt requires # of rounds.");
+ assert.throws(function() {bcrypt.gen_salt();}, "Should throw an Error. gen_salt requires a callback.");
+ assert.done();
+ },
+ test_salt_only_cb: function(assert) {
+ assert.doesNotThrow(function() {bcrypt.gen_salt(function(err, salt) {});}, "Should not throw an Error. Rounds and seed length are optional.");
assert.done();
},
test_salt_rounds_is_string_number: function(assert) {

0 comments on commit c4b6318

Please sign in to comment.