web-base/test/installTest.py

54 lines
2.3 KiB
Python
Raw Normal View History

2020-04-02 15:08:14 +02:00
from phpTest import PhpTest
2020-04-02 16:16:58 +02:00
import sys
2020-04-02 15:08:14 +02:00
class InstallTestCase(PhpTest):
2020-04-02 13:54:54 +02:00
def __init__(self, args):
2020-04-02 16:16:58 +02:00
super().__init__({
"Testing connection…": self.test_connection,
"Testing database setup…": self.test_database_setup,
"Testing invalid usernames…": self.test_invalid_usernames,
"Testing invalid password…": self.test_invalid_password,
"Testing not matching password…": self.test_not_matching_passwords,
"Testing user creation…": self.test_create_user,
"Testing skip mail configuration…": self.test_skil_mail_config,
"Testing complete setup…": self.test_complete_setup,
})
2020-04-02 13:54:54 +02:00
self.args = args
2020-04-02 16:16:58 +02:00
def test_connection(self):
self.httpGet()
2020-04-02 13:54:54 +02:00
2020-04-02 16:16:58 +02:00
def test_database_setup(self):
obj = self.httpPost(data=vars(self.args))
self.assertEquals(True, obj["success"], obj["msg"])
2020-04-02 13:54:54 +02:00
2020-04-02 16:16:58 +02:00
def test_invalid_usernames(self):
2020-04-02 13:54:54 +02:00
for username in ["a", "a"*33]:
2020-04-02 16:16:58 +02:00
obj = self.httpPost(data={ "username": username, "password": "123456", "confirmPassword": "123456" })
2020-04-02 13:54:54 +02:00
self.assertEquals(False, obj["success"])
self.assertEquals("The username should be between 5 and 32 characters long", obj["msg"])
2020-04-02 16:16:58 +02:00
def test_invalid_password(self):
obj = self.httpPost(data={ "username": PhpTest.ADMIN_USERNAME, "password": "1", "confirmPassword": "1" })
2020-04-02 13:54:54 +02:00
self.assertEquals(False, obj["success"])
self.assertEquals("The password should be at least 6 characters long", obj["msg"])
2020-04-02 16:16:58 +02:00
def test_not_matching_passwords(self):
obj = self.httpPost(data={ "username": PhpTest.ADMIN_USERNAME, "password": "1", "confirmPassword": "2" })
2020-04-02 13:54:54 +02:00
self.assertEquals(False, obj["success"])
self.assertEquals("The given passwords do not match", obj["msg"])
2020-04-02 16:16:58 +02:00
def test_create_user(self):
obj = self.httpPost(data={ "username": PhpTest.ADMIN_USERNAME, "password": PhpTest.ADMIN_PASSWORD, "confirmPassword": PhpTest.ADMIN_PASSWORD })
self.assertEquals(True, obj["success"], obj["msg"])
2020-04-02 13:54:54 +02:00
2020-04-02 16:16:58 +02:00
def test_skil_mail_config(self):
obj = self.httpPost(data={ "skip": "true" })
self.assertEquals(True, obj["success"], obj["msg"])
2020-04-02 13:54:54 +02:00
2020-04-02 16:16:58 +02:00
def test_complete_setup(self):
res = self.httpGet()
self.assertTrue("Installation finished" in res.text)