#NEWLINE# def test_callback_view_errors( self ) : #NEWLINE# #INDENT# with self . app . test_client ( ) as client : #NEWLINE# #INDENT# with client . session_transaction ( ) as session : #NEWLINE# #INDENT# session [ 'google_oauth2_csrf_token' ] = 'tokenz' #NEWLINE# #UNINDENT# response = client . get ( '/oauth2callback?state={}&error=something' ) #NEWLINE# self . assertEqual ( response . status_code , httplib . BAD_REQUEST ) #NEWLINE# self . assertIn ( 'something' , response . data . decode ( 'utf-8' ) ) #NEWLINE# #UNINDENT# with self . app . test_client ( ) as client : #NEWLINE# #INDENT# with client . session_transaction ( ) as session : #NEWLINE# #INDENT# session [ 'google_oauth2_csrf_token' ] = 'goodstate' #NEWLINE# #UNINDENT# state = json . dumps ( { #NEWLINE# #INDENT# 'csrf_token' : 'badstate' , #NEWLINE# 'return_url' : '/return_url' , #NEWLINE# #UNINDENT# } ) #NEWLINE# response = client . get ( '/oauth2callback?state={0}&code=codez' . format ( state ) ) #NEWLINE# self . assertEqual ( response . status_code , httplib . BAD_REQUEST ) #NEWLINE# #UNINDENT# with self . app . test_client ( ) as client : #NEWLINE# #INDENT# response = client . get ( '/oauth2callback?state={}&code=codez' ) #NEWLINE# self . assertEqual ( response . status_code , httplib . BAD_REQUEST ) #NEWLINE# #UNINDENT# with self . app . test_client ( ) as client : #NEWLINE# #INDENT# state = self . _setup_callback_state ( client ) #NEWLINE# with Http2Mock ( status = httplib . INTERNAL_SERVER_ERROR ) : #NEWLINE# #INDENT# response = client . get ( '/oauth2callback?state={0}&code=codez' . format ( state ) ) #NEWLINE# self . assertEqual ( response . status_code , httplib . BAD_REQUEST ) #NEWLINE# #UNINDENT# #UNINDENT# with self . app . test_client ( ) as client : #NEWLINE# #INDENT# with client . session_transaction ( ) as session : #NEWLINE# #INDENT# session [ 'google_oauth2_csrf_token' ] = 'tokenz' #NEWLINE# #UNINDENT# state = '[{' #NEWLINE# response = client . get ( '/oauth2callback?state={0}&code=codez' . format ( state ) ) #NEWLINE# self . assertEqual ( response . status_code , httplib . BAD_REQUEST ) #NEWLINE# #UNINDENT# with self . app . test_client ( ) as client : #NEWLINE# #INDENT# with client . session_transaction ( ) as session : #NEWLINE# #INDENT# session [ 'google_oauth2_csrf_token' ] = 'tokenz' #NEWLINE# #UNINDENT# state = json . dumps ( { #NEWLINE# #INDENT# 'csrf_token' : 'tokenz' , #NEWLINE# 'return_url' : '/return_url' , #NEWLINE# #UNINDENT# } ) #NEWLINE# response = client . get ( '/oauth2callback?state={0}&code=codez' . format ( state ) ) #NEWLINE# self . assertEqual ( response . status_code , httplib . BAD_REQUEST )