Exemple #1
0
    def test_incompleteUsername(self):
        """
        Test that a login attempt using a username without a domain part
        results in a customized authentication failure message which points
        out that a domain part should be included in the username.
        """
        mta = mail.MailTransferAgent(store=self.store)
        installOn(mta, self.store)
        factory = mta.getFactory()
        protocol = factory.buildProtocol(("192.168.1.1", 12345))
        transport = StringTransport()
        transport.getHost = lambda: IPv4Address("TCP", "192.168.1.1", 54321)
        transport.getPeer = lambda: IPv4Address("TCP", "192.168.1.1", 12345)
        protocol.makeConnection(transport)
        protocol.dataReceived("EHLO example.net\r\n")
        protocol.dataReceived("AUTH LOGIN\r\n")
        protocol.dataReceived("testuser".encode("base64") + "\r\n")
        transport.clear()
        protocol.dataReceived("password".encode("base64") + "\r\n")
        written = transport.value()
        protocol.connectionLost(failure.Failure(error.ConnectionDone()))

        self.assertEquals(
            written,
            "535 Authentication failure [Username without domain name (ie "
            '"yourname" instead of "yourname@yourdomain") not allowed; try '
            "with a domain name.]\r\n",
        )
Exemple #2
0
    def test_incompleteUsername(self):
        """
        Test that a login attempt using a username without a domain part
        results in a customized authentication failure message which points
        out that a domain part should be included in the username.
        """
        mta = mail.MailTransferAgent(store=self.store)
        installOn(mta, self.store)
        factory = mta.getFactory()
        protocol = factory.buildProtocol(('192.168.1.1', 12345))
        transport = StringTransport()
        transport.getHost = lambda: IPv4Address('TCP', '192.168.1.1', 54321)
        transport.getPeer = lambda: IPv4Address('TCP', '192.168.1.1', 12345)
        protocol.makeConnection(transport)
        protocol.dataReceived('EHLO example.net\r\n')
        protocol.dataReceived('AUTH LOGIN\r\n')
        protocol.dataReceived('testuser'.encode('base64') + '\r\n')
        transport.clear()
        protocol.dataReceived('password'.encode('base64') + '\r\n')
        written = transport.value()
        protocol.connectionLost(failure.Failure(error.ConnectionDone()))

        self.assertEquals(
            written,
            '535 Authentication failure [Username without domain name (ie '
            '"yourname" instead of "yourname@yourdomain") not allowed; try '
            'with a domain name.]\r\n')