@@ -6,9 +6,10 @@ var temp = require('temp').track()
6
6
7
7
var describe = global . describe
8
8
var it = global . it
9
+ var timeout = process . env . CI ? 60000 : 30000
9
10
10
11
describe ( 'signcode' , function ( ) {
11
- this . timeout ( 30000 )
12
+ this . timeout ( timeout )
12
13
13
14
describe ( '.sign(options)' , function ( ) {
14
15
it ( 'signs the executable with a cert/key pem pair' , function ( done ) {
@@ -133,7 +134,46 @@ describe('signcode', function () {
133
134
}
134
135
135
136
signcode . sign ( options , function ( error ) {
136
- assert ( error . message . length > 0 )
137
+ assert ( error instanceof Error )
138
+ assert . notEqual ( error . message . indexOf ( 'Failed to read private key file' ) , - 1 )
139
+ done ( )
140
+ } )
141
+ } )
142
+
143
+ it ( 'calls back with an error when a file with an incorrect password is specified' , function ( done ) {
144
+ var tempPath = temp . path ( { suffix : '.exe' } )
145
+ fs . writeFileSync ( tempPath , fs . readFileSync ( path . join ( __dirname , 'fixtures' , 'electron.exe' ) ) )
146
+
147
+ var options = {
148
+ cert : path . join ( __dirname , 'fixtures' , 'cert-with-pw.pem' ) ,
149
+ hash : [ 'sha1' , 'sha256' ] ,
150
+ key : path . join ( __dirname , 'fixtures' , 'key-with-pw.pem' ) ,
151
+ passwordPath : path . join ( __dirname , 'fixtures' , 'bad-password.txt' ) ,
152
+ path : tempPath
153
+ }
154
+
155
+ signcode . sign ( options , function ( error ) {
156
+ assert ( error instanceof Error )
157
+ assert . notEqual ( error . message . indexOf ( 'Failed to read private key file' ) , - 1 )
158
+ done ( )
159
+ } )
160
+ } )
161
+
162
+ it ( 'calls back with an error when a non-existent password file is specified' , function ( done ) {
163
+ var tempPath = temp . path ( { suffix : '.exe' } )
164
+ fs . writeFileSync ( tempPath , fs . readFileSync ( path . join ( __dirname , 'fixtures' , 'electron.exe' ) ) )
165
+
166
+ var options = {
167
+ cert : path . join ( __dirname , 'fixtures' , 'cert-with-pw.pem' ) ,
168
+ hash : [ 'sha1' , 'sha256' ] ,
169
+ key : path . join ( __dirname , 'fixtures' , 'key-with-pw.pem' ) ,
170
+ passwordPath : path . join ( __dirname , 'fixtures' , 'not-password.txt' ) ,
171
+ path : tempPath
172
+ }
173
+
174
+ signcode . sign ( options , function ( error ) {
175
+ assert ( error instanceof Error )
176
+ assert . notEqual ( error . message . indexOf ( 'Failed to open password file' ) , - 1 )
137
177
done ( )
138
178
} )
139
179
} )
@@ -149,8 +189,8 @@ describe('signcode', function () {
149
189
}
150
190
151
191
signcode . sign ( options , function ( error ) {
152
- assert ( error . message . length > 0 )
153
- assert . notEqual ( - 1 , error . message . indexOf ( 'Failed to read certificate file' ) )
192
+ assert ( error instanceof Error )
193
+ assert . notEqual ( error . message . indexOf ( 'Failed to read certificate file' ) , - 1 )
154
194
done ( )
155
195
} )
156
196
} )
@@ -166,8 +206,8 @@ describe('signcode', function () {
166
206
}
167
207
168
208
signcode . sign ( options , function ( error ) {
169
- assert ( error . message . length > 0 )
170
- assert . notEqual ( - 1 , error . message . indexOf ( 'Failed to read private key file' ) )
209
+ assert ( error instanceof Error )
210
+ assert . notEqual ( error . message . indexOf ( 'Failed to read private key file' ) , - 1 )
171
211
done ( )
172
212
} )
173
213
} )
@@ -195,6 +235,7 @@ describe('signcode', function () {
195
235
path : path . join ( __dirname , 'fixtures' , 'electron.exe' )
196
236
}
197
237
signcode . verify ( verifyOptions , function ( error ) {
238
+ assert ( error instanceof Error )
198
239
assert . equal ( error . message , 'No signature found' )
199
240
done ( )
200
241
} )
@@ -206,6 +247,7 @@ describe('signcode', function () {
206
247
path : path . join ( __dirname , 'fixtures' , 'electron-signed.exe' )
207
248
}
208
249
signcode . verify ( verifyOptions , function ( error ) {
250
+ assert ( error instanceof Error )
209
251
assert . equal ( error . message , 'Leaf hash match failed' )
210
252
done ( )
211
253
} )
0 commit comments