#NEWLINE# def test_is_authenticated_header( self ) : #NEWLINE# #INDENT# auth = ApiKeyAuthentication ( ) #NEWLINE# request = HttpRequest ( ) #NEWLINE# john_doe = User . objects . get ( username = 'johndoe' ) #NEWLINE# create_api_key ( User , instance = john_doe , created = True ) #NEWLINE# self . assertEqual ( isinstance ( auth . is_authenticated ( request ) , HttpUnauthorized ) , True ) #NEWLINE# request . META [ 'HTTP_AUTHORIZATION' ] = 'foo' #NEWLINE# self . assertEqual ( isinstance ( auth . is_authenticated ( request ) , HttpUnauthorized ) , True ) #NEWLINE# request . META [ 'HTTP_AUTHORIZATION' ] = 'ApiKey daniel' #NEWLINE# self . assertEqual ( isinstance ( auth . is_authenticated ( request ) , HttpUnauthorized ) , True ) #NEWLINE# request . META [ 'HTTP_AUTHORIZATION' ] = 'ApiKey daniel:pass' #NEWLINE# self . assertEqual ( isinstance ( auth . is_authenticated ( request ) , HttpUnauthorized ) , True ) #NEWLINE# john_doe = User . objects . get ( username = 'johndoe' ) #NEWLINE# request . META [ 'HTTP_AUTHORIZATION' ] = ( 'ApiKey johndoe:%s' % john_doe . api_key . key ) #NEWLINE# self . assertEqual ( auth . is_authenticated ( request ) , True ) #NEWLINE# john_doe = User . objects . get ( username = 'johndoe' ) #NEWLINE# request . META [ 'HTTP_AUTHORIZATION' ] = ( 'aPiKeY johndoe:%s' % john_doe . api_key . key ) #NEWLINE# self . assertEqual ( auth . is_authenticated ( request ) , True )