mirror of
https://github.com/moparisthebest/mail
synced 2024-11-22 17:02:17 -05:00
added grunt test runner
This commit is contained in:
parent
f9461aaf25
commit
b77affb86a
25
Gruntfile.js
Normal file
25
Gruntfile.js
Normal 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']);
|
||||
|
||||
};
|
@ -5,10 +5,17 @@
|
||||
"node": ">=0.8"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "./res/copy-deps.sh"
|
||||
"preinstall": "rm -rf node_modules/",
|
||||
"postinstall": "./res/copy-deps.sh",
|
||||
"test": "test/test.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "latest",
|
||||
"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"
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ var RSA = function(forge, util) {
|
||||
|
||||
var utl = forge.util;
|
||||
|
||||
var keypair = null;
|
||||
var keypair = {};
|
||||
|
||||
/**
|
||||
* Initializes the RSA module by passing the user's keypair
|
||||
@ -14,13 +14,15 @@ var RSA = function(forge, util) {
|
||||
* and signing
|
||||
*/
|
||||
this.init = function(pubkeyPem, privkeyPem, keyId) {
|
||||
keypair = {
|
||||
_id: keyId,
|
||||
publicKey: forge.pki.publicKeyFromPem(pubkeyPem)
|
||||
};
|
||||
if (pubkeyPem) {
|
||||
keypair.publicKey = forge.pki.publicKeyFromPem(pubkeyPem);
|
||||
}
|
||||
if (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
|
||||
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
27
test/test.sh
Executable 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"
|
Loading…
Reference in New Issue
Block a user