#NEWLINE# def testCred( cred , username = None , password = None ) : #NEWLINE# #INDENT# "\n    Test if given credentials matches specified credentials\n\n    If specified credentials doesn't have username or password, it\n    will still match on the other.\n\n    " #NEWLINE# cred_username = cred . get ( 'username' , None ) #NEWLINE# cred_password = cred . get ( 'password' , None ) #NEWLINE# user_match = True #NEWLINE# if ( cred_username is not None ) : #NEWLINE# #INDENT# user_match = ( cred_username == username ) #NEWLINE# #UNINDENT# password_match = True #NEWLINE# if ( cred_password is not None ) : #NEWLINE# #INDENT# password_match = cryptcontext . verify ( password , cred_password ) #NEWLINE# #UNINDENT# return ( user_match and username )