@@ -4,8 +4,9 @@ import { execSync } from 'child_process'
44
55describe ( 'ssh-crypt cli tests' , ( ) => {
66 it ( 'should show help' , ( ) => {
7- const output = execSync ( ` npm exec -- tsx src/cli.ts -h` , {
7+ const output = execSync ( ' npm exec -- tsx src/cli.ts -h' , {
88 encoding : 'utf8' ,
9+ stdio : 'pipe' ,
910 } )
1011 const text =
1112 'Usage: ssh-crypt [options] <command>\n' +
@@ -30,9 +31,11 @@ describe('ssh-crypt cli tests', () => {
3031 } )
3132 it ( 'should encrypt' , ( ) => {
3233 const output = execSync (
33- `echo 'Lorem ipsum dolor' | npm exec -- tsx src/cli.ts -k key_ed25519 -s not_a_secret --encryptEncoding hex encrypt` ,
34+ ' npm exec -- tsx src/cli.ts -k key_ed25519 -s not_a_secret --encryptEncoding hex encrypt' ,
3435 {
3536 encoding : 'ascii' ,
37+ input : 'Lorem ipsum dolor' ,
38+ stdio : 'pipe' ,
3639 } ,
3740 )
3841 chai . assert . strictEqual ( output . length , 96 )
@@ -41,9 +44,11 @@ describe('ssh-crypt cli tests', () => {
4144 const data =
4245 'ecfd6bb57f4891ba7226886e90d2eb848022a495b15ffd91ffe760bca5605f9062c305ee14226d9daf7faa58460c8f50'
4346 const output = execSync (
44- `echo ' ${ data } ' | npm exec -- tsx src/cli.ts -k key_rsa -s not_a_secret --decryptEncoding hex decrypt` ,
47+ ' npm exec -- tsx src/cli.ts -k key_rsa -s not_a_secret --decryptEncoding hex decrypt' ,
4548 {
4649 encoding : 'utf8' ,
50+ input : data ,
51+ stdio : 'pipe' ,
4752 } ,
4853 )
4954 chai . assert . strictEqual ( output , 'Lorem ipsum dolor' )
@@ -53,9 +58,10 @@ describe('ssh-crypt cli tests', () => {
5358 'ecfd6bb57f4891ba7226886e90d2eb848022a495b15ffd91ffe760bca5605f9062c305ee14226d9daf7faa58460c8f50'
5459 chai
5560 . expect ( ( ) =>
56- execSync (
57- `echo '${ data } ' | npm exec -- tsx src/cli.ts -k key_rsa -s wrong_secret --decryptEncoding hex decrypt` ,
58- ) ,
61+ execSync ( 'npm exec -- tsx src/cli.ts -k key_rsa -s wrong_secret --decryptEncoding hex decrypt' , {
62+ input : data ,
63+ stdio : 'pipe' ,
64+ } ) ,
5965 )
6066 . to . throw ( / b a d s e c r e t o r k e y , c a n ' t d e c r y p t / iu)
6167 } )
0 commit comments