From f65c41593357c0b5657f5cc9090ea032cc50e96a Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Wed, 22 May 2024 09:58:14 +0200 Subject: [PATCH 1/2] chore: Add SSHLibrary to api.resource test --- tests/api.resource | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/api.resource diff --git a/tests/api.resource b/tests/api.resource new file mode 100644 index 0000000..e6b90ee --- /dev/null +++ b/tests/api.resource @@ -0,0 +1,14 @@ +*** Settings *** +Library SSHLibrary + +*** Keywords *** +Run task + [Arguments] ${action} ${input} ${decode_json}=${TRUE} ${rc_expected}=0 + ${stdout} ${stderr} ${rc} = Execute Command api-cli run ${action} --data '${input}' return_stdout=True return_stderr=True return_rc=True + Should Be Equal As Integers ${rc_expected} ${rc} Run task ${action} failed!${\n}${stderr} + IF ${decode_json} and len($stdout) > 0 + ${response} = Evaluate json.loads('''${stdout}''') modules=json + ELSE + ${response} = Set Variable ${stdout} + END + [Return] ${response} \ No newline at end of file From 454d44305924f4127b83b0d43888235ef437caac Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Wed, 22 May 2024 11:01:25 +0200 Subject: [PATCH 2/2] feat: Add api.resource to SSHLibrary test in postgresql.robot --- tests/postgresql.robot | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/postgresql.robot b/tests/postgresql.robot index 9725965..43344c6 100644 --- a/tests/postgresql.robot +++ b/tests/postgresql.robot @@ -1,5 +1,6 @@ *** Settings *** Library SSHLibrary +Resource api.resource *** Test Cases *** Check if postgresql is installed correctly @@ -10,16 +11,30 @@ Check if postgresql is installed correctly Set Suite Variable ${module_id} ${output.module_id} Check if postgresql can be configured - ${rc} = Execute Command api-cli run module/${module_id}/configure-module --data '{}' + ${rc} = Execute Command api-cli run module/${module_id}/configure-module --data '{"host":"postgresql.domain.org","http2https": true,"lets_encrypt": true}' ... return_rc=True return_stdout=False Should Be Equal As Integers ${rc} 0 -Check if postgresql works as expected - ${rc} = Execute Command curl -f http://127.0.0.1/postgresql/ - ... return_rc=True return_stdout=False - Should Be Equal As Integers ${rc} 0 +Check postgresql path is configured + ${ocfg} = Run task module/${module_id}/get-configuration {} + Set Suite Variable ${HOST} ${ocfg['host']} + Set Suite Variable ${HTTP2HTTPS} ${ocfg['http2https']} + Set Suite Variable ${LE_ENCRYPT} ${ocfg['lets_encrypt']} + Should Not Be Empty ${HOST} + Should Be True ${HTTP2HTTPS} + Should Be True ${LE_ENCRYPT} + +Check if posgresql works as expected + Wait Until Keyword Succeeds 20 times 3 seconds Ping postgresql Check if postgresql is removed correctly ${rc} = Execute Command remove-module --no-preserve ${module_id} ... return_rc=True return_stdout=False Should Be Equal As Integers ${rc} 0 + +*** Keywords *** +Ping postgresql + ${out} ${err} ${rc} = Execute Command curl -k -f -H 'Host: postgresql.domain.org' https://127.0.0.1/login + ... return_rc=True return_stdout=True return_stderr=True + Should Be Equal As Integers ${rc} 0 + Should Contain ${out} pgAdmin