updateRepoURL

This commit is contained in:
Usman Nasir
2019-11-25 18:00:31 +05:00
parent be72d844e4
commit 44f2994cff
4 changed files with 107 additions and 11 deletions

View File

@@ -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)

View File

@@ -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:

View File

@@ -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'

View File

@@ -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)