diff --git a/config.json.example b/config.json.example index 0ae4df26..8aab7943 100644 --- a/config.json.example +++ b/config.json.example @@ -9,7 +9,6 @@ "generate_swagger": false, "host": "127.0.0.1", "port": "5000", - "test_username": "root", - "test_password": "pw", + "test_user_credentials": {"username": "root", "password": "pw"}, "test_mechanism": "simple" } diff --git a/datagateway_api/common/config.py b/datagateway_api/common/config.py index 7ae31b9e..cdc26b97 100644 --- a/datagateway_api/common/config.py +++ b/datagateway_api/common/config.py @@ -76,17 +76,11 @@ def get_port(self): except KeyError: sys.exit("Missing config value, port") - def get_test_username(self): + def get_test_user_credentials(self): try: - return self.config["test_username"] + return self.config["test_user_credentials"] except KeyError: - sys.exit("Missing config value, test_username") - - def get_test_password(self): - try: - return self.config["test_password"] - except KeyError: - sys.exit("Missing config value, test_password") + sys.exit("Missing config value, test_user_credentials") def get_test_mechanism(self): try: diff --git a/test/icat/test_config.py b/test/icat/test_config.py index 57ac2c20..dee771c4 100644 --- a/test/icat/test_config.py +++ b/test/icat/test_config.py @@ -120,24 +120,14 @@ def test_invalid_port(self, invalid_config): invalid_config.get_icat_url() -class TestGetTestUsername: - def test_valid_test_username(self, valid_config): - test_username = valid_config.get_test_username() - assert test_username == "root" +class TestGetTestUserCredentials: + def test_valid_test_user_credentials(self, valid_config): + test_user_credentials = valid_config.get_test_user_credentials() + assert test_user_credentials == {"username": "root", "password": "pw"} - def test_invalid_test_username(self, invalid_config): + def test_invalid_test_user_credentials(self, invalid_config): with pytest.raises(SystemExit): - invalid_config.get_test_username() - - -class TestGetTestPassword: - def test_valid_test_password(self, valid_config): - test_password = valid_config.get_test_password() - assert test_password == "pw" - - def test_invalid_test_password(self, invalid_config): - with pytest.raises(SystemExit): - invalid_config.get_test_password() + invalid_config.get_test_user_credentials() class TestGetTestMechanism: