#NEWLINE# def test_clear_expired( self ) : #NEWLINE# #INDENT# self . login ( ) #NEWLINE# self . _login_and_authorize ( ) #NEWLINE# response = self . client . get ( self . redirect_url ( ) ) #NEWLINE# self . assertEqual ( 302 , response . status_code ) #NEWLINE# location = response [ 'Location' ] #NEWLINE# self . assertFalse ( ( 'error' in location ) ) #NEWLINE# self . assertTrue ( ( 'code' in location ) ) #NEWLINE# code = urlparse . parse_qs ( location ) [ 'code' ] [ 0 ] #NEWLINE# self . assertTrue ( Grant . objects . filter ( code = code ) . exists ( ) ) #NEWLINE# response = self . client . post ( self . access_token_url ( ) , { #NEWLINE# #INDENT# 'grant_type' : 'authorization_code' , #NEWLINE# 'client_id' : self . get_client ( ) . client_id , #NEWLINE# 'client_secret' : self . get_client ( ) . client_secret , #NEWLINE# 'code' : code , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEquals ( 200 , response . status_code ) #NEWLINE# token = json . loads ( response . content ) #NEWLINE# self . assertTrue ( ( 'access_token' in token ) ) #NEWLINE# access_token = token [ 'access_token' ] #NEWLINE# self . assertTrue ( ( 'refresh_token' in token ) ) #NEWLINE# refresh_token = token [ 'refresh_token' ] #NEWLINE# self . assertFalse ( Grant . objects . filter ( code = code ) . exists ( ) ) #NEWLINE# self . assertTrue ( AccessToken . objects . filter ( token = access_token ) . exists ( ) ) #NEWLINE# self . assertTrue ( RefreshToken . objects . filter ( token = refresh_token ) . exists ( ) ) #NEWLINE# response = self . client . post ( self . access_token_url ( ) , { #NEWLINE# #INDENT# 'grant_type' : 'refresh_token' , #NEWLINE# 'refresh_token' : token [ 'refresh_token' ] , #NEWLINE# 'client_id' : self . get_client ( ) . client_id , #NEWLINE# 'client_secret' : self . get_client ( ) . client_secret , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( 200 , response . status_code ) #NEWLINE# token = json . loads ( response . content ) #NEWLINE# self . assertTrue ( ( 'access_token' in token ) ) #NEWLINE# self . assertNotEquals ( access_token , token [ 'access_token' ] ) #NEWLINE# self . assertTrue ( ( 'refresh_token' in token ) ) #NEWLINE# self . assertNotEquals ( access_token , token [ 'refresh_token' ] ) #NEWLINE# self . assertFalse ( AccessToken . objects . filter ( token = access_token ) . exists ( ) ) #NEWLINE# self . assertFalse ( RefreshToken . objects . filter ( token = refresh_token ) . exists ( ) )