From 38d2e934e119ebf021a1597723e73b6358dc7cd2 Mon Sep 17 00:00:00 2001 From: Matteo Valentini Date: Tue, 7 Jan 2025 17:25:03 +0100 Subject: [PATCH] --- tests/00_webtop_install_dependences.robot | 21 +++++++++++++++++++ .../00_configure-module.robot | 8 +++++++ tests/api.resource | 14 +++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/00_webtop_install_dependences.robot create mode 100644 tests/10_webtop_actions/00_configure-module.robot create mode 100644 tests/api.resource diff --git a/tests/00_webtop_install_dependences.robot b/tests/00_webtop_install_dependences.robot new file mode 100644 index 0000000..d46b676 --- /dev/null +++ b/tests/00_webtop_install_dependences.robot @@ -0,0 +1,21 @@ +*** Settings *** +Library SSHLibrary +Resource ./api.resource + +*** Test Cases *** +Setup internal user provider + ${response} = Run task cluster/add-internal-provider {"image":"openldap","node":1} + Set Global Variable ${openldap_module_id} ${response['module_id']} + Set Global Variable ${users_domain} domain.ns8.local + Run task module/${openldap_module_id}/configure-module {"domain":"${users_domain}","admuser":"admin","admpass":"Nethesis,1234","provision":"new-domain"} + +Check if mail is installed correctly + ${output} ${rc} = Execute Command add-module mail + ... return_rc=True + Should Be Equal As Integers ${rc} 0 + &{output} = Evaluate ${output} + Set Global Variable ${mail_module_id} ${output.module_id} + Set Global Variable ${mail_domain} ns8.local + Set Global Variable ${mail_hostname} mail.ns8.local + Run task module/${mail_module_id}/configure-module {"hostname":"${mail_hostname}","user_domain":"${users_domain}","mail_domain":"${mail_domain}"} + ... decode_json=False rc_expected=0 diff --git a/tests/10_webtop_actions/00_configure-module.robot b/tests/10_webtop_actions/00_configure-module.robot new file mode 100644 index 0000000..7e84bd6 --- /dev/null +++ b/tests/10_webtop_actions/00_configure-module.robot @@ -0,0 +1,8 @@ +*** Settings *** +Library SSHLibrary +Resource ../api.resource + +*** Test Cases *** +Check if WevTop can be configured correctly + Run task module/${module_id}/configure-module {hostname:"${hostname}",user_domain:"${user_domain}",mail_domain:"${mail_domain}"} + ... decode_json=False rc_expected=0 diff --git a/tests/api.resource b/tests/api.resource new file mode 100644 index 0000000..575bc94 --- /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}