def test_failedBasicAuthentication(self):
        self.addPortal()
        self.proxy.authorizers = self.proxy.authorizers.copy()
        self.proxy.authorizers['basic'] = sip.BasicAuthorizer()
        warnings = self.flushWarnings(
            offendingFunctions=[self.test_failedBasicAuthentication])
        self.assertEqual(len(warnings), 1)
        self.assertEqual(
            warnings[0]['message'],
            "twisted.protocols.sip.BasicAuthorizer was deprecated in "
            "Twisted 9.0.0")
        self.assertEqual(
            warnings[0]['category'],
            DeprecationWarning)
        r = sip.Request("REGISTER", "sip:bell.example.com")
        r.addHeader("to", "sip:joe@bell.example.com")
        r.addHeader("contact", "sip:joe@client.com:1234")
        r.addHeader("via", sip.Via("client.com").toString())
        r.addHeader(
            "authorization", "Basic " + "userXname:password".encode('base64'))
        self.proxy.datagramReceived(r.toString(), ("client.com", 5060))

        self.assertEquals(len(self.registry.users), 0)
        self.assertEquals(len(self.sent), 1)
        dest, m = self.sent[0]
        self.assertEquals(m.code, 401)
Failed registration with basic authentication results in an
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/test/test_sip.py/RegistrationTestCase.test_failedBasicAuthentication