allow immediate redirect on auth
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is failing
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	continuous-integration/drone/push Build is failing
				
			This commit is contained in:
		| @@ -36,7 +36,7 @@ function check_headers (resp: Response): CheckHeaderResult { | ||||
|   return { data, at, rt }; | ||||
| } | ||||
|  | ||||
| function check_token (token: string, type: string):void { | ||||
| function check_token (token: string, type: string): void { | ||||
|   const v = auth.verify (token); | ||||
|   expect (v.valid) | ||||
|     .toEqual (true); | ||||
| @@ -88,6 +88,12 @@ describe ('auth handler', () => { | ||||
|       else if (req.user === 'part' && req.password === 'bar') { | ||||
|         req.allow_part (part_expires_seconds, 'two_factor'); | ||||
|       } | ||||
|       else if (req.user === 'red' && req.password === 'irect') { | ||||
|         req.allow_access ({ | ||||
|           access_token_expires_in: expires_seconds, | ||||
|           redirect_to:             '/redirected' | ||||
|         }); | ||||
|       } | ||||
|       else { | ||||
|         req.deny (); | ||||
|       } | ||||
| @@ -290,6 +296,20 @@ describe ('auth handler', () => { | ||||
|     expect (res2.rt).not.toEqual (res1.rt); | ||||
|   }); | ||||
|  | ||||
|   it ('should do immediate redirect', async () => { | ||||
|     const resp1 = await get ({ authorization: 'Basic red:irect' }); | ||||
|     expect (resp1.statusCode) | ||||
|       .toEqual (302); | ||||
|     expect (resp1.headers.location) | ||||
|       .toEqual ('/redirected'); | ||||
|     let signature = ''; | ||||
|     for (const c of resp1.headers['set-cookie'] as string[]) { | ||||
|       if (c.includes ('cookie_jar=')) | ||||
|         signature = c.replace ('cookie_jar=', ''); | ||||
|     } | ||||
|     check_token (signature, 'access_token'); | ||||
|   }); | ||||
|  | ||||
|   it ('should handle any authorization type', async () => { | ||||
|     const resp = await get ({ authorization: 'Foo asdefg' }); | ||||
|     expect (resp.statusCode) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user