Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias K <6317548+theCalcaholic@users.noreply.github.com>2021-07-07 16:41:30 +0300
committerTobias K <6317548+theCalcaholic@users.noreply.github.com>2021-07-07 16:41:30 +0300
commit33067ddfde684a7a62701d066175252aa5a2eafe (patch)
treee1cdb107e2fca86ca69eea61aeff27c54793bf25
parent7b809d114b06c761d3662a8eb1c734b43503b688 (diff)
activation_tests, nextcloud_tests: Make ports configurable
-rwxr-xr-xtests/activation_tests.py20
-rwxr-xr-xtests/nextcloud_tests.py13
-rwxr-xr-xtests/system_tests.py11
3 files changed, 36 insertions, 8 deletions
diff --git a/tests/activation_tests.py b/tests/activation_tests.py
index 84c1e247..3b8e5fec 100755
--- a/tests/activation_tests.py
+++ b/tests/activation_tests.py
@@ -32,6 +32,7 @@ suite_name = "activation tests"
test_cfg = 'test_cfg.txt'
test_log = 'test_log.txt'
+
class tc:
"terminal colors"
brown='\033[33m'
@@ -40,9 +41,11 @@ class tc:
red='\033[31m'
normal='\033[0m'
+
def usage():
"Print usage"
- print("usage: activation_tests.py [ip]")
+ print("usage: activation_tests.py [ip [nc-port [admin-port]]]")
+
class Test:
title = "test"
@@ -74,15 +77,18 @@ class Test:
with open(test_log, 'w') as logfile:
config.write(logfile)
+
def is_element_present(driver, how, what):
try: driver.find_element(by=how, value=what)
except NoSuchElementException: return False
return True
+
def signal_handler(sig, frame):
sys.exit(0)
-def test_activation(IP):
+
+def test_activation(IP, nc_port, admin_port):
""" Activation process checks"""
# activation page
@@ -90,7 +96,7 @@ def test_activation(IP):
driver = webdriver.Firefox(service_log_path='/dev/null')
driver.implicitly_wait(5)
test.new("activation opens")
- driver.get("https://" + IP)
+ driver.get(f"https://{IP}:{nc_port}")
test.check("NextCloudPi Activation" in driver.title)
try:
ncp_pass = driver.find_element_by_id("ncp-pwd").get_attribute("value")
@@ -128,7 +134,7 @@ def test_activation(IP):
test.new("ncp-web")
driver = webdriver.Firefox(service_log_path='/dev/null')
try:
- driver.get("https://ncp:" + urllib.parse.quote_plus(ncp_pass) + "@" + IP + ":4443")
+ driver.get(f"https://ncp:{urllib.parse.quote_plus(ncp_pass)}@{IP}:{admin_port}")
except UnexpectedAlertPresentException:
pass
test.check("NextCloudPi Panel" in driver.title)
@@ -136,6 +142,7 @@ def test_activation(IP):
driver.close()
+
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal_handler)
@@ -155,10 +162,13 @@ if __name__ == "__main__":
sys.exit(2)
# test
+
IP = args[0] if len(args) > 0 else 'localhost'
+ nc_port = args[1] if len(args) > 1 else "443"
+ admin_port = args[2] if len(args) > 2 else "4443"
print("Activation tests " + tc.yellow + IP + tc.normal)
print("---------------------------")
- test_activation(IP)
+ test_activation(IP, nc_port, admin_port)
# License
#
diff --git a/tests/nextcloud_tests.py b/tests/nextcloud_tests.py
index c4346bfe..f68d9c81 100755
--- a/tests/nextcloud_tests.py
+++ b/tests/nextcloud_tests.py
@@ -29,6 +29,7 @@ suite_name = "nextcloud tests"
test_cfg = 'test_cfg.txt'
test_log = 'test_log.txt'
+
class tc:
"terminal colors"
brown='\033[33m'
@@ -37,6 +38,7 @@ class tc:
red='\033[31m'
normal='\033[0m'
+
class Test:
title = "test"
@@ -67,22 +69,25 @@ class Test:
with open(test_log, 'w') as logfile:
config.write(logfile)
+
def usage():
"Print usage"
print("usage: nextcloud_tests.py [--new] [ip]")
print("--new removes saved configuration")
+
def signal_handler(sig, frame):
sys.exit(0)
-def test_nextcloud(IP):
+
+def test_nextcloud(IP, nc_port):
""" Login and assert admin page checks"""
test = Test()
driver = webdriver.Firefox(service_log_path='/dev/null')
driver.implicitly_wait(60)
test.new("nextcloud page")
try:
- driver.get("https://" + IP + "/index.php/settings/admin/overview")
+ driver.get(f"https://{IP}:{nc_port}/index.php/settings/admin/overview")
except:
test.check(False)
print(tc.red + "error:" + tc.normal + " unable to reach " + tc.yellow + IP + tc.normal)
@@ -107,6 +112,7 @@ def test_nextcloud(IP):
driver.close()
+
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal_handler)
@@ -155,9 +161,10 @@ if __name__ == "__main__":
# test
IP = args[0] if len(args) > 0 else 'localhost'
+ nc_port = args[1] if len(args) > 1 else "443"
print("Nextcloud tests " + tc.yellow + IP + tc.normal)
print("---------------------------")
- test_nextcloud(IP)
+ test_nextcloud(IP, nc_port)
# License
#
diff --git a/tests/system_tests.py b/tests/system_tests.py
index 2564af5b..4a2b2648 100755
--- a/tests/system_tests.py
+++ b/tests/system_tests.py
@@ -66,10 +66,12 @@ class tc:
red='\033[31m'
normal='\033[0m'
+
def usage():
"Print usage"
print("usage: system_tests.py [user@ip]")
+
def is_running(process):
"check that a process is running"
print("[running] " + tc.brown + "{:16}".format(process) + tc.normal, end=' ')
@@ -80,6 +82,7 @@ def is_running(process):
print(tc.red + "error" + tc.normal)
return result.returncode == 0
+
def file_exists(file):
"check that a file exists"
print("[exists ] " + tc.brown + "{:16}".format(file) + tc.normal, end=' ')
@@ -90,6 +93,7 @@ def file_exists(file):
print(tc.red + "error" + tc.normal)
return result.returncode == 0
+
def file_not_exists(file):
"check that a file doesn't exist"
print("[nexists] " + tc.brown + "{:16}".format(file) + tc.normal, end=' ')
@@ -100,6 +104,7 @@ def file_not_exists(file):
print(tc.red + "error" + tc.normal)
return result.returncode == 0
+
def check_processes_running(processes):
"check that all processes are running"
ret = True
@@ -108,6 +113,7 @@ def check_processes_running(processes):
ret = False
return ret
+
def is_installed(binary):
"check that a binary is installed"
print("[install] " + tc.brown + "{:16}".format(binary) + tc.normal, end=' ')
@@ -118,6 +124,7 @@ def is_installed(binary):
print(tc.red + "error" + tc.normal)
return result.returncode == 0
+
def check_binaries_installed(binaries):
"check that all the binaries are installed"
ret = True
@@ -126,6 +133,7 @@ def check_binaries_installed(binaries):
ret = False
return ret
+
def check_files_exist(files):
"check that all the files exist"
ret = True
@@ -134,6 +142,7 @@ def check_files_exist(files):
ret = False
return ret
+
def check_files_dont_exist(files):
"check that all the files don't exist"
ret = True
@@ -142,9 +151,11 @@ def check_files_dont_exist(files):
ret = False
return ret
+
def signal_handler(sig, frame):
sys.exit(0)
+
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal_handler)