Exemplo n.º 1
0
def configure_mail_relay():
    global orig_mailsettings, test_email_address
    test_email_address = global_functions.random_email()
    orig_mailsettings = uvmContext.mailSender().getSettings()
    new_mailsettings = copy.deepcopy(orig_mailsettings)
    new_mailsettings['sendMethod'] = 'DIRECT'
    new_mailsettings['fromAddress'] = test_email_address
    uvmContext.mailSender().setSettings(new_mailsettings)
Exemplo n.º 2
0
 def finalTearDown(self):
     global app, web_app
     if app != None:
         app.setSettings(orig_settings)
     if web_app != None:
         uvmContext.appManager().destroy(web_app.getAppSettings()["id"])
         web_app = None
     if orig_mailsettings != None:
         uvmContext.mailSender().setSettings(orig_mailsettings)
     app = None
Exemplo n.º 3
0
 def finalTearDown(self):
     global app, web_app
     # remove all the apps in case test 103 does not remove them.
     for name in apps_list:
         if (uvmContext.appManager().isInstantiated(name)):
             remove_app = uvmContext.appManager().app(name)
             uvmContext.appManager().destroy(remove_app.getAppSettings()["id"])
     if app != None:
         app.setSettings(orig_settings)
     if orig_mailsettings != None:
         uvmContext.mailSender().setSettings(orig_mailsettings)
     app = None
     web_app = None
Exemplo n.º 4
0
    def test_030_test_smtp_settings(self):
        if remote_control.quickTestsOnly:
            raise unittest2.SkipTest('Skipping a time consuming test')
        # Test mail setting in config -> email -> outgoing server
        if (uvmContext.appManager().isInstantiated(self.appNameSpamCase())):
            print "smtp case present"
        else:
            print "smtp not present"
            uvmContext.appManager().instantiate(self.appNameSpamCase(), 1)
        appSP = uvmContext.appManager().app(self.appNameSpamCase())
        origAppDataSP = appSP.getSmtpSettings()
        origMailsettings = uvmContext.mailSender().getSettings()
        # print appDataSP
        newMailsettings = copy.deepcopy(origMailsettings)
        newMailsettings['smtpHost'] = global_functions.testServerHost
        newMailsettings['smtpPort'] = "6800"
        newMailsettings['sendMethod'] = 'CUSTOM'

        uvmContext.mailSender().setSettings(newMailsettings)
        time.sleep(10) # give it time for exim to restart

        appDataSP = appSP.getSmtpSettings()
        appSP.setSmtpSettingsWithoutSafelists(appDataSP)
        recipient = global_functions.random_email()
        uvmContext.mailSender().sendTestMessage(recipient)
        time.sleep(2)
        # force exim to flush queue
        subprocess.call(["exim -qff >/dev/null 2>&1"],shell=True,stdout=None,stderr=None)
        time.sleep(10)

        uvmContext.mailSender().setSettings(origMailsettings)
        appSP.setSmtpSettingsWithoutSafelists(origAppDataSP)
        emailContext = remote_control.run_command("wget -q --timeout=5 -O - http://test.untangle.com/cgi-bin/getEmail.py?toaddress=" + recipient + " 2>&1" ,stdout=True)
        assert('Test Message' in emailContext)