Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Feb 24, 2015
1 parent 9f41662 commit 5034d3e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 23 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
@@ -1,9 +1,10 @@
language: node_js
node_js:
- 0.8
- "0.10"
- "0.11"

- 0.12
- iojs
before_install:
- npm install -g grunt-cli
notifications:
email:
recipients:
Expand Down
24 changes: 24 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,24 @@
'use strict';

module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
jshint: {
all: ['lib/*.js', 'test/*.js', 'Gruntfile.js'],
options: {
jshintrc: '.jshintrc'
}
},

nodeunit: {
all: 'test/pem.js'
}
});

// Load the plugin(s)
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-nodeunit');

// Tasks
grunt.registerTask('default', ['jshint', 'nodeunit']);
};
32 changes: 16 additions & 16 deletions lib/pem.js
@@ -1,14 +1,14 @@
'use strict';

var spawn = require('child_process').spawn,
os = require('os'),
pathlib = require('path'),
fs = require('fs'),
net = require('net'),
crypto = require('crypto'),
which = require('which'),
pathOpenSSL,
tempDir = process.env.PEMJS_TMPDIR || (os.tmpdir || os.tmpDir) && (os.tmpdir || os.tmpDir)() || '/tmp';
var spawn = require('child_process').spawn;
var os = require('os');
var pathlib = require('path');
var fs = require('fs');
var net = require('net');
var crypto = require('crypto');
var which = require('which');
var pathOpenSSL;
var tempDir = process.env.PEMJS_TMPDIR || (os.tmpdir || os.tmpDir) && (os.tmpdir || os.tmpDir)() || '/tmp';

module.exports.createPrivateKey = createPrivateKey;
module.exports.createDhparam = createDhparam;
Expand Down Expand Up @@ -59,7 +59,7 @@ function createPrivateKey(keyBitsize, callback) {
* @param {Number} [keyBitsize=512] Size of the key, defaults to 512bit
* @param {Function} callback Callback function with an error object and {dhparam}
*/
function createDhparam (keyBitsize, callback) {
function createDhparam(keyBitsize, callback) {
if (!callback && typeof keyBitsize === 'function') {
callback = keyBitsize;
keyBitsize = undefined;
Expand Down Expand Up @@ -412,20 +412,20 @@ function config(options) {
* @param {Function} callback Callback function with an error object and {fingerprint}
*/
function getFingerprint(certificate, hash, callback) {
if (!callback && typeof hash === 'function') {

if (!callback && typeof hash === 'function') {
callback = hash;
hash = undefined;
}
hash = hash || 'sha1';

hash = hash || 'sha1';

var params = ['x509',
'-in',
'--TMPFILE--',
'-fingerprint',
'-noout',
'-'+hash
'-' + hash
];

spawnWrapper(params, certificate, function(err, code, stdout) {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -9,13 +9,15 @@
},
"main": "lib/pem",
"scripts": {
"test": "nodeunit test"
"test": "grunt"
},
"dependencies": {
"which": "~1.0.8"
},
"devDependencies": {
"nodeunit": "*"
"grunt": "^0.4.5",
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-nodeunit": "^0.4.1"
},
"optionalDependencies": {},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions test/pem.js
Expand Up @@ -11,7 +11,7 @@ try {

exports['General Tests'] = {

'Create default sized dhparam key': function(test) {
'Create default sized dhparam key': function(test) {
pem.createDhparam(function(error, data) {
var dhparam = (data && data.dhparam || '').toString();
test.ifError(error);
Expand All @@ -36,7 +36,7 @@ exports['General Tests'] = {
test.done();
});
},

'Create default sized Private key': function(test) {
pem.createPrivateKey(function(error, data) {
var key = (data && data.key || '').toString();
Expand Down

0 comments on commit 5034d3e

Please sign in to comment.