From eaa753ab29bd5d1361cf8ada054cce4b279ff4b8 Mon Sep 17 00:00:00 2001 From: phala Date: Tue, 11 Jun 2024 12:34:38 +0200 Subject: [PATCH] Remove global unused-argument disables --- testsuite/oidc/auth0.py | 3 +-- testsuite/tests/conftest.py | 11 +++++------ testsuite/tests/kuadrant/authorino/conftest.py | 1 - .../tests/kuadrant/authorino/metrics/conftest.py | 3 +-- .../authorino/operator/clusterwide/conftest.py | 3 +-- .../kuadrant/authorino/operator/raw_http/conftest.py | 5 ++--- .../authorino/operator/raw_http/test_raw_http.py | 6 ++---- .../kuadrant/authorino/operator/sharding/conftest.py | 3 +-- .../kuadrant/authorino/operator/tls/test_webhook.py | 11 ++++------- .../tests/kuadrant/authorino/wristband/conftest.py | 3 +-- testsuite/tests/kuadrant/conftest.py | 5 ++--- 11 files changed, 20 insertions(+), 34 deletions(-) diff --git a/testsuite/oidc/auth0.py b/testsuite/oidc/auth0.py index d7d44667..a8180b7e 100644 --- a/testsuite/oidc/auth0.py +++ b/testsuite/oidc/auth0.py @@ -26,8 +26,7 @@ def well_known(self): response = httpx.get(self.domain + "/.well-known/openid-configuration") return response.json() - # pylint: disable=unused-argument - def refresh_token(self, refresh_token): + def refresh_token(self, refresh_token): # pylint: disable=unused-argument """Refresh tokens are not yet implemented for Auth0, will attempt to acquire new token instead""" return self.get_token() diff --git a/testsuite/tests/conftest.py b/testsuite/tests/conftest.py index d3053fad..66ac85af 100644 --- a/testsuite/tests/conftest.py +++ b/testsuite/tests/conftest.py @@ -99,8 +99,7 @@ def term_handler(): signal.signal(signal.SIGTERM, orig) -# pylint: disable=unused-argument -def pytest_collection_modifyitems(session, config, items): +def pytest_collection_modifyitems(session, config, items): # pylint: disable=unused-argument """ Add user properties to testcases for xml output @@ -150,7 +149,7 @@ def openshift2(testconfig, skip_or_fail): @pytest.fixture(scope="session") -def keycloak(request, testconfig, blame, skip_or_fail): +def keycloak(testconfig, blame, skip_or_fail): """Keycloak OIDC Provider fixture""" try: testconfig.validators.validate(only="keycloak") @@ -274,8 +273,8 @@ def kuadrant(request, testconfig): if request.config.getoption("--standalone"): return None - ocp = settings["service_protection"]["project"] - project = settings["service_protection"]["system_project"] + ocp = testconfig["service_protection"]["project"] + project = testconfig["service_protection"]["system_project"] kuadrant_openshift = ocp.change_project(project) try: @@ -362,7 +361,7 @@ def wildcard_domain(base_domain): @pytest.fixture(scope="module") -def client(route, hostname): +def client(route, hostname): # pylint: disable=unused-argument """Returns httpx client to be used for requests, it also commits AuthConfig""" client = hostname.client() yield client diff --git a/testsuite/tests/kuadrant/authorino/conftest.py b/testsuite/tests/kuadrant/authorino/conftest.py index c738ecd0..bf6d168d 100644 --- a/testsuite/tests/kuadrant/authorino/conftest.py +++ b/testsuite/tests/kuadrant/authorino/conftest.py @@ -36,7 +36,6 @@ def authorino(authorino, openshift, blame, request, testconfig, label) -> Author return authorino -# pylint: disable=unused-argument @pytest.fixture(scope="module") def authorization(authorization, oidc_provider, route, authorization_name, openshift, label) -> AuthConfig: """In case of Authorino, AuthConfig used for authorization""" diff --git a/testsuite/tests/kuadrant/authorino/metrics/conftest.py b/testsuite/tests/kuadrant/authorino/metrics/conftest.py index 3035847f..2f8361aa 100644 --- a/testsuite/tests/kuadrant/authorino/metrics/conftest.py +++ b/testsuite/tests/kuadrant/authorino/metrics/conftest.py @@ -61,9 +61,8 @@ def authorino(authorino, module_label): return authorino -# pylint: disable=unused-argument @pytest.fixture(scope="module") -def service_monitor(openshift, prometheus, blame, module_label): +def service_monitor(openshift, prometheus, blame, module_label): # pylint: disable=unused-argument """Create ServiceMonitor object to follow Authorino /metrics and /server-metrics endpoints""" endpoints = [MetricsEndpoint("/metrics", "http"), MetricsEndpoint("/server-metrics", "http")] return ServiceMonitor.create_instance(openshift, blame("sm"), endpoints, match_labels={"app": module_label}) diff --git a/testsuite/tests/kuadrant/authorino/operator/clusterwide/conftest.py b/testsuite/tests/kuadrant/authorino/operator/clusterwide/conftest.py index 696d045f..bd8f9871 100644 --- a/testsuite/tests/kuadrant/authorino/operator/clusterwide/conftest.py +++ b/testsuite/tests/kuadrant/authorino/operator/clusterwide/conftest.py @@ -44,9 +44,8 @@ def client2(hostname2): client.close() -# pylint: disable=unused-argument @pytest.fixture(scope="module", autouse=True) -def commit(request, commit, authorization2): +def commit(request, commit, authorization2): # pylint: disable=unused-argument """Commits all important stuff before tests""" request.addfinalizer(authorization2.delete) authorization2.commit() diff --git a/testsuite/tests/kuadrant/authorino/operator/raw_http/conftest.py b/testsuite/tests/kuadrant/authorino/operator/raw_http/conftest.py index b367c63a..3f39740b 100644 --- a/testsuite/tests/kuadrant/authorino/operator/raw_http/conftest.py +++ b/testsuite/tests/kuadrant/authorino/operator/raw_http/conftest.py @@ -9,9 +9,8 @@ from testsuite.openshift.route import OpenshiftRoute -# pylint: disable=unused-argument @pytest.fixture(scope="module") -def authorization(authorization, route, wildcard_domain, openshift, module_label) -> AuthConfig: +def authorization(authorization, route, wildcard_domain) -> AuthConfig: """In case of Authorino, AuthConfig used for authorization""" authorization.remove_all_hosts() route.add_hostname(wildcard_domain) @@ -20,7 +19,7 @@ def authorization(authorization, route, wildcard_domain, openshift, module_label @pytest.fixture(scope="module") -def client(authorization, authorino_route): +def client(authorino_route): """Returns httpx client to be used for requests, it also commits AuthConfig""" client = KuadrantClient(base_url=f"http://{authorino_route.model.spec.host}", verify=False) yield client diff --git a/testsuite/tests/kuadrant/authorino/operator/raw_http/test_raw_http.py b/testsuite/tests/kuadrant/authorino/operator/raw_http/test_raw_http.py index 514cb181..9e3e7366 100644 --- a/testsuite/tests/kuadrant/authorino/operator/raw_http/test_raw_http.py +++ b/testsuite/tests/kuadrant/authorino/operator/raw_http/test_raw_http.py @@ -7,8 +7,7 @@ pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only] -# pylint: disable=unused-argument -def test_authorized_via_http(authorization, client, auth): +def test_authorized_via_http(client, auth): """Test raw http authentication with Keycloak.""" response = client.get("/check", auth=auth) assert response.status_code == 200 @@ -16,8 +15,7 @@ def test_authorized_via_http(authorization, client, auth): assert response.headers.get("x-ext-auth-other-json", "") == '{"propX":"valueX"}' -# pylint: disable=unused-argument -def test_unauthorized_via_http(authorization, client): +def test_unauthorized_via_http(client): """Test raw http authentication with unauthorized request.""" response = client.get("/check") assert response.status_code == 401 diff --git a/testsuite/tests/kuadrant/authorino/operator/sharding/conftest.py b/testsuite/tests/kuadrant/authorino/operator/sharding/conftest.py index e7f56636..a55ce817 100644 --- a/testsuite/tests/kuadrant/authorino/operator/sharding/conftest.py +++ b/testsuite/tests/kuadrant/authorino/operator/sharding/conftest.py @@ -44,9 +44,8 @@ def _route(hostname, gateway): return _route -# pylint: disable=unused-argument @pytest.fixture(scope="module") -def setup_authorization(request, blame, openshift, label): +def setup_authorization(request, blame, openshift, label): # pylint: disable=unused-argument """Factory method for creating AuthConfigs in the test run""" def _authorization(route, sharding_label=None): diff --git a/testsuite/tests/kuadrant/authorino/operator/tls/test_webhook.py b/testsuite/tests/kuadrant/authorino/operator/tls/test_webhook.py index c354fa31..5dcf0d23 100644 --- a/testsuite/tests/kuadrant/authorino/operator/tls/test_webhook.py +++ b/testsuite/tests/kuadrant/authorino/operator/tls/test_webhook.py @@ -67,9 +67,8 @@ def authorino_parameters(authorino_parameters, specific_authorino_name): return authorino_parameters -# pylint: disable=unused-argument @pytest.fixture(scope="module") -def authorization(authorization, openshift, module_label, authorino_domain) -> AuthConfig: +def authorization(authorization, openshift, authorino_domain) -> AuthConfig: """In case of Authorino, AuthConfig used for authorization""" # Authorino should have specific url so it is accessible by k8s webhook @@ -116,7 +115,7 @@ def authorization(authorization, openshift, module_label, authorino_domain) -> A return authorization -@pytest.fixture(scope="module") +@pytest.fixture(scope="module", autouse=True) def validating_webhook(openshift, authorino_domain, certificates, blame): """Create validating webhook.""" name = blame("check-ingress") + ".authorino.kuadrant.io" @@ -157,8 +156,7 @@ def validating_webhook(openshift, authorino_domain, certificates, blame): webhook.delete() -# pylint: disable=unused-argument -def test_authorized_via_http(authorization, openshift, authorino, authorino_domain, validating_webhook, blame): +def test_authorized_via_http(openshift, blame): """Test raw http authorization via webhooks.""" ingress = Ingress.create_instance(openshift, blame("minimal-ingress"), rules=[{}]) ingress.commit() @@ -166,8 +164,7 @@ def test_authorized_via_http(authorization, openshift, authorino, authorino_doma ingress.delete() -# pylint: disable=unused-argument -def test_unauthorized_via_http(authorization, openshift, authorino, authorino_domain, validating_webhook, blame): +def test_unauthorized_via_http(openshift, blame): """Test raw http authorization via webhooks but for unauthorized object.""" ingress = Ingress.create_instance(openshift, blame("minimal-ingress"), rules=[{}, {}]) with pytest.raises(OpenShiftPythonException, match="Unauthorized"): diff --git a/testsuite/tests/kuadrant/authorino/wristband/conftest.py b/testsuite/tests/kuadrant/authorino/wristband/conftest.py index d27bccb3..d1e8bde1 100644 --- a/testsuite/tests/kuadrant/authorino/wristband/conftest.py +++ b/testsuite/tests/kuadrant/authorino/wristband/conftest.py @@ -123,9 +123,8 @@ def wristband_authorization( return authorization -# pylint: disable=unused-argument @pytest.fixture(scope="module", autouse=True) -def commit(request, commit, wristband_authorization): +def commit(request, commit, wristband_authorization): # pylint: disable=unused-argument """Commits all important stuff before tests""" request.addfinalizer(wristband_authorization.delete) wristband_authorization.commit() diff --git a/testsuite/tests/kuadrant/conftest.py b/testsuite/tests/kuadrant/conftest.py index 8090249f..d08a869f 100644 --- a/testsuite/tests/kuadrant/conftest.py +++ b/testsuite/tests/kuadrant/conftest.py @@ -7,7 +7,6 @@ from testsuite.policy.rate_limit_policy import RateLimitPolicy -# pylint: disable=unused-argument @pytest.fixture(scope="session") def authorino(kuadrant): """Authorino instance when configured through Kuadrant""" @@ -24,7 +23,7 @@ def authorization_name(blame): @pytest.fixture(scope="module") -def authorization(kuadrant, oidc_provider, route, authorization_name, openshift, label): +def authorization(kuadrant, route, authorization_name, openshift, label): """Authorization object (In case of Kuadrant AuthPolicy)""" if kuadrant: return AuthPolicy.create_instance(openshift, authorization_name, route, labels={"testRun": label}) @@ -32,7 +31,7 @@ def authorization(kuadrant, oidc_provider, route, authorization_name, openshift, @pytest.fixture(scope="module") -def rate_limit(kuadrant, openshift, blame, request, module_label, route, gateway): +def rate_limit(kuadrant, openshift, blame, request, module_label, route, gateway): # pylint: disable=unused-argument """ Rate limit object. Request is used for indirect parametrization, with two possible parameters: