コード例 #1
0
ファイル: uvm_tests.py プロジェクト: untangle/ngfw_src
    def test_100_account_login(self):
        untangleEmail, untanglePassword = global_functions.get_live_account_info("Untangle")
        untangle2Email, untangle2Password = global_functions.get_live_account_info("Untangle2")
        if untangleEmail == "message":
            raise unittest.SkipTest('Skipping no accound found:' + str(untanglePassword))

        result = uvmContext.cloudManager().accountLogin( untangleEmail, untanglePassword )
        result2 = uvmContext.cloudManager().accountLogin( untangle2Email, untangle2Password )
        assert (result.get('success') or result2.get('success'))
コード例 #2
0
ファイル: test_uvm.py プロジェクト: creatovolve/ngfw_src
    def test_100_account_login(self):
        untangleEmail, untanglePassword = global_functions.get_live_account_info("Untangle")
        untangle2Email, untangle2Password = global_functions.get_live_account_info("Untangle2")
        if untangleEmail == "message":
            raise unittest.SkipTest('Skipping no accound found:' + str(untanglePassword))

        result = uvmContext.cloudManager().accountLogin( untangleEmail, untanglePassword )
        result2 = uvmContext.cloudManager().accountLogin( untangle2Email, untangle2Password )
        assert (result.get('success') or result2.get('success'))
コード例 #3
0
    def initial_setup(self):
        global app,md5StdNum, appSSL, appSSLData, canRelay
        # download eicar and trojan files before installing virus blocker
        self.ftp_user_name, self.ftp_password = global_functions.get_live_account_info("ftp")
        remote_control.run_command("rm -f /tmp/eicar /tmp/std_022_ftpVirusBlocked_file /tmp/temp_022_ftpVirusPassSite_file")
        result = remote_control.run_command("wget --user="******" --password='******' -q -O /tmp/eicar http://test.untangle.com/virus/eicar.com")
        assert (result == 0)
        result = remote_control.run_command("wget --user="******" --password='******' -q -O /tmp/std_022_ftpVirusBlocked_file ftp://" + global_functions.ftp_server + "/virus/fedexvirus.zip")
        assert (result == 0)
        md5StdNum = remote_control.run_command("\"md5sum /tmp/std_022_ftpVirusBlocked_file | awk '{print $1}'\"", stdout=True)
        self.md5StdNum = md5StdNum
        # print("md5StdNum <%s>" % md5StdNum)
        assert (result == 0)

        try:
            canRelay = global_functions.send_test_email(mailhost=testsiteIP)
        except Exception as e:
            canRelay = False

        if (uvmContext.appManager().isInstantiated(self.module_name())):
            raise unittest.SkipTest('app %s already instantiated' % self.module_name())
        app = uvmContext.appManager().instantiate(self.module_name(), default_policy_id)
        self.app = app

        if uvmContext.appManager().isInstantiated(self.appNameSSLInspector()):
            raise Exception('app %s already instantiated' % self.appNameSSLInspector())
        appSSL = uvmContext.appManager().instantiate(self.appNameSSLInspector(), default_policy_id)
        # appSSL.start() # leave app off. app doesn't auto-start
        appSSLData = appSSL.getSettings()
        # Enable cloud connection
        system_settings = uvmContext.systemManager().getSettings()
        system_settings['cloudEnabled'] = True
        uvmContext.systemManager().setSettings(system_settings)
コード例 #4
0
    def initial_setup(self):
        global app,md5StdNum, appSSL, appSSLData, canRelay
        # download eicar and trojan files before installing virus blocker
        self.ftp_user_name, self.ftp_password = global_functions.get_live_account_info("ftp")
        remote_control.run_command("rm -f /tmp/eicar /tmp/std_022_ftpVirusBlocked_file /tmp/temp_022_ftpVirusPassSite_file")
        result = remote_control.run_command("wget --user="******" --password='******' -q -O /tmp/eicar http://test.untangle.com/virus/eicar.com")
        assert (result == 0)
        result = remote_control.run_command("wget --user="******" --password='******' -q -O /tmp/std_022_ftpVirusBlocked_file ftp://" + global_functions.ftp_server + "/virus/fedexvirus.zip")
        assert (result == 0)
        md5StdNum = remote_control.run_command("\"md5sum /tmp/std_022_ftpVirusBlocked_file | awk '{print $1}'\"", stdout=True)
        self.md5StdNum = md5StdNum
        # print("md5StdNum <%s>" % md5StdNum)
        assert (result == 0)

        try:
            canRelay = global_functions.send_test_email(mailhost=testsiteIP)
        except Exception as e:
            canRelay = False

        if (uvmContext.appManager().isInstantiated(self.module_name())):
            raise unittest.SkipTest('app %s already instantiated' % self.module_name())
        app = uvmContext.appManager().instantiate(self.module_name(), default_policy_id)
        self.app = app

        if uvmContext.appManager().isInstantiated(self.appNameSSLInspector()):
            raise Exception('app %s already instantiated' % self.appNameSSLInspector())
        appSSL = uvmContext.appManager().instantiate(self.appNameSSLInspector(), default_policy_id)
        # appSSL.start() # leave app off. app doesn't auto-start
        appSSLData = appSSL.getSettings()
        # Enable cloud connection
        system_settings = uvmContext.systemManager().getSettings()
        system_settings['cloudEnabled'] = True
        uvmContext.systemManager().setSettings(system_settings)
コード例 #5
0
 def test_025_protoRule_Ftp(self):
     touchProtoRule("FTP",False,False)
     pingResult = subprocess.call(["ping","-c","1",global_functions.ftp_server],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
     if pingResult:
         raise unittest.SkipTest(global_functions.ftp_server + " not reachable")
     ftpUserName, ftpPassword = global_functions.get_live_account_info("ftp")            
     result1 = remote_control.run_command("wget --user="******" --password='******' -q -O /dev/null -4 -t 2 -o /dev/null --timeout=5 ftp://" + global_functions.ftp_server + "/")
     touchProtoRule("FTP",True,True)
     result2 = remote_control.run_command("wget --user="******" --password='******' -q -O /dev/null -4 -t 2 -o /dev/null --timeout=5 ftp://" + global_functions.ftp_server + "/")
     touchProtoRule("FTP",False,False)
     assert (result1 == 0)
     assert (result2 != 0)
コード例 #6
0
    def test_140_compare_cloud_backup(self):
        """Compare a cloud backup with a local backup"""
        boxUID = uvmContext.getServerUID()
        #get authentication url and api key
        authUrl, authKey = global_functions.get_live_account_info(
            "UntangleAuth")
        boxBackupUrl, bbKey = global_functions.get_live_account_info(
            "BoxBackup")
        self._app.sendBackup()
        #remove previous backups/backup directories
        subprocess.call("rm -rf /tmp/localBackup*", shell=True)
        subprocess.call("rm -rf /tmp/cloudBackup*", shell=True)

        #download local backup
        subprocess.call(
            "wget -o /dev/null -O '/tmp/localBackup.backup' -t 2 --timeout 3 --post-data 'type=backup' http://localhost/admin/download",
            shell=True)
        #extract backup
        subprocess.call("mkdir /tmp/localBackup", shell=True)
        subprocess.call("tar -xf /tmp/localBackup.backup -C /tmp/localBackup",
                        shell=True)
        subprocess.call(
            "tar -xf " + glob.glob("/tmp/localBackup/files*.tar.gz")[0] +
            " -C /tmp/localBackup",
            shell=True)  #use glob since extracted file has timestamp
        localBackupPath = "/tmp/localBackup/usr"

        #set Token for boxbackup access
        authenticationUrl = authUrl
        authPayload = "{\n  \"token\": 123,\n  \"resourceIds\": [\"%s\"],\n  \"timeoutOverride\": \"5\"\n}" % (
            boxUID)
        authHeaders = {
            'Content-Type': "application/json",
            'AuthRequest': authKey,
            'Cache-Control': "no-cache"
        }
        requests.request("POST",
                         authenticationUrl,
                         data=authPayload,
                         headers=authHeaders)

        #get list of backups for the UID above
        bbUrl = boxBackupUrl
        bbQueryString = {"action": "list", "uid": boxUID, "token": "123"}
        bbHeaders = {'Cache-Control': 'no-cache'}
        bbResponse = requests.request("GET",
                                      bbUrl,
                                      headers=bbHeaders,
                                      params=bbQueryString)

        #convert response text to literal list
        backupList = ast.literal_eval(bbResponse.text)
        #grab the latest cloud backup from the list
        latestBackup = backupList[-1]
        #print("latest backup from cloud: %s" % latestBackup)

        #download the latest backup and save it to /tmp
        dlUrl = boxBackupUrl
        dlQueryString = {
            "action": "get",
            "uid": boxUID,
            "token": "123",
            "filename": latestBackup
        }
        dlHeaders = {'Cache-Control': 'no-cache'}
        dlResponse = requests.request("GET",
                                      dlUrl,
                                      headers=dlHeaders,
                                      params=dlQueryString)
        with open("/tmp/cloudBackup.backup", "wb") as f:
            f.write(dlResponse.content)
        #extract cloud backup
        subprocess.call("mkdir /tmp/cloudBackup", shell=True)
        subprocess.call("tar -xf /tmp/cloudBackup.backup -C /tmp/cloudBackup",
                        shell=True)
        subprocess.call(
            "tar -xf " + glob.glob("/tmp/cloudBackup/files*.tar.gz")[0] +
            " -C /tmp/cloudBackup",
            shell=True)  #use glob since extracted file has timestamp
        cloudBackupPath = "/tmp/cloudBackup/usr"

        #compare directories
        def is_same(dir1, dir2):
            compared = filecmp.dircmp(dir1, dir2)
            if (compared.left_only or compared.right_only
                    or compared.diff_files or compared.funny_files):
                return False
            for subdir in compared.common_dirs:
                if not is_same(os.path.join(dir1, subdir),
                               os.path.join(dir2, subdir)):
                    return False
            return True

        assert (is_same(localBackupPath, cloudBackupPath))
コード例 #7
0
    def test_140_compare_cloud_backup(self):
        """Compare a cloud backup with a local backup"""
        global app
        boxUID = uvmContext.getServerUID()
        #get authentication url and api key
        authUrl,authKey = global_functions.get_live_account_info("UntangleAuth")
        boxBackupUrl,bbKey = global_functions.get_live_account_info("BoxBackup")
        app.sendBackup()
        #remove previous backups/backup directories
        subprocess.call("rm -rf /tmp/localBackup*", shell=True)
        subprocess.call("rm -rf /tmp/cloudBackup*", shell=True)

        #download local backup
        subprocess.call("wget -o /dev/null -O '/tmp/localBackup.backup' -t 2 --timeout 3 --post-data 'type=backup' http://localhost/admin/download", shell=True)
        #extract backup
        subprocess.call("mkdir /tmp/localBackup", shell=True)
        subprocess.call("tar -xf /tmp/localBackup.backup -C /tmp/localBackup", shell=True)
        subprocess.call("tar -xf "+glob.glob("/tmp/localBackup/files*.tar.gz")[0] + " -C /tmp/localBackup", shell=True) #use glob since extracted file has timestamp
        localBackupPath = "/tmp/localBackup/usr"

        #set Token for boxbackup access
        authenticationUrl = authUrl
        authPayload = "{\n  \"token\": 123,\n  \"resourceIds\": [\"%s\"],\n  \"timeoutOverride\": \"5\"\n}" % (boxUID)
        authHeaders = {
            'Content-Type': "application/json",
            'AuthRequest': authKey,
            'Cache-Control': "no-cache"
            }
        requests.request("POST", authenticationUrl, data=authPayload, headers=authHeaders)
        
        #get list of backups for the UID above
        bbUrl = boxBackupUrl
        bbQueryString = {"action":"list","uid":boxUID,"token":"123"}
        bbHeaders = {'Cache-Control': 'no-cache'}
        bbResponse = requests.request("GET", bbUrl, headers=bbHeaders, params=bbQueryString)

        #convert response text to literal list
        backupList = ast.literal_eval(bbResponse.text)
        #grab the latest cloud backup from the list
        latestBackup = backupList[-1]
        #print("latest backup from cloud: %s" % latestBackup)

        #download the latest backup and save it to /tmp
        dlUrl = boxBackupUrl
        dlQueryString = {"action":"get","uid":boxUID,"token":"123","filename":latestBackup}
        dlHeaders = {'Cache-Control': 'no-cache'}
        dlResponse = requests.request("GET", dlUrl, headers=dlHeaders, params=dlQueryString)
        with open("/tmp/cloudBackup.backup", "wb") as f:
            f.write(dlResponse.content)
        #extract cloud backup
        subprocess.call("mkdir /tmp/cloudBackup", shell=True)
        subprocess.call("tar -xf /tmp/cloudBackup.backup -C /tmp/cloudBackup", shell=True)
        subprocess.call("tar -xf "+glob.glob("/tmp/cloudBackup/files*.tar.gz")[0] + " -C /tmp/cloudBackup", shell=True) #use glob since extracted file has timestamp
        cloudBackupPath = "/tmp/cloudBackup/usr"
        
        #compare directories
        def is_same(dir1, dir2):
            compared = filecmp.dircmp(dir1, dir2)
            if (compared.left_only or compared.right_only or compared.diff_files 
                or compared.funny_files):
                return False
            for subdir in compared.common_dirs:
                if not is_same(os.path.join(dir1, subdir), os.path.join(dir2, subdir)):
                    return False
            return True
    
        assert(is_same(localBackupPath, cloudBackupPath))