diff --git a/packages/tests.py b/packages/tests.py index 5982e6bcd..136101cbb 100755 --- a/packages/tests.py +++ b/packages/tests.py @@ -2,5 +2,51 @@ from __future__ import unicode_literals from django.test import TestCase - +import json +from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging +import requests +import time +from plogical.processUtilities import ProcessUtilities +import urllib3 +urllib3.disable_warnings() # Create your tests here. + + +class TestPackages(TestCase): + httpClient = requests.Session() + + def MakeRequest(self, endPoint, data): + json_data = json.dumps(data) + path = 'https://cyberpanel.xyz:8090/%s' % (endPoint) + result = TestPackages.httpClient.post(path, data=json_data, verify=False) + return json.loads(result.text) + + def MakeRequestRaw(self, path): + result = requests.get(path) + return str(result.text) + + def setUp(self): + ## Verify login + + data_ret = {'username': 'admin', 'password': '1234567'} + response = self.MakeRequest('verifyLogin', data_ret) + self.assertEqual(response['loginStatus'], 1) + + def test_submitPackage(self): + + ## Login + + data_ret = {'domainName': 'hello.cyberpanel.xyz', 'adminEmail': 'usman@cyberpersons.com' , 'phpSelection': 'PHP 7.1', + 'package': 'Default', 'websiteOwner': 'admin', 'ssl': 0, 'dkimCheck': 0, 'openBasedir': 0} + response = self.MakeRequest('packages/submitPackage', data_ret) + + time.sleep(10) + + self.assertEqual(response['status'], 1) + + exists = 0 + + if self.MakeRequestRaw('http://hello.cyberpanel.xyz').find('CyberPanel') > -1: + exists = 1 + + self.assertEqual(exists, 1) diff --git a/plogical/cronUtil.py b/plogical/cronUtil.py index 90f50e19d..48d45d4c0 100755 --- a/plogical/cronUtil.py +++ b/plogical/cronUtil.py @@ -1,13 +1,5 @@ -import CyberCPLogFileWriter as logging -import subprocess -import shlex -import thread -import installUtilities import argparse -import os -from mailUtilities import mailUtilities from processUtilities import ProcessUtilities -from random import randint class CronUtil: diff --git a/plogical/upgrade.py b/plogical/upgrade.py index cc0cb591e..dd948834c 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -54,6 +54,32 @@ class Upgrade: except: return 0 + @staticmethod + def updateRepoURL(): + command = "sed -i 's|sgp.cyberpanel.sh|cdn.cyberpanel.sh|g' /etc/yum.repos.d/MariaDB.repo" + Upgrade.executioner(command, command, 0) + + command = "sed -i 's|lax.cyberpanel.sh|cdn.cyberpanel.sh|g' /etc/yum.repos.d/MariaDB.repo" + Upgrade.executioner(command, command, 0) + + command = "sed -i 's|fra.cyberpanel.sh|cdn.cyberpanel.sh|g' /etc/yum.repos.d/MariaDB.repo" + Upgrade.executioner(command, command, 0) + + command = "sed -i 's|mirror.cyberpanel.net|cdn.cyberpanel.sh|g' /etc/yum.repos.d/MariaDB.repo" + Upgrade.executioner(command, command, 0) + + command = "sed -i 's|sgp.cyberpanel.sh|cdn.cyberpanel.sh|g' /etc/yum.repos.d/litespeed.repo" + Upgrade.executioner(command, command, 0) + + command = "sed -i 's|lax.cyberpanel.sh|cdn.cyberpanel.sh|g' /etc/yum.repos.d/litespeed.repo" + Upgrade.executioner(command, command, 0) + + command = "sed -i 's|fra.cyberpanel.sh|cdn.cyberpanel.sh|g' /etc/yum.repos.d/litespeed.repo" + Upgrade.executioner(command, command, 0) + + command = "sed -i 's|mirror.cyberpanel.net|cdn.cyberpanel.sh|g' /etc/yum.repos.d/litespeed.repo" + Upgrade.executioner(command, command, 0) + @staticmethod def mountTemp(): try: @@ -1982,6 +2008,8 @@ failovermethod=priority pdns = '/home/cyberpanel/pdns' pureftpd = '/home/cyberpanel/ftp' + Upgrade.updateRepoURL() + os.chdir("/usr/local") command = 'yum remove yum-plugin-priorities -y' diff --git a/websiteFunctions/tests.py b/websiteFunctions/tests.py index 2fbefb02a..cf67fd790 100755 --- a/websiteFunctions/tests.py +++ b/websiteFunctions/tests.py @@ -513,8 +513,38 @@ phpinfo(); self.assertEqual(exists, 1) - - + def test_addNewCron(self): + + ## Check cron creation + + data_ret = {'domain': 'cyberpanel.xyz', 'cronCommand': 'touch /home/cyberpanel.xyz/cron.txt' , 'hour': '*', 'minute': '*', 'month': '*', 'monthday': '*', 'weekday': '*'} + response = self.MakeRequest('websites/addNewCron', data_ret) + + time.sleep(65) + + self.assertEqual(response['addNewCron'], 1) + + import os + self.assertEqual(os.path.exists('/home/cyberpanel.xyz/cron.txt'), True) + + ## + + data_ret = {'domain': 'cyberpanel.xyz', 'line': 1} + response = self.MakeRequest('websites/remCronbyLine', data_ret) + + self.assertEqual(response['remCronbyLine'], 1) + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + cronPath = "/var/spool/cron/cyberpa" + else: + cronPath = "/var/spool/cron/crontabs/cyberpa" + + exists = 0 + + if open(cronPath, 'r').read().find('cron.txt') > -1: + exists = 1 + + self.assertEqual(exists, 0)