@@ -29,63 +29,46 @@ describe("pgp", () => {
2929 it ( "cannot read non-existent signature" , async ( ) => {
3030 const armoredKeys = await fs . readFile ( publicKeysPath , "utf8" ) ;
3131 const publicKeys = await openpgp . readKeys ( { armoredKeys } ) ;
32- const result = await pgp . verifySignature (
33- publicKeys ,
34- cliPath ,
35- path . join ( __dirname , "does-not-exist" ) ,
36- ) ;
37- expect ( ( result as pgp . VerificationError ) . code ) . toBe (
38- pgp . VerificationErrorCode . Read ,
39- ) ;
32+ await expect (
33+ pgp . verifySignature (
34+ publicKeys ,
35+ cliPath ,
36+ path . join ( __dirname , "does-not-exist" ) ,
37+ ) ,
38+ ) . rejects . toThrow ( "Failed to read" ) ;
4039 } ) ;
4140
4241 it ( "cannot read invalid signature" , async ( ) => {
4342 const armoredKeys = await fs . readFile ( publicKeysPath , "utf8" ) ;
4443 const publicKeys = await openpgp . readKeys ( { armoredKeys } ) ;
45- const result = await pgp . verifySignature (
46- publicKeys ,
47- cliPath ,
48- invalidSignaturePath ,
49- ) ;
50- expect ( ( result as pgp . VerificationError ) . code ) . toBe (
51- pgp . VerificationErrorCode . Read ,
52- ) ;
44+ await expect (
45+ pgp . verifySignature ( publicKeys , cliPath , invalidSignaturePath ) ,
46+ ) . rejects . toThrow ( "Failed to read" ) ;
5347 } ) ;
5448
5549 it ( "cannot read file" , async ( ) => {
5650 const armoredKeys = await fs . readFile ( publicKeysPath , "utf8" ) ;
5751 const publicKeys = await openpgp . readKeys ( { armoredKeys } ) ;
58- const result = await pgp . verifySignature (
59- publicKeys ,
60- path . join ( __dirname , "does-not-exist" ) ,
61- validSignaturePath ,
62- ) ;
63- expect ( ( result as pgp . VerificationError ) . code ) . toBe (
64- pgp . VerificationErrorCode . Read ,
65- ) ;
52+ await expect (
53+ pgp . verifySignature (
54+ publicKeys ,
55+ path . join ( __dirname , "does-not-exist" ) ,
56+ validSignaturePath ,
57+ ) ,
58+ ) . rejects . toThrow ( "Failed to read" ) ;
6659 } ) ;
6760
6861 it ( "mismatched signature" , async ( ) => {
6962 const armoredKeys = await fs . readFile ( publicKeysPath , "utf8" ) ;
7063 const publicKeys = await openpgp . readKeys ( { armoredKeys } ) ;
71- const result = await pgp . verifySignature (
72- publicKeys ,
73- __filename ,
74- validSignaturePath ,
75- ) ;
76- expect ( ( result as pgp . VerificationError ) . code ) . toBe (
77- pgp . VerificationErrorCode . Invalid ,
78- ) ;
64+ await expect (
65+ pgp . verifySignature ( publicKeys , __filename , validSignaturePath ) ,
66+ ) . rejects . toThrow ( "Unable to verify" ) ;
7967 } ) ;
8068
8169 it ( "verifies signature" , async ( ) => {
8270 const armoredKeys = await fs . readFile ( publicKeysPath , "utf8" ) ;
8371 const publicKeys = await openpgp . readKeys ( { armoredKeys } ) ;
84- const result = await pgp . verifySignature (
85- publicKeys ,
86- cliPath ,
87- validSignaturePath ,
88- ) ;
89- expect ( result ) . toBe ( true ) ;
72+ await pgp . verifySignature ( publicKeys , cliPath , validSignaturePath ) ;
9073 } ) ;
9174} ) ;
0 commit comments