Exemplo n.º 1
0
    def test_do_config_checks_capabilities_errors(self):
        # Set up our mock expectations.
        # Our configuration is using password-encrypted. If we return it
        # supports GSSAPI and doesn't support password-encrypted,
        # do_config_checks should return 1 error and 1 warning for each server
        # incoming and outgoing)
        # IMAP SSL
        server = imaplib.IMAP4_SSL('mail.test.com', 995)
        server.capabilities = ('IMAP4REV1', 'SASL-IR', 'SORT',
                'THREAD=REFERENCES', 'MULTIAPPEND',
                'UNSELECT', 'LITERAL+', 'IDLE', 'CHILDREN', 'NAMESPACE',
                'LOGIN-REFERRALS', 'QUOTA', 'AUTH=PLAIN', 'AUTH=LOGIN',
                'AUTH=GSSAPI')
        server.shutdown()
        # SMTP SSL
        server = smtplib.SMTP_SSL('mail.test.com', 465, timeout=TIMEOUT)
        server.ehlo().AndReturn((250,
            'mx2.mail.corp.phx1.test.com\nPIPELINING\nSIZE '
            '31457280\nETRN\nAUTH LOGIN PLAIN NTLM GSSAPI UNSUPPORTED'
            '\nENHANCEDSTATUSCODES\n8BITMIME\nDSN'))
        server.quit()
        self.mox.ReplayAll()

        #Test methods
        config = Config.objects.get(pk=1)
        config.incoming_authentication = 'password-encrypted'
        config.outgoing_authentication = 'password-encrypted'
        config.save()
        errors, warnings = do_config_checks(config)

        # Verify the results (and the mock expectations.)
        self.mox.VerifyAll()
        assert_equal(len(errors), 2)
        assert_equal(len(warnings), 2)
Exemplo n.º 2
0
def sanity(request, id):
    config = get_object_or_404(Config, pk=id)
    domains = config.domains.all() or config.domainrequests.all()
    domain_errors, domain_warnings = do_domain_checks(domains)
    config_errors, config_warnings = do_config_checks(config)
    data = simplejson.dumps({"errors": domain_errors + config_errors,
                             "warnings": domain_warnings + config_warnings,
                            })
    return HttpResponse(data, mimetype='application/json')
Exemplo n.º 3
0
    def test_do_config_checks_socket_type_errors(self):
        # Set up our mock expectations.
        # Our configuration is using STARTTLS. If we return it supports SSL and
        # it doesn't support STARTTLS, do_config_checks should return 1 error
        # and 1 warning for each server (incoming and outgoing)
        # IMAP SSL
        server = imaplib.IMAP4_SSL('mail.test.com', 993)
        server.capabilities = ('IMAP4REV1', 'SASL-IR', 'SORT',
                'THREAD=REFERENCES', 'MULTIAPPEND',
                'UNSELECT', 'LITERAL+', 'IDLE', 'CHILDREN', 'NAMESPACE',
                'LOGIN-REFERRALS', 'QUOTA', 'AUTH=PLAIN', 'AUTH=LOGIN')
        server.shutdown()
        # IMAP STARTTLS
        server = imaplib.IMAP4('mail.test.com', 995)
        server.starttls().AndRaise(Exception("STARTTLS extension not supported"
                "by server."))
        server.shutdown()
        # SMTP SSL
        server = smtplib.SMTP_SSL('mail.test.com', 465, timeout=TIMEOUT)
        server.ehlo().AndReturn((250,
            'mx2.mail.corp.phx1.test.com\nPIPELINING\nSIZE '
            '31457280\nETRN\nAUTH LOGIN PLAIN NTLM CRAM-MD5 GSSAPI UNSUPPORTED'
            '\nENHANCEDSTATUSCODES\n8BITMIME\nDSN'))
        server.quit()
        # SMTP STARTTLS
        server = smtplib.SMTP('mail.test.com', 465, timeout=TIMEOUT)
        server.ehlo()
        server.starttls().AndRaise(smtplib.SMTPException("STARTTLS extension"
                "not supported by server."))
        server.quit()
        self.mox.ReplayAll()

        #Test methods
        config = Config.objects.get(pk=1)
        config.incoming_socket_type = 'STARTTLS'
        config.outgoing_socket_type = 'STARTTLS'
        config.save()
        errors, warnings = do_config_checks(config)

        # Verify the results (and the mock expectations.)
        self.mox.VerifyAll()
        assert_equal(len(errors), 2)
        assert_equal(len(warnings), 2)