@@ -29,63 +29,46 @@ describe("pgp", () => {
29
29
it ( "cannot read non-existent signature" , async ( ) => {
30
30
const armoredKeys = await fs . readFile ( publicKeysPath , "utf8" ) ;
31
31
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" ) ;
40
39
} ) ;
41
40
42
41
it ( "cannot read invalid signature" , async ( ) => {
43
42
const armoredKeys = await fs . readFile ( publicKeysPath , "utf8" ) ;
44
43
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" ) ;
53
47
} ) ;
54
48
55
49
it ( "cannot read file" , async ( ) => {
56
50
const armoredKeys = await fs . readFile ( publicKeysPath , "utf8" ) ;
57
51
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" ) ;
66
59
} ) ;
67
60
68
61
it ( "mismatched signature" , async ( ) => {
69
62
const armoredKeys = await fs . readFile ( publicKeysPath , "utf8" ) ;
70
63
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" ) ;
79
67
} ) ;
80
68
81
69
it ( "verifies signature" , async ( ) => {
82
70
const armoredKeys = await fs . readFile ( publicKeysPath , "utf8" ) ;
83
71
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 ) ;
90
73
} ) ;
91
74
} ) ;
0 commit comments