1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-23 01:12:19 -05:00

added grunt test runner

This commit is contained in:
Tankred Hase 2013-05-21 15:38:18 +02:00
parent f9461aaf25
commit b77affb86a
4 changed files with 72 additions and 7 deletions

25
Gruntfile.js Normal file
View File

@ -0,0 +1,25 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
all: ['Gruntfile.js', 'src/js/**/*.js']
},
qunit: {
all: {
options: {
urls: ['http://localhost:8580/unit/index.html']
}
}
}
});
// Load the plugin(s)
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
// Default task(s).
grunt.registerTask('test', ['jshint', 'qunit']);
};

View File

@ -5,10 +5,17 @@
"node": ">=0.8" "node": ">=0.8"
}, },
"scripts": { "scripts": {
"postinstall": "./res/copy-deps.sh" "preinstall": "rm -rf node_modules/",
"postinstall": "./res/copy-deps.sh",
"test": "test/test.sh"
}, },
"dependencies": { "dependencies": {
"express": "latest", "express": "latest",
"crypto-lib": "https://github.com/whiteout-io/crypto-lib/tarball/master" "crypto-lib": "https://github.com/whiteout-io/crypto-lib/tarball/master"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.5.3",
"grunt-contrib-qunit": "~0.2.1"
} }
} }

View File

@ -6,7 +6,7 @@ var RSA = function(forge, util) {
var utl = forge.util; var utl = forge.util;
var keypair = null; var keypair = {};
/** /**
* Initializes the RSA module by passing the user's keypair * Initializes the RSA module by passing the user's keypair
@ -14,13 +14,15 @@ var RSA = function(forge, util) {
* and signing * and signing
*/ */
this.init = function(pubkeyPem, privkeyPem, keyId) { this.init = function(pubkeyPem, privkeyPem, keyId) {
keypair = { if (pubkeyPem) {
_id: keyId, keypair.publicKey = forge.pki.publicKeyFromPem(pubkeyPem);
publicKey: forge.pki.publicKeyFromPem(pubkeyPem) }
};
if (privkeyPem) { if (privkeyPem) {
keypair.privateKey = forge.pki.privateKeyFromPem(privkeyPem); keypair.privateKey = forge.pki.privateKeyFromPem(privkeyPem);
} }
if (keyId) {
keypair._id = keyId;
}
}; };
/** /**
@ -43,7 +45,11 @@ var RSA = function(forge, util) {
// generate unique keypair ID // generate unique keypair ID
keypair._id = util.UUID(); keypair._id = util.UUID();
callback(); callback(null, {
_id: keypair._id,
pubkeyPem: forge.pki.publicKeyToPem(keypair.publicKey),
privkeyPem: forge.pki.privateKeyToPem(keypair.privateKey)
});
}); });
}; };

27
test/test.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
# go to root
cd `dirname $0`
cd ..
PORT=8580
# start server for integration tests
echo "--> starting test server...\n"
PORT=$PORT node server.js --dev &
# get process id
PID=$!
# wait the service to init
sleep 1
# run integration tests
echo "\n--> run tests via grunt...\n"
grunt test
# stop server for integration tests
echo "\n--> stoping test server..."
# wait for request to terminate
sleep 0.5
# kill server process
kill $PID
echo "\n--> all done!\n"