From 66e06ec893bad0c4c0066003eb41b2873c857dc8 Mon Sep 17 00:00:00 2001 From: Tomas Halman Date: Mon, 24 Oct 2022 14:54:51 +0200 Subject: [PATCH] Add gating tests Related: rhbz#1984046 - python-oauthlib depends on jwt for RSA --- gating.yaml | 6 +++++ tests/oauthtests.sh | 48 ++++++++++++++++++++++++++++++++++++ tests/requirements-tests.txt | 2 ++ tests/tests.yml | 17 +++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 gating.yaml create mode 100755 tests/oauthtests.sh create mode 100644 tests/requirements-tests.txt create mode 100644 tests/tests.yml diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..648918d --- /dev/null +++ b/gating.yaml @@ -0,0 +1,6 @@ +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/tests/oauthtests.sh b/tests/oauthtests.sh new file mode 100755 index 0000000..cbe06d0 --- /dev/null +++ b/tests/oauthtests.sh @@ -0,0 +1,48 @@ +#!/bin/bash -x + +die () { + echo "$1" >&2 + exit 1 +} + +SITEDIR=`python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'` +if [ "$SITEDIR" == "" ]; then + die "Can't locate python site dir" +fi + +# +# install dependencies (pytest & blinker) +# +rm -rf venv +python3 -m venv venv +. venv/bin/activate +pip install -r requirements-tests.txt + + +# rename source code directory to be sure that we are +# testing files from our rpm +cd source || die "Missing source directory!" +if [ -d oauthlib ] ; then + mv oauthlib oauthlib.backup || die "Can't rename/hide source code directory!" +fi +ln -s $SITEDIR/oauthlib || die "Can't locate installed library" + +# +# run upstream tests, skip jwt tests +# +echo 'import pytest; __getattr__ = lambda _: pytest.skip("this test needs jwt")' > jwt.py +pytest tests -p no:warnings --ignore tests/oauth2/rfc6749/clients/test_service_application.py | tee oauthlib.log +RESULT=${PIPESTATUS[0]} + +# +# cleanup +# +rm jwt.py +if [ -L oauthlib ] ; then + rm oauthlib +fi +if [ -d oauthlib.backup ] ; then + mv oauthlib.backup oauthlib +fi + +exit $RESULT diff --git a/tests/requirements-tests.txt b/tests/requirements-tests.txt new file mode 100644 index 0000000..176ffef --- /dev/null +++ b/tests/requirements-tests.txt @@ -0,0 +1,2 @@ +blinker==1.5 +pytest==7.2 diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..e44be58 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,17 @@ +--- +- hosts: localhost + roles: + - role: standard-test-source + tags: + - always + + - role: standard-test-basic + tags: + - classic + required_packages: + - python3-oauthlib + tests: + - oauthtests: + dir: . + run: ./oauthtests.sh + save-files: ["source/*.log"]