File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,36 @@ describe('proxy route filter middleware', () => {
22
22
sinon . restore ( ) ;
23
23
} ) ;
24
24
25
+ it ( 'should reject invalid git requests with 400' , async ( ) => {
26
+ const res = await chai
27
+ . request ( app )
28
+ . get ( '/owner/repo.git/invalid/path' )
29
+ . set ( 'user-agent' , 'git/2.42.0' )
30
+ . set ( 'accept' , 'application/x-git-upload-pack-request' ) ;
31
+
32
+ expect ( res ) . to . have . status ( 400 ) ;
33
+ expect ( res . text ) . to . equal ( 'Invalid request received' ) ;
34
+ } ) ;
35
+
36
+ it ( 'should handle blocked requests and return custom packet message' , async ( ) => {
37
+ sinon . stub ( chain , 'executeChain' ) . resolves ( {
38
+ blocked : true ,
39
+ blockedMessage : 'You shall not push!' ,
40
+ error : false ,
41
+ } ) ;
42
+
43
+ const res = await chai
44
+ . request ( app )
45
+ . get ( '/owner/repo.git/info/refs?service=git-upload-pack' )
46
+ . set ( 'user-agent' , 'git/2.42.0' )
47
+ . set ( 'accept' , 'application/x-git-upload-pack-request' )
48
+ . buffer ( ) ;
49
+
50
+ expect ( res . status ) . to . equal ( 200 ) ;
51
+ expect ( res . text ) . to . contain ( 'You shall not push!' ) ;
52
+ expect ( res . headers [ 'content-type' ] ) . to . include ( 'application/x-git-receive-pack-result' ) ;
53
+ expect ( res . headers [ 'x-frame-options' ] ) . to . equal ( 'DENY' ) ;
54
+ } ) ;
25
55
} ) ;
26
56
} ) ;
27
57
You can’t perform that action at this time.
0 commit comments