#NEWLINE# def test_credentials( self ) : #NEWLINE# #INDENT# logging . debug ( '' ) #NEWLINE# logging . debug ( 'test_credentials' ) #NEWLINE# owner = Credentials ( ) #NEWLINE# if ( ( sys . platform == 'win32' ) and ( not HAVE_PYWIN32 ) ) : #NEWLINE# #INDENT# self . assertEqual ( ( '%s' % owner ) , ( owner . user + ' (transient)' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertEqual ( ( '%s' % owner ) , owner . user ) #NEWLINE# #UNINDENT# user = Credentials ( ) #NEWLINE# self . assertEqual ( user , owner ) #NEWLINE# user . user = 'anyone@hostname' #NEWLINE# self . assertNotEqual ( user , owner ) #NEWLINE# self . assertNotEqual ( user , 'xyzzy' ) #NEWLINE# try : #NEWLINE# #INDENT# del threading . current_thread ( ) . credentials #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# self . assertEqual ( get_credentials ( ) , owner ) #NEWLINE# encoded = owner . encode ( ) #NEWLINE# Credentials . verify ( encoded , allowed_users = None ) #NEWLINE# Credentials . verify ( encoded , allowed_users = None ) #NEWLINE# ( data , signature , client_creds ) = encoded #NEWLINE# encoded = ( data [ : 1 ] , signature , client_creds ) #NEWLINE# assert_raises ( self , 'Credentials.verify(encoded, None)' , globals ( ) , locals ( ) , CredentialsError , 'Invalid data' ) #NEWLINE# encoded = ( data [ : ( - 1 ) ] , signature , client_creds ) #NEWLINE# assert_raises ( self , 'Credentials.verify(encoded, None)' , globals ( ) , locals ( ) , CredentialsError , 'Invalid signature' ) #NEWLINE# encoded = ( data , signature [ : ( - 1 ) ] , client_creds ) #NEWLINE# assert_raises ( self , 'Credentials.verify(encoded, None)' , globals ( ) , locals ( ) , CredentialsError , 'Invalid signature' ) #NEWLINE# newline = data . find ( '\n' ) #NEWLINE# newline = data . find ( '\n' , ( newline + 1 ) ) #NEWLINE# mangled = ( ( data [ : ( newline + 1 ) ] + '*' ) + data [ ( newline + 2 ) : ] ) #NEWLINE# encoded = ( mangled , signature , client_creds ) #NEWLINE# assert_raises ( self , 'Credentials.verify(encoded, None)' , globals ( ) , locals ( ) , CredentialsError , 'Invalid key' ) #NEWLINE# get_key_pair ( owner . user , overwrite_cache = True ) #NEWLINE# spook = Credentials ( ) #NEWLINE# encoded = spook . encode ( ) #NEWLINE# assert_raises ( self , 'Credentials.verify(encoded, None)' , globals ( ) , locals ( ) , CredentialsError , 'Public key mismatch' ) #NEWLINE# self . assertFalse ( remote_access ( ) )