33 * @todo Finish tests with mocha and remove actual test.js
44 */
55
6- var exec = require ( 'child_process' ) . exec ;
6+ var exec = require ( 'child_process' ) . exec , fs = require ( 'fs' ) ;
77var assert = require ( 'chai' ) . assert ;
88
99describe ( 'Store and Restore TLS cert and keys from Consul KV' , function ( ) {
10-
11- var cmd = './index.js --set --url http://localhost:8500 --fqdn=localhost --cert ./test/localhost.crt --key ./test/localhost.key' ;
10+ var cmd = 'node ./index.js --set --url http://localhost:8500 --fqdn=localhost --cert ./test/localhost.crt --key ./test/localhost.key' ;
1211 //console.log('================================================================================');
1312 //console.log('TEST: set');
1413 //console.log(cmd);
1514
16- it ( 'should save on consul KV' , function ( ) {
15+ it ( 'should save on consul KV' , function ( done ) {
1716 exec ( cmd , function ( error , stdout , stderr ) {
1817 if ( error ) {
1918 console . log ( 'error' , error ) ;
2019 }
2120 if ( stderr ) {
2221 console . log ( 'stderr' , stderr ) ;
2322 }
24- assert ( ! ! error ) ;
25- done ( ) ;
26-
23+ assert ( ! error ) ;
2724 console . log ( stdout ) ;
25+ done ( ) ;
2826 } ) ;
2927 } ) ;
3028
31- it ( 'should restore from consul KV to disk' , function ( ) {
32- var cmd = './index.js --debug --get --url http://localhost:8500 --fqdn=localhost --cert ./test/result-localhost.crt --key ./test/result-localhost.key' ;
29+ it ( 'should restore from consul KV to disk' , function ( done ) {
30+ //var cmd = 'node ./index.js --debug --get --url http://localhost:8500 --fqdn=localhost --cert ./test/result-localhost.crt --key ./test/result-localhost.key';
31+ var cmd = 'node ./index.js --get --url http://localhost:8500 --fqdn=localhost --cert ./test/result-localhost.crt --key ./test/result-localhost.key' ;
3332 //console.log('================================================================================');
3433 //console.log('TEST: get');
3534
@@ -40,15 +39,18 @@ describe('Store and Restore TLS cert and keys from Consul KV', function () {
4039 if ( stderr ) {
4140 console . log ( 'stderr' , stderr ) ;
4241 }
43- assert ( ! ! error ) ;
42+ assert ( ! error ) ;
4443 console . log ( stdout ) ;
4544
4645 done ( ) ;
4746 } ) ;
4847 } ) ;
4948
50- it ( 'files should be equal' , function ( ) {
51-
49+ it ( 'files should be equal: certificate' , function ( ) {
50+ assert ( fs . readFileSync ( './test/localhost.crt' , 'utf8' ) === fs . readFileSync ( './test/result-localhost.crt' , 'utf8' ) ) ;
51+ } ) ;
52+ it ( 'files should be equal: key' , function ( ) {
53+ assert ( fs . readFileSync ( './test/localhost.key' , 'utf8' ) === fs . readFileSync ( './test/result-localhost.key' , 'utf8' ) ) ;
5254 } ) ;
5355} ) ;
5456
0 commit comments