def test_basic_auth(self, tmp_path): config = AuthConfig(path=tmp_path) with mock.patch.object(openeo.rest.auth.config, "utcnow_rfc3339", return_value="2020-06-08T11:18:27Z"): config.set_basic_auth("oeo.test", "John", "j0hn123") assert config.path.exists() assert [p.name for p in tmp_path.iterdir()] == [AuthConfig.DEFAULT_FILENAME] with config.path.open("r") as f: data = json.load(f) assert data["backends"] == { "oeo.test": { "basic": { "date": "2020-06-08T11:18:27Z", "username": "******", "password": "******" } } } assert config.get_basic_auth("oeo.test") == ("John", "j0hn123") assert config.get_basic_auth("oeo.test") == ("John", "j0hn123")
def test_start_empty(self, tmp_path): config = AuthConfig(path=tmp_path) assert config.get_basic_auth("foo") == (None, None) assert config.get_oidc_client_configs("oeo.test", "default") == (None, None)
def test_basic_auth_url_normalization(self, tmp_path, to_set, to_get): config = AuthConfig(path=tmp_path) config.set_basic_auth(to_set, "John", "j0hn123") assert config.get_basic_auth(to_set) == ("John", "j0hn123") assert config.get_basic_auth(to_get) == ("John", "j0hn123")