Skip to content

Commit

Permalink
Merge pull request #431 from pehala/remove_unused
Browse files Browse the repository at this point in the history
Remove global unused-argument disables
  • Loading branch information
pehala authored Jun 17, 2024
2 parents 7e93506 + eaa753a commit 75256a8
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 34 deletions.
3 changes: 1 addition & 2 deletions testsuite/oidc/auth0.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
11 changes: 5 additions & 6 deletions testsuite/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion testsuite/tests/kuadrant/authorino/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
3 changes: 1 addition & 2 deletions testsuite/tests/kuadrant/authorino/metrics/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
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
assert response.text == ""
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 4 additions & 7 deletions testsuite/tests/kuadrant/authorino/operator/tls/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -157,17 +156,15 @@ 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()
assert ingress.model.metadata.creationTimestamp
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"):
Expand Down
3 changes: 1 addition & 2 deletions testsuite/tests/kuadrant/authorino/wristband/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions testsuite/tests/kuadrant/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -24,15 +23,15 @@ 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})
return None


@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:
Expand Down

0 comments on commit 75256a8

Please sign in to comment.