Skip to content

Commit

Permalink
Add tests suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Amygos committed Dec 14, 2023
1 parent a9d213f commit 32c95f6
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 25 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/test-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test module

on:
workflow_dispatch:
inputs:
debug_shell:
description: "Debug shell"
required: true
type: boolean
workflow_run:
workflows: ["Publish images"]
types: [completed]

jobs:
module:
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == '' }}
uses: NethServer/ns8-github-actions/.github/workflows/module-info.yml@main
run_tests:
needs: module
uses: NethServer/ns8-github-actions/.github/workflows/test-on-digitalocean-infra.yml@main
with:
args: "ghcr.io/${{needs.module.outputs.owner}}/${{needs.module.outputs.name}}:${{needs.module.outputs.tag}}"
repo_ref: ${{needs.module.outputs.sha}}
debug_shell: ${{ github.event.inputs.debug_shell == 'true' || false }}
secrets:
do_token: ${{ secrets.do_token }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/tests/outputs
21 changes: 21 additions & 0 deletions tests/00_nethvoice_install_dependencies.robot
Original file line number Diff line number Diff line change
@@ -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 nethvoice-proxy is installed correctly
Run task cluster/alter-repository {"name": "default", "status": true, "testing": true}
... rc_expected=0
${output} ${rc} = Execute Command add-module nethvoice-proxy
... return_rc=True
Should Be Equal As Integers ${rc} 0
&{output} = Evaluate ${output}
Set Global Variable ${proxy_module_id} ${output.module_id}
Run task cluster/alter-repository {"name": "default", "status": true, "testing": true}
... rc_expected=0
10 changes: 10 additions & 0 deletions tests/01_nethvoice_add-module.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*** Settings ***
Library SSHLibrary

*** Test Cases ***
Check if nethvoice is installed correctly
${output} ${rc} = Execute Command add-module ${IMAGE_URL} 1
... return_rc=True
Should Be Equal As Integers ${rc} 0
&{output} = Evaluate ${output}
Set Global Variable ${module_id} ${output.module_id}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*** Settings ***
Library SSHLibrary
Resource ../api.resource

*** Test Cases ***
Input can't be empty
${response} = Run task module/${module_id}/configure-module
... {} rc_expected=10 decode_json=False
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*** Settings ***
Library SSHLibrary
Resource ../api.resource

*** Test Cases ***
Input can't be empty
${response} = Run task module/${module_id}/set-nethvoice-admin-password
... {} rc_expected=10 decode_json=False
21 changes: 21 additions & 0 deletions tests/10_nethvoice_actions/10_configure_integrations.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*** Settings ***
Library SSHLibrary
Resource ../api.resource

*** Test Cases ***
Check if nethvoice can be configured correctly
${response} = Run task module/${module_id}/configure-module
... {"nethvoice_host": "voice.ns8.local", "nethcti_ui_host": "cti.ns8.local", "user_domain": "${users_domain}", "reports_international_prefix": "+39", "lets_encrypt": false}
... decode_json=False

Check if nethvoice is configured as expected
${response} = Run task module/${module_id}/get-configuration {}
Should Be Equal As Strings ${response['nethvoice_host']} voice.ns8.local
Should Be Equal As Strings ${response['nethcti_ui_host']} cti.ns8.local
Should Be Equal As Strings ${response['user_domain']} ${users_domain}
Should Be Equal As Strings ${response['reports_international_prefix']} +39
Should Be Equal As Strings ${response['lets_encrypt']} False

Check if the password can be changed
${response} = Run task module/${module_id}/set-nethvoice-admin-password
... {"nethvoice_admin_password": "Nethesis,1234"}
17 changes: 17 additions & 0 deletions tests/99_nethvoice_remove-modules.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*** Settings ***
Library SSHLibrary
Resource ./api.resource

*** Test Cases ***
Check if nethvoice-proxy is removed correctly
${rc} = Execute Command remove-module --no-preserve ${proxy_module_id}
... return_rc=True return_stdout=False
Should Be Equal As Integers ${rc} 0

Check if nethvoice 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

Remove internal domain
Run task cluster/remove-internal-domain {"domain":"${users_domain}"}
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}
25 changes: 0 additions & 25 deletions tests/nethvoice.robot

This file was deleted.

0 comments on commit 32c95f6

Please sign in to comment.