Skip to content

Commit

Permalink
Annotate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pehala committed Feb 7, 2024
1 parent 7b881f9 commit 696a10c
Show file tree
Hide file tree
Showing 68 changed files with 144 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from testsuite.utils import rego_allow_header


pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def updated_header():
"""Header for updated OPA policy"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""Tests for Open Policy Agent (OPA) using Mockserver Expectations as http endpoint with Rego query"""

import pytest

pytestmark = [pytest.mark.authorino]


def test_allowed_by_opa(client, auth, header):
"""Tests a request that should be authorized by OPA external registry declaration"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from testsuite.utils import rego_allow_header

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def header():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from testsuite.utils import extract_response


pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def cache_ttl():
"""Returns TTL in seconds for Cached Metadata"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from testsuite.utils import extract_response

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization, module_label, expectation_path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from testsuite.policy.authorization import Pattern

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from testsuite.policy.authorization import Pattern
from testsuite.httpx.auth import HeaderApiKeyAuth

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def api_key(create_api_key, module_label):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from testsuite.policy.authorization import Pattern

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def mockserver_expectation(request, mockserver, module_label):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from testsuite.policy.authorization import Pattern, Value, JsonResponse
from testsuite.utils import extract_response

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from testsuite.policy.authorization import Pattern, PatternRef, AnyPattern, AllPattern

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from testsuite.policy.authorization import Pattern

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization, module_label):
Expand Down
2 changes: 2 additions & 0 deletions testsuite/tests/kuadrant/authorino/dinosaur/test_dinosaur.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pytest

pytestmark = [pytest.mark.authorino]

ERROR_MESSAGE = {
"kind": "Error",
"id": "403",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from testsuite.utils import extract_response

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import pytest

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization, rhsso):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from testsuite.utils import extract_response

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization, api_key):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from testsuite.policy.authorization import Credentials

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module", params=["authorizationHeader", "customHeader", "queryString", "cookie"])
def credentials(request):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from testsuite.openshift import Selector, MatchExpression


pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def valid_label_selectors(module_label):
"""Accepted labels for selector.matchExpressions in AuthConfig"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import pytest


pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization, api_key):
"""Creates AuthConfig with API key identity"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from testsuite.httpx.auth import HeaderApiKeyAuth
from testsuite.openshift import Selector

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="function")
def api_key(create_api_key, module_label):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from testsuite.oidc import OIDCProvider
from testsuite.oidc.rhsso import RHSSO

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization, oidc_provider):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from testsuite.httpx.auth import HttpxOidcClientAuth

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def auth0_auth(auth0):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from testsuite.policy.authorization import Value, ValueFrom
from testsuite.utils import extract_response

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization, rhsso):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from testsuite.policy.authorization import Value
from testsuite.utils import extract_response

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from testsuite.policy.authorization import Pattern, Value, ValueFrom
from testsuite.httpx.auth import HeaderApiKeyAuth, HttpxOidcClientAuth

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def api_key(create_api_key, module_label):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from testsuite.policy.authorization import Credentials

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module", params=["authorizationHeader", "customHeader", "queryString", "cookie"])
def credentials(request):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from testsuite.policy.authorization import ValueFrom, JsonResponse

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def authorization(authorization):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import pytest
from testsuite.httpx.auth import HttpxOidcClientAuth

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="function")
def user_with_role(rhsso, realm_role, blame):
Expand Down
3 changes: 3 additions & 0 deletions testsuite/tests/kuadrant/authorino/metadata/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

from testsuite.utils import ContentType

pytestmark = [pytest.mark.authorino]


ALLOWED_COUNTRY = {"countryCode": "SK"}
CHECK_COUNTRY_REGO = """allow {
split(input.context.request.http.path, "/") = [_, _, country_code]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from testsuite.utils import ContentType, extract_response

pytestmark = [pytest.mark.authorino]

MULTI_ELEMENT_JSON = '{"foo": "bar"}\n{"blah": "bleh"}'

Expand Down
2 changes: 2 additions & 0 deletions testsuite/tests/kuadrant/authorino/metadata/test_uma.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from testsuite.httpx.auth import HttpxOidcClientAuth

pytestmark = [pytest.mark.authorino]

VALIDATE_RESOURCE_OWNER = """
metadata := object.get(input.auth.metadata, "resource-data", [])[0]
Expand Down
2 changes: 2 additions & 0 deletions testsuite/tests/kuadrant/authorino/metadata/test_user_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from testsuite.httpx.auth import HttpxOidcClientAuth
from testsuite.policy.authorization import Pattern

pytestmark = [pytest.mark.authorino]


@pytest.fixture(scope="module")
def user2(rhsso, blame):
Expand Down
6 changes: 0 additions & 6 deletions testsuite/tests/kuadrant/authorino/metrics/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
from testsuite.openshift.metrics import ServiceMonitor, MetricsEndpoint, Prometheus


@pytest.fixture(scope="module")
def run_on_kuadrant():
"""Kuadrant doesn't allow customization of Authorino parameters"""
return False


@pytest.fixture(scope="module")
def prometheus(request, openshift):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from testsuite.policy.authorization import Value, JsonResponse

pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only]


@pytest.fixture(scope="module")
def mockserver_expectation(request, mockserver, module_label):
Expand Down
1 change: 1 addition & 0 deletions testsuite/tests/kuadrant/authorino/metrics/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only]

METRICS = [
"controller_runtime_reconcile_total",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""Tests AuthConfig with multiple specified hosts"""

import pytest

pytestmark = [pytest.mark.authorino]


def test_original_host(client, auth):
"""Tests correct host"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""Test host removal"""

import pytest

pytestmark = [pytest.mark.authorino]


def test_removing_host(client, client2, auth, route, second_hostname):
"""Tests that after removal of the second host, it stops working, while the first one still works"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from testsuite.httpx.auth import HeaderApiKeyAuth

pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only]


@pytest.fixture(scope="module")
def api_key(create_api_key, module_label, openshift2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import pytest

pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only]


@pytest.mark.parametrize(
"client_fixture",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from testsuite.policy.authorization import Value, JsonResponse
from testsuite.policy.authorization.auth_config import AuthConfig

pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only]


@pytest.fixture(scope="module")
def route(route, wildcard_domain, hostname):
Expand Down
9 changes: 0 additions & 9 deletions testsuite/tests/kuadrant/authorino/operator/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
"""Module containing common features of all Operator tests"""

import pytest


@pytest.fixture(scope="module")
def run_on_kuadrant():
"""Kuadrant doesn't allow customization of Authorino parameters"""
return False
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Test raw http authorization interface.
"""

import pytest

pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only]


# pylint: disable=unused-argument
def test_authorized_via_http(authorization, client, auth):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from testsuite.openshift.authorino import AuthorinoCR

pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only]


@pytest.fixture(scope="module")
def setup_authorino(openshift, blame, testconfig, module_label, request):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import pytest

pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only]


@pytest.fixture(scope="module")
def authorino_parameters(authorino_parameters):
Expand Down
Loading

0 comments on commit 696a10c

Please sign in to comment.