mirror of
https://github.com/nextcloud/nextcloudpi.git
synced 2026-01-10 15:12:01 -03:30
activation_tests, nextcloud_tests: Make ports configurable
This commit is contained in:
parent
7b809d114b
commit
33067ddfde
@ -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
|
||||
#
|
||||
|
||||
@ -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
|
||||
#
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user