@@ -23,14 +23,20 @@ describe('Security Check', () => {
23
23
await reconfigureServer ( config ) ;
24
24
}
25
25
26
- const securityRequest = ( options ) => request ( Object . assign ( {
27
- url : securityUrl ,
28
- headers : {
29
- 'X-Parse-Master-Key' : Parse . masterKey ,
30
- 'X-Parse-Application-Id' : Parse . applicationId ,
31
- } ,
32
- followRedirects : false ,
33
- } , options ) ) . catch ( e => e ) ;
26
+ const securityRequest = options =>
27
+ request (
28
+ Object . assign (
29
+ {
30
+ url : securityUrl ,
31
+ headers : {
32
+ 'X-Parse-Master-Key' : Parse . masterKey ,
33
+ 'X-Parse-Application-Id' : Parse . applicationId ,
34
+ } ,
35
+ followRedirects : false ,
36
+ } ,
37
+ options
38
+ )
39
+ ) . catch ( e => e ) ;
34
40
35
41
beforeEach ( async ( ) => {
36
42
groupName = 'Example Group Name' ;
@@ -41,7 +47,7 @@ describe('Security Check', () => {
41
47
solution : 'TestSolution' ,
42
48
check : ( ) => {
43
49
return true ;
44
- }
50
+ } ,
45
51
} ) ;
46
52
checkFail = new Check ( {
47
53
group : 'TestGroup' ,
@@ -50,14 +56,14 @@ describe('Security Check', () => {
50
56
solution : 'TestSolution' ,
51
57
check : ( ) => {
52
58
throw 'Fail' ;
53
- }
59
+ } ,
54
60
} ) ;
55
61
Group = class Group extends CheckGroup {
56
62
setName ( ) {
57
63
return groupName ;
58
64
}
59
65
setChecks ( ) {
60
- return [ checkSuccess , checkFail ] ;
66
+ return [ checkSuccess , checkFail ] ;
61
67
}
62
68
} ;
63
69
config = {
@@ -154,7 +160,7 @@ describe('Security Check', () => {
154
160
title : 'string' ,
155
161
warning : 'string' ,
156
162
solution : 'string' ,
157
- check : ( ) => { }
163
+ check : ( ) => { } ,
158
164
} ,
159
165
{
160
166
group : 'string' ,
@@ -203,7 +209,9 @@ describe('Security Check', () => {
203
209
title : 'string' ,
204
210
warning : 'string' ,
205
211
solution : 'string' ,
206
- check : ( ) => { throw 'error' } ,
212
+ check : ( ) => {
213
+ throw 'error' ;
214
+ } ,
207
215
} ) ;
208
216
expect ( check . _checkState == CheckState . none ) ;
209
217
check . run ( ) ;
@@ -277,7 +285,7 @@ describe('Security Check', () => {
277
285
} ) ;
278
286
279
287
it ( 'runs all checks of all groups' , async ( ) => {
280
- const checkGroups = [ Group , Group ] ;
288
+ const checkGroups = [ Group , Group ] ;
281
289
const runner = new CheckRunner ( { checkGroups } ) ;
282
290
const report = await runner . run ( ) ;
283
291
expect ( report . report . groups [ 0 ] . checks [ 0 ] . state ) . toBe ( CheckState . success ) ;
@@ -287,27 +295,27 @@ describe('Security Check', () => {
287
295
} ) ;
288
296
289
297
it ( 'reports correct default syntax version 1.0.0' , async ( ) => {
290
- const checkGroups = [ Group ] ;
298
+ const checkGroups = [ Group ] ;
291
299
const runner = new CheckRunner ( { checkGroups, enableCheckLog : true } ) ;
292
300
const report = await runner . run ( ) ;
293
301
expect ( report ) . toEqual ( {
294
302
report : {
295
- version : " 1.0.0" ,
296
- state : " fail" ,
303
+ version : ' 1.0.0' ,
304
+ state : ' fail' ,
297
305
groups : [
298
306
{
299
- name : " Example Group Name" ,
300
- state : " fail" ,
307
+ name : ' Example Group Name' ,
308
+ state : ' fail' ,
301
309
checks : [
302
310
{
303
- title : " TestTitleSuccess" ,
304
- state : " success" ,
311
+ title : ' TestTitleSuccess' ,
312
+ state : ' success' ,
305
313
} ,
306
314
{
307
- title : " TestTitleFail" ,
308
- state : " fail" ,
309
- warning : " TestWarning" ,
310
- solution : " TestSolution" ,
315
+ title : ' TestTitleFail' ,
316
+ state : ' fail' ,
317
+ warning : ' TestWarning' ,
318
+ solution : ' TestSolution' ,
311
319
} ,
312
320
] ,
313
321
} ,
@@ -316,12 +324,17 @@ describe('Security Check', () => {
316
324
} ) ;
317
325
} ) ;
318
326
319
- it ( 'logs report' , async ( ) => {
327
+ fit ( 'logs report' , async ( ) => {
320
328
const logger = require ( '../lib/logger' ) . logger ;
321
329
const logSpy = spyOn ( logger , 'warn' ) . and . callThrough ( ) ;
322
- const checkGroups = [ Group ] ;
330
+ const checkGroups = [ Group ] ;
323
331
const runner = new CheckRunner ( { checkGroups, enableCheckLog : true } ) ;
324
332
const report = await runner . run ( ) ;
333
+ console . log ( JSON . stringify ( report ) ) ;
334
+ expect ( report ) . toBeDefined ( ) ;
335
+ expect ( report . report ) . toBeDefined ( ) ;
336
+ expect ( report . report . groups ) . toBeDefined ( ) ;
337
+ expect ( report . report . groups . length ) . toBe ( 1 ) ;
325
338
const titles = report . report . groups . flatMap ( group => group . checks . map ( check => check . title ) ) ;
326
339
expect ( titles . length ) . toBe ( 2 ) ;
327
340
0 commit comments