From c8e9342a0fc48a3afefcc3a49146ccd7d1299c26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sachse?= <joerg.sachse@slub-dresden.de> Date: Fri, 20 Oct 2023 14:11:01 +0200 Subject: [PATCH] test: add tests to verify CGI binaries work as expected (with more to implement) --- .gitlab-ci.yml | 2 +- molecule/resources/playbooks/verify.yml | 31 +++++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index de58472..0f64fa6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,4 +36,4 @@ test-job: - molecule create --scenario-name default - molecule converge --scenario-name default - molecule idempotence --scenario-name default - # - molecule verify --scenario-name default + - molecule verify --scenario-name default diff --git a/molecule/resources/playbooks/verify.yml b/molecule/resources/playbooks/verify.yml index e707420..c2e0f39 100644 --- a/molecule/resources/playbooks/verify.yml +++ b/molecule/resources/playbooks/verify.yml @@ -1,10 +1,33 @@ --- -# This is an example playbook to execute Ansible tests. - - name: Verify hosts: all gather_facts: false tasks: - - name: Example assertion + - name: get result for CGI-Binaries + ansible.builtin.command: + cmd: "/usr/lib/cgi-bin/{{ item }}" + loop: + - "convert_to" + - "is_valid" + register: cgi_binaries + changed_when: false + # The return code is 1 when calling the CGI-Binaries on the commandline, + # because the environment is not right and we're not PUTting a PDF file, so + # we expect failure. That's OK, we just want to see if it crashes or + # returns a nice HTML structure. + # This test does NOT tell us anything about the use of the correct + # libcgicc version. To do this, we would need to upload a file to tcp/8080 + # and observe apache2/error.log output. If you feel up to the task of + # writing an appropriate test, please feel free to do so. + # If you try, expect the following apache error messages: + # [Thu Oct 19 13:28:12.252241 2023] [cgid:error] [pid 34681:tid 140007369025216] [client 10.0.2.2:56994] End of script output before headers: is_valid, referer: http://localhost:8080/cgi-bin/is_valid/pdfa + # terminate called after throwing an instance of 'PTB::exc' + # what(): The PDF file is corrupt, it could not be opened + failed_when: false + - name: evaluate return code and message for CGI-Binaries ansible.builtin.assert: - that: true + that: + - ( 'Content-Type: text/html' in item.stdout ) + - ( '<html><head' in item.stdout ) + quiet: true + loop: "{{ cgi_binaries.results }}" -- GitLab