File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,43 @@ describe('proxy route filter middleware', () => {
5252 expect ( res . headers [ 'content-type' ] ) . to . include ( 'application/x-git-receive-pack-result' ) ;
5353 expect ( res . headers [ 'x-frame-options' ] ) . to . equal ( 'DENY' ) ;
5454 } ) ;
55+
56+ describe ( 'when request is valid and not blocked' , ( ) => {
57+ it ( 'should return error if repo is not found' , async ( ) => {
58+ sinon . stub ( chain , 'executeChain' ) . resolves ( {
59+ blocked : false ,
60+ blockedMessage : '' ,
61+ error : false ,
62+ } ) ;
63+
64+ const res = await chai
65+ . request ( app )
66+ . get ( '/owner/repo.git/info/refs?service=git-upload-pack' )
67+ . set ( 'user-agent' , 'git/2.42.0' )
68+ . set ( 'accept' , 'application/x-git-upload-pack-request' )
69+ . buffer ( ) ;
70+
71+ expect ( res . status ) . to . equal ( 401 ) ;
72+ expect ( res . text ) . to . equal ( 'Repository not found.' ) ;
73+ } ) ;
74+
75+ it ( 'should pass through if repo is found' , async ( ) => {
76+ sinon . stub ( chain , 'executeChain' ) . resolves ( {
77+ blocked : false ,
78+ blockedMessage : '' ,
79+ error : false ,
80+ } ) ;
81+
82+ const res = await chai
83+ . request ( app )
84+ . get ( '/finos/git-proxy.git/info/refs?service=git-upload-pack' )
85+ . set ( 'user-agent' , 'git/2.42.0' )
86+ . set ( 'accept' , 'application/x-git-upload-pack-request' )
87+ . buffer ( ) ;
88+
89+ expect ( res . status ) . to . equal ( 200 ) ;
90+ expect ( res . text ) . to . contain ( 'git-upload-pack' ) ;
91+ } ) ;
5592 } ) ;
5693} ) ;
5794
You can’t perform that action at this time.
0 commit comments