From a9823bbbf93238315087ae5325e2fe8f8164ae4d Mon Sep 17 00:00:00 2001 From: Sudhir Menon Date: Wed, 26 Jun 2024 15:57:06 +0530 Subject: [PATCH] Added gating.yaml and tests for python-qrcode Signed-off-by: Sudhir Menon --- gating.yaml | 7 +++++++ tests/test_ipa_otptoken.py | 30 ++++++++++++++++++++++++++++++ tests/tests.yml | 10 ++++++++++ 3 files changed, 47 insertions(+) create mode 100644 gating.yaml create mode 100644 tests/test_ipa_otptoken.py create mode 100644 tests/tests.yml diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..122483d --- /dev/null +++ b/gating.yaml @@ -0,0 +1,7 @@ +# recipients: abokovoy, frenaud, kaleem, ftrivino, cheimes +--- !Policy +product_versions: + - rhel-10 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/tests/test_ipa_otptoken.py b/tests/test_ipa_otptoken.py new file mode 100644 index 0000000..412fdb8 --- /dev/null +++ b/tests/test_ipa_otptoken.py @@ -0,0 +1,30 @@ +#!/usr/libexec/platform-python +"""Simple test for APIs used by python3-qrcode +""" +import io +import logging +import hashlib + +import qrcode + +logging.basicConfig(level=logging.INFO) +log = logging.getLogger() + +TEXT = "example data" +HASH = "45100bc2be879090a4b219d4adf9e8342e123ba8cd74769343ef4b3656a3dc2f" + + +def main(): + qr_output = io.StringIO() + qr = qrcode.QRCode() + qr.add_data(TEXT) + qr.make() + qr.print_ascii(out=qr_output, tty=False) + value = qr_output.getvalue() + print(value) + assert hashlib.sha256(value.encode('utf-8')).hexdigest() == HASH + log.info("PASS") + + +if __name__ == "__main__": + main() diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..8aa91d9 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,10 @@ +- hosts: localhost + tags: + - classic + roles: + - role: standard-test-source + - role: standard-test-basic + tests: + - simple: + dir: "tests" + run: ./test_ipa_otptoken.py