From 4e1b0721c2a9c47f2e1ba9741c445ba07ebda8c7 Mon Sep 17 00:00:00 2001 From: dmyios Date: Thu, 20 Oct 2022 13:34:12 +0200 Subject: [PATCH 1/3] added test feature for contact templates --- tests/api/behat.yml | 4 ++ .../ConfigurationContactTemplates.feature | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/api/features/ConfigurationContactTemplates.feature diff --git a/tests/api/behat.yml b/tests/api/behat.yml index 975f73d260d..4dc21518aaf 100644 --- a/tests/api/behat.yml +++ b/tests/api/behat.yml @@ -96,3 +96,7 @@ default: paths: [ "%paths.base%/features/MonitoringServerConfiguration.feature" ] contexts: - Centreon\Test\Api\Context\MonitoringServerConfigurationContext + contact_tempaltes_configuration: + paths: [ "%paths.base%/features/ConfigurationContactTemplates.feature" ] + contexts: + - Centreon\Test\Behat\Api\Context\ApiContext \ No newline at end of file diff --git a/tests/api/features/ConfigurationContactTemplates.feature b/tests/api/features/ConfigurationContactTemplates.feature new file mode 100644 index 00000000000..b95016bcd85 --- /dev/null +++ b/tests/api/features/ConfigurationContactTemplates.feature @@ -0,0 +1,43 @@ +Feature: List Contact Templates API + In order to use List Contact Templates API + As a logged user + I need to be able to list Access Groups + + Background: + Given a running instance of Centreon Web API + + Scenario: List Contact Templates as an admin user + Given I am logged in + And the endpoints are described in Centreon Web API documentation (version: 22.10) + + When I send a GET request to '/api/latest/configuration/contacts/templates' + Then the response code should be "200" + And the JSON should be equal to: + """ + { + "result": [ + { + "id": 19, + "name": "contact_template" + } + ], + "meta": { + "page": 1, + "limit": 10, + "search": {}, + "sort_by": {}, + "total": 1 + } + } + """ + + Scenario: List Contact Templates as a non-admin user without rights to Reach API + Given the following CLAPI import data: + """ + CONTACT;ADD;kev;kev;kev@localhost;Centreon@2022;0;1;en_US;local + CONTACT;setparam;kev;reach_api;0 + """ + And I am logged in with "kev"/"Centreon@2022" + + When I send a GET request to '/api/latest/configuration/contacts/templates' + Then the response code should be "403" From 2c2015031f1d249371a4b9b46c496d6f55d0af2e Mon Sep 17 00:00:00 2001 From: dmyios Date: Thu, 20 Oct 2022 13:39:17 +0200 Subject: [PATCH 2/3] fix --- tests/api/behat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/api/behat.yml b/tests/api/behat.yml index 4dc21518aaf..0544e59c9d1 100644 --- a/tests/api/behat.yml +++ b/tests/api/behat.yml @@ -99,4 +99,4 @@ default: contact_tempaltes_configuration: paths: [ "%paths.base%/features/ConfigurationContactTemplates.feature" ] contexts: - - Centreon\Test\Behat\Api\Context\ApiContext \ No newline at end of file + - Centreon\Test\Behat\Api\Context\ApiContext From 9174c63c686e97c05cefe98353670f520deeece2 Mon Sep 17 00:00:00 2001 From: dmyios Date: Thu, 20 Oct 2022 13:57:26 +0200 Subject: [PATCH 3/3] added 3rd scenario and correction of typo --- tests/api/behat.yml | 2 +- .../ConfigurationContactTemplates.feature | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/api/behat.yml b/tests/api/behat.yml index 0544e59c9d1..16d08d0b605 100644 --- a/tests/api/behat.yml +++ b/tests/api/behat.yml @@ -96,7 +96,7 @@ default: paths: [ "%paths.base%/features/MonitoringServerConfiguration.feature" ] contexts: - Centreon\Test\Api\Context\MonitoringServerConfigurationContext - contact_tempaltes_configuration: + contact_templates_configuration: paths: [ "%paths.base%/features/ConfigurationContactTemplates.feature" ] contexts: - Centreon\Test\Behat\Api\Context\ApiContext diff --git a/tests/api/features/ConfigurationContactTemplates.feature b/tests/api/features/ConfigurationContactTemplates.feature index b95016bcd85..9667231d8dc 100644 --- a/tests/api/features/ConfigurationContactTemplates.feature +++ b/tests/api/features/ConfigurationContactTemplates.feature @@ -31,6 +31,35 @@ Feature: List Contact Templates API } """ + Scenario: List Contact Templates as a non-admin user with rights to reach API + Given the following CLAPI import data: + """ + CONTACT;ADD;kev;kev;kev@localhost;Centreon@2022;0;1;en_US;local + CONTACT;setparam;kev;reach_api;1 + """ + And I am logged in with "kev"/"Centreon@2022" + + When I send a GET request to '/api/latest/configuration/contacts/templates' + Then the response code should be "200" + And the JSON should be equal to: + """ + { + "result": [ + { + "id": 19, + "name": "contact_template" + } + ], + "meta": { + "page": 1, + "limit": 10, + "search": {}, + "sort_by": {}, + "total": 1 + } + } + """ + Scenario: List Contact Templates as a non-admin user without rights to Reach API Given the following CLAPI import data: """