#NEWLINE# def test_basicAuthentication( self ) : #NEWLINE# #INDENT# '\n        Test that registration with basic authentication suceeds.\n        ' #NEWLINE# self . addPortal ( ) #NEWLINE# self . proxy . authorizers = self . proxy . authorizers . copy ( ) #NEWLINE# self . proxy . authorizers [ 'basic' ] = sip . BasicAuthorizer ( ) #NEWLINE# warnings = self . flushWarnings ( offendingFunctions = [ self . test_basicAuthentication ] ) #NEWLINE# self . assertEqual ( len ( warnings ) , 1 ) #NEWLINE# self . assertEqual ( warnings [ 0 ] [ 'message' ] , 'twisted.protocols.sip.BasicAuthorizer was deprecated in Twisted 9.0.0' ) #NEWLINE# self . assertEqual ( warnings [ 0 ] [ 'category' ] , DeprecationWarning ) #NEWLINE# r = sip . Request ( 'REGISTER' , 'sip:bell.example.com' ) #NEWLINE# r . addHeader ( 'to' , 'sip:joe@bell.example.com' ) #NEWLINE# r . addHeader ( 'contact' , 'sip:joe@client.com:1234' ) #NEWLINE# r . addHeader ( 'via' , sip . Via ( 'client.com' ) . toString ( ) ) #NEWLINE# r . addHeader ( 'authorization' , ( 'Basic ' + 'userXname:passXword' . encode ( 'base64' ) ) ) #NEWLINE# self . proxy . datagramReceived ( r . toString ( ) , ( 'client.com' , 5060 ) ) #NEWLINE# self . assertEquals ( len ( self . registry . users ) , 1 ) #NEWLINE# self . assertEquals ( len ( self . sent ) , 1 ) #NEWLINE# ( dest , m ) = self . sent [ 0 ] #NEWLINE# self . assertEquals ( m . code , 200 )