Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SSHLibrary to api.resource test file #12

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/api.resource
Original file line number Diff line number Diff line change
@@ -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}
23 changes: 19 additions & 4 deletions tests/wordpress.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*** Settings ***
Library SSHLibrary
Resource api.resource

*** Test Cases ***
Check if wordpress is installed correctly
Expand All @@ -10,16 +11,30 @@ Check if wordpress is installed correctly
Set Suite Variable ${module_id} ${output.module_id}

Check if wordpress 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":"wordpress.domain.org","http2https":true,"lets_encrypt":true}'
... 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 wordpress works as expected
${rc} = Execute Command curl -f http://127.0.0.1/wordpress/
... return_rc=True return_stdout=False
Should Be Equal As Integers ${rc} 0
Wait Until Keyword Succeeds 20 times 3 seconds Ping wordpress

Check if wordpress 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 wordpress
${out} ${err} ${rc} = Execute Command curl -k -f -H 'Host: wordpress.domain.org' https://127.0.0.1/wp-admin/install.php
... return_rc=True return_stdout=True return_stderr=True
Should Be Equal As Integers ${rc} 0
Should Contain ${out} <title>WordPress
Loading