Example #1
0
 def test_certreq_warn(self, caplog, ssl_context_server):
     context = ssl_context_server
     context.verify_mode = ssl.CERT_REQUIRED
     _ = Server(Sink(), tls_context=context)
     assert context.verify_mode == ssl.CERT_REQUIRED
     logmsg = caplog.record_tuples[0][-1]
     assert "tls_context.verify_mode not in" in logmsg
     assert "might cause client connection problems" in logmsg
Example #2
0
 def test_nocertreq_chkhost_warn(self, caplog, ssl_context_server):
     context = ssl_context_server
     context.verify_mode = ssl.CERT_OPTIONAL
     context.check_hostname = True
     _ = Server(Sink(), tls_context=context)
     assert context.verify_mode == ssl.CERT_OPTIONAL
     logmsg = caplog.record_tuples[0][-1]
     assert "tls_context.check_hostname == True" in logmsg
     assert "might cause client connection problems" in logmsg
Example #3
0
 def test_hook_EHLO_deprecated_warning(self):
     with pytest.warns(
             DeprecationWarning,
             match=
         (
             # Is a regex; escape regex special chars if necessary
             r"Use the 5-argument handle_EHLO\(\) hook instead of the "
             r"4-argument handle_EHLO\(\) hook; support for the 4-argument "
             r"handle_EHLO\(\) hook will be removed in version 2.0")):
         _ = Server(EHLOHandlerDeprecated())
Example #4
0
 def factory(self):
     #return MySMTPServer(self.handler)
     return Server(self.handler,
                   data_size_limit=33554432,
                   enable_SMTPUTF8=False,
                   decode_data=False,
                   hostname="10.10.10.248",
                   ident=None,
                   tls_context=None,
                   require_starttls=False,
                   timeout=300)
Example #5
0
    def factory(self):
        """``CustomIdentController`` factory.

        Overrides ``super.factory()``.
        Creates an aiosmtpd server object.

        Returns:
            Returns the server object.
        """

        server = Server(self.handler)
        server.hostname = self.ident_hostname
        server.__ident__ = self.ident
        return server
Example #6
0
 def factory(self):
     return Server(self.handler, timeout=0.1)
Example #7
0
 def factory(self):
     return Server(self.handler, decode_data=False)
Example #8
0
 def _get_protocol(self, *args, **kwargs):
     protocol = Server(*args, loop=self.loop, **kwargs)
     protocol.connection_made(self.transport)
     return protocol
Example #9
0
 def test_hook_EHLO_incompat(self, handler_class):
     with pytest.raises(RuntimeError, match="Unsupported EHLO Hook"):
         _ = Server(handler_class())
Example #10
0
 def factory(self):
     server = Server(self.handler)
     server.hostname = self.ident_hostname
     server.__ident__ = self.ident
     return server
Example #11
0
 def factory(self):
     return Server(self.handler, hostname='custom.localhost')
Example #12
0
 def test_default_max_command_size_limit(self):
     server = Server(Sink())
     assert server.max_command_size_limit == 512
Example #13
0
 def test_verify_mode_nochange(self, ssl_context_server):
     context = ssl_context_server
     for mode in (ssl.CERT_NONE, ssl.CERT_OPTIONAL):
         context.verify_mode = mode
         _ = Server(Sink(), tls_context=context)
         assert context.verify_mode == mode
Example #14
0
 def test_special_max_command_size_limit(self):
     server = Server(Sink())
     server.command_size_limits['DATA'] = 1024
     self.assertEqual(server.max_command_size_limit, 1024)
Example #15
0
 def test_default_max_command_size_limit(self):
     server = Server(Sink())
     self.assertEqual(server.max_command_size_limit, 512)
Example #16
0
 def factory(self):
     return Server(self.handler, enable_SMTPUTF8=True)
Example #17
0
 def factory(self):
     server = Server(self.handler)
     server.__ident__ = 'Identifying SMTP v2112'
     return server
Example #18
0
 def factory(self):
     return Server(self.handler, data_size_limit=self.size)
Example #19
0
 def test_special_max_command_size_limit(self):
     server = Server(Sink())
     server.command_size_limits["DATA"] = 1024
     assert server.max_command_size_limit == 1024
Example #20
0
 def factory(self):
     return Server(self.handler, enable_SMTPUTF8=False, decode_data=True)
Example #21
0
 def factory(self):
     return Server(self.handler, decode_data=True, auth_require_tls=False)
Example #22
0
 def factory(self):
     server = Server(self.handler, ident='Identifying SMTP v2112')
     return server
Example #23
0
 def test_warn_authreq_notls(self):
     expectedre = (r"Requiring AUTH while not requiring TLS can lead to "
                   r"security vulnerabilities!")
     with pytest.warns(UserWarning, match=expectedre):
         Server(Sink(), auth_require_tls=False, auth_required=True)