Page MenuHomeSoftware Heritage

pytest_plugin: Add generic keycloak_oidc fixture instantiation
ClosedPublic

Authored by anlambert on Mar 25 2021, 6:45 PM.

Details

Summary

This will simplify fixture use in external modules that use the
pytest plugin.

A second commit turns realm_name and client_id from the
KeycloakOpenIDConnect class into properties.
It enables to properly override those values by getting / setting them
from / to the wrapped keycloak.KeycloakOpenID instance.

The purpose is to easily override the fixture and its parameters
in external module tests, see below:

conftest.py
import pytest

pytest_plugins = ["swh.auth.pytest_plugin"]

@pytest.fixture
def keycloak_oidc(keycloak_oidc):
    keycloak_oidc.server_url = "..."
    keycloak_oidc.realm_name = "..."
    keycloak_oidc.client_id = "..."
    return keycloak_oidc

Diff Detail

Repository
rDAUTH Common authentication libraries
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D5344 (id=19152)

Rebasing onto 88e7075a85...

Current branch diff-target is up to date.
Changes applied before test
commit 4ca67f65e07aa16e5976244bef059e1dee2a6d80
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Thu Mar 25 18:38:39 2021 +0100

    keycloak: Turn realm_name and client_id into properties
    
    It enables to properly override those values by getting / setting them
    from / to the wrapped KeycloakOpenID instance.

commit e1846a0e49a89a867552f945bf9db56d9d079fa4
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Thu Mar 25 18:36:23 2021 +0100

    pytest_plugin: Add generic keycloak_oidc fixture instantiation
    
    This will simplify fixture use in external modules that use the
    pytest plugin.

See https://jenkins.softwareheritage.org/job/DAUTH/job/tests-on-diff/56/ for more details.

This revision is now accepted and ready to land.Mar 25 2021, 6:54 PM