From 58ee810541e7c634d45247f91bf6083582199fc2 Mon Sep 17 00:00:00 2001 From: sfarouq-ext <116093375+sfarouq-ext@users.noreply.github.com> Date: Wed, 19 Mar 2025 19:46:02 +0100 Subject: [PATCH] Wip --- src/apps/exense/step/restapi/custom/api.pm | 3 +- .../exense/step/restapi/mode/listplans.pm | 3 +- src/apps/exense/step/restapi/mode/plans.pm | 9 +- tests/apps/exense/step/restapi/list-plan.json | 1 + .../apps/exense/step/restapi/list-plans.json | 163 ++++++++++++++++++ .../apps/exense/step/restapi/list-plans.robot | 36 ++++ .../exense/step/restapi/list-tenants.json | 1 + .../exense/step/restapi/list-tenants.robot | 35 ++++ tests/apps/exense/step/restapi/plans.json | 1 + tests/apps/exense/step/restapi/plans.robot | 43 +++++ 10 files changed, 288 insertions(+), 7 deletions(-) create mode 100644 tests/apps/exense/step/restapi/list-plan.json create mode 100644 tests/apps/exense/step/restapi/list-plans.json create mode 100644 tests/apps/exense/step/restapi/list-plans.robot create mode 100644 tests/apps/exense/step/restapi/list-tenants.json create mode 100644 tests/apps/exense/step/restapi/list-tenants.robot create mode 100644 tests/apps/exense/step/restapi/plans.json create mode 100644 tests/apps/exense/step/restapi/plans.robot diff --git a/src/apps/exense/step/restapi/custom/api.pm b/src/apps/exense/step/restapi/custom/api.pm index 7db85b95f..c9483477d 100644 --- a/src/apps/exense/step/restapi/custom/api.pm +++ b/src/apps/exense/step/restapi/custom/api.pm @@ -160,7 +160,8 @@ sub get_session_id { (defined($md5_secret_cache) && $md5_secret_cache ne $md5_secret) ) { my $json_request = { username => $self->{api_username}, password => $self->{api_password} }; - my $encoded = centreon::plugins::misc::json_encode($json_request) or { + my $encoded = centreon::plugins::misc::json_encode($json_request); + unless($encoded) { $self->{output}->add_option_msg(short_msg => 'cannot encode json request'); $self->{output}->option_exit(); } diff --git a/src/apps/exense/step/restapi/mode/listplans.pm b/src/apps/exense/step/restapi/mode/listplans.pm index 872cf8ec4..e042c996a 100644 --- a/src/apps/exense/step/restapi/mode/listplans.pm +++ b/src/apps/exense/step/restapi/mode/listplans.pm @@ -66,7 +66,8 @@ sub manage_selection { 'direction' => 'ASCENDING' } }; - $payload = centreon::plugins::misc::json_encode($payload) or { + $payload = centreon::plugins::misc::json_encode($payload); + unless($payload) { $self->{output}->add_option_msg(short_msg => 'cannot encode json request'); $self->{output}->option_exit(); } diff --git a/src/apps/exense/step/restapi/mode/plans.pm b/src/apps/exense/step/restapi/mode/plans.pm index e1474d04d..f385d1a7e 100644 --- a/src/apps/exense/step/restapi/mode/plans.pm +++ b/src/apps/exense/step/restapi/mode/plans.pm @@ -109,10 +109,9 @@ sub plan_long_output { sub prefix_plan_output { my ($self, %options) = @_; - return sprintf( - "plan '%s' ", - $options{instance_value}->{name} - ); + my $plan_name = defined $options{instance_value}->{name} ? $options{instance_value}->{name} : 'unknown'; + + return sprintf("plan '%s' ", $plan_name); } sub prefix_global_output { @@ -331,7 +330,7 @@ sub manage_selection { $self->{plans} = {}; foreach my $plan (@{$plans->{data}}) { # skip plans created by keyword single execution - next if ($plan->{visible} =~ /false|0/); + next if (defined $plan->{visible} && $plan->{visible} =~ /false|0/); next if (defined($self->{option_results}->{filter_plan_id}) && $self->{option_results}->{filter_plan_id} ne '' && $plan->{id} !~ /$self->{option_results}->{filter_plan_id}/); next if (defined($self->{option_results}->{filter_plan_name}) && $self->{option_results}->{filter_plan_name} ne '' && diff --git a/tests/apps/exense/step/restapi/list-plan.json b/tests/apps/exense/step/restapi/list-plan.json new file mode 100644 index 000000000..56c6976d2 --- /dev/null +++ b/tests/apps/exense/step/restapi/list-plan.json @@ -0,0 +1 @@ +{"openapi":"3.0.0","info":{"title":"List plans","version":"1.0.0"},"servers":[{"url":"http://localhost:3001/"}],"paths":{"/rest/access/login":{"post":{"description":"","responses":{"200":{"description":"","content":{"application/json":{"example":{}}},"headers":{"Access-Control-Allow-Origin":{"schema":{"type":"string"},"example":"*"},"Access-Control-Allow-Methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"Access-Control-Allow-Headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"},"Set-Cookie":{"schema":{"type":"string"},"example":"sessionid=azertyuiop"}}}}}},"/rest/tenants/current":{"post":{"description":"","responses":{"204":{"description":"","content":{"application/json":{"example":"{}"}},"headers":{"Access-Control-Allow-Origin":{"schema":{"type":"string"},"example":"*"},"Access-Control-Allow-Methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"Access-Control-Allow-Headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"}}}}}},"/rest/table/plans":{"post":{"description":"","responses":{"200":{"description":"","content":{"application/json":{"example":"{\r\n \"recordsTotal\": 11,\r\n \"recordsFiltered\": 3,\r\n \"data\": [\r\n {\r\n \"customFields\": {\r\n \"versionId\": \"66d1904664e24c6ef10f74d8\"\r\n },\r\n \"attributes\": {\r\n \"name\": \"plop2-test\",\r\n \"project\": \"66d18fc464e24c6ef10f6f02\"\r\n },\r\n \"root\": {\r\n \"_class\": \"TestCase\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"plop2-test\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d1904664e24c6ef10f74d1\"\r\n },\r\n \"functions\": null,\r\n \"subPlans\": null,\r\n \"visible\": true,\r\n \"id\": \"66d1904664e24c6ef10f74d2\"\r\n },\r\n {\r\n \"customFields\": {\r\n \"versionId\": \"669fc885498c2a0322a6aa13\"\r\n },\r\n \"attributes\": {\r\n \"name\": \"test-plan\",\r\n \"project\": \"669fc509498c2a0322a6a5ad\"\r\n },\r\n \"root\": {\r\n \"_class\": \"TestCase\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"test-plan\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"669fc899498c2a0322a6aa27\"\r\n },\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"669fc89f498c2a0322a6aa42\"\r\n }\r\n ],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"669fc855498c2a0322a6a9c4\"\r\n },\r\n \"functions\": null,\r\n \"subPlans\": null,\r\n \"visible\": true,\r\n \"id\": \"669fc855498c2a0322a6a9c5\"\r\n },\r\n {\r\n \"customFields\": {\r\n \"versionId\": \"66d180a764e24c6ef10e0159\"\r\n },\r\n \"attributes\": {\r\n \"name\": \"test-plan_Copy\",\r\n \"project\": \"669fc509498c2a0322a6a5ad\"\r\n },\r\n \"root\": {\r\n \"_class\": \"TestCase\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"test-plan\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d180a764e24c6ef10e0157\"\r\n },\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d180a764e24c6ef10e0158\"\r\n }\r\n ],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d180a764e24c6ef10e0156\"\r\n },\r\n \"functions\": null,\r\n \"subPlans\": null,\r\n \"visible\": true,\r\n \"id\": \"66d180a764e24c6ef10e0155\"\r\n }\r\n ]\r\n}\r\n"}},"headers":{"Access-Control-Allow-Origin":{"schema":{"type":"string"},"example":"*"},"Access-Control-Allow-Methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"Access-Control-Allow-Headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"}}}}}}}} \ No newline at end of file diff --git a/tests/apps/exense/step/restapi/list-plans.json b/tests/apps/exense/step/restapi/list-plans.json new file mode 100644 index 000000000..896ec9df5 --- /dev/null +++ b/tests/apps/exense/step/restapi/list-plans.json @@ -0,0 +1,163 @@ +{ + "uuid": "07dc5f45-6599-4e24-8ac5-2db84d687b64", + "lastMigration": 32, + "name": "List plans", + "endpointPrefix": "", + "latency": 0, + "port": 3001, + "hostname": "", + "folders": [], + "routes": [ + { + "uuid": "f715b4db-b117-4da5-8620-0944ab2a4bc0", + "type": "http", + "documentation": "", + "method": "post", + "endpoint": "rest/access/login", + "responses": [ + { + "uuid": "0f4b3f64-13c5-4f7d-98f1-d8f8ddce11b4", + "body": "", + "latency": 0, + "statusCode": 200, + "label": "", + "headers": [ + { + "key": "Set-Cookie", + "value": "sessionid=azertyuiop" + } + ], + "bodyType": "INLINE", + "filePath": "", + "databucketID": "", + "sendFileAsBody": false, + "rules": [], + "rulesOperator": "OR", + "disableTemplating": false, + "fallbackTo404": false, + "default": true, + "crudKey": "id", + "callbacks": [] + } + ], + "responseMode": null + }, + { + "uuid": "8fc53730-42d0-477a-b9fe-091f77a9124e", + "type": "http", + "documentation": "", + "method": "post", + "endpoint": "rest/tenants/current", + "responses": [ + { + "uuid": "cee1d9cb-26ac-45e6-8b84-fc439baa7203", + "body": "{}", + "latency": 0, + "statusCode": 204, + "label": "", + "headers": [], + "bodyType": "INLINE", + "filePath": "", + "databucketID": "", + "sendFileAsBody": false, + "rules": [], + "rulesOperator": "OR", + "disableTemplating": false, + "fallbackTo404": false, + "default": true, + "crudKey": "id", + "callbacks": [] + } + ], + "responseMode": null + }, + { + "uuid": "2b5b4cf5-edd8-4b26-a014-bb2ff19def42", + "type": "http", + "documentation": "", + "method": "post", + "endpoint": "rest/table/plans", + "responses": [ + { + "uuid": "4fb9bc48-7d2e-4559-8642-2342c7b5007f", + "body": "{\r\n \"recordsTotal\": 11,\r\n \"recordsFiltered\": 3,\r\n \"data\": [\r\n {\r\n \"customFields\": {\r\n \"versionId\": \"66d1904664e24c6ef10f74d8\"\r\n },\r\n \"attributes\": {\r\n \"name\": \"plop2-test\",\r\n \"project\": \"66d18fc464e24c6ef10f6f02\"\r\n },\r\n \"root\": {\r\n \"_class\": \"TestCase\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"plop2-test\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d1904664e24c6ef10f74d1\"\r\n },\r\n \"functions\": null,\r\n \"subPlans\": null,\r\n \"visible\": true,\r\n \"id\": \"66d1904664e24c6ef10f74d2\"\r\n },\r\n {\r\n \"customFields\": {\r\n \"versionId\": \"669fc885498c2a0322a6aa13\"\r\n },\r\n \"attributes\": {\r\n \"name\": \"test-plan\",\r\n \"project\": \"669fc509498c2a0322a6a5ad\"\r\n },\r\n \"root\": {\r\n \"_class\": \"TestCase\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"test-plan\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"669fc899498c2a0322a6aa27\"\r\n },\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"669fc89f498c2a0322a6aa42\"\r\n }\r\n ],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"669fc855498c2a0322a6a9c4\"\r\n },\r\n \"functions\": null,\r\n \"subPlans\": null,\r\n \"visible\": true,\r\n \"id\": \"669fc855498c2a0322a6a9c5\"\r\n },\r\n {\r\n \"customFields\": {\r\n \"versionId\": \"66d180a764e24c6ef10e0159\"\r\n },\r\n \"attributes\": {\r\n \"name\": \"test-plan_Copy\",\r\n \"project\": \"669fc509498c2a0322a6a5ad\"\r\n },\r\n \"root\": {\r\n \"_class\": \"TestCase\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"test-plan\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d180a764e24c6ef10e0157\"\r\n },\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d180a764e24c6ef10e0158\"\r\n }\r\n ],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d180a764e24c6ef10e0156\"\r\n },\r\n \"functions\": null,\r\n \"subPlans\": null,\r\n \"visible\": true,\r\n \"id\": \"66d180a764e24c6ef10e0155\"\r\n }\r\n ]\r\n}\r\n", + "latency": 0, + "statusCode": 200, + "label": "", + "headers": [], + "bodyType": "INLINE", + "filePath": "", + "databucketID": "", + "sendFileAsBody": false, + "rules": [], + "rulesOperator": "OR", + "disableTemplating": false, + "fallbackTo404": false, + "default": true, + "crudKey": "id", + "callbacks": [] + } + ], + "responseMode": null + } + ], + "rootChildren": [ + { + "type": "route", + "uuid": "f715b4db-b117-4da5-8620-0944ab2a4bc0" + }, + { + "type": "route", + "uuid": "8fc53730-42d0-477a-b9fe-091f77a9124e" + }, + { + "type": "route", + "uuid": "2b5b4cf5-edd8-4b26-a014-bb2ff19def42" + } + ], + "proxyMode": false, + "proxyHost": "", + "proxyRemovePrefix": false, + "tlsOptions": { + "enabled": false, + "type": "CERT", + "pfxPath": "", + "certPath": "", + "keyPath": "", + "caPath": "", + "passphrase": "" + }, + "cors": true, + "headers": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], + "proxyReqHeaders": [ + { + "key": "", + "value": "" + } + ], + "proxyResHeaders": [ + { + "key": "", + "value": "" + } + ], + "data": [], + "callbacks": [] +} \ No newline at end of file diff --git a/tests/apps/exense/step/restapi/list-plans.robot b/tests/apps/exense/step/restapi/list-plans.robot new file mode 100644 index 000000000..fe98c9888 --- /dev/null +++ b/tests/apps/exense/step/restapi/list-plans.robot @@ -0,0 +1,36 @@ +*** Settings *** + +Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource + +Suite Setup Start Mockoon ${MOCKOON_JSON} +Suite Teardown Stop Mockoon +Test Timeout 120s + + +*** Variables *** +${MOCKOON_JSON} ${CURDIR}${/}list-plans.json +${HOSTNAME} host.docker.internal +${APIPORT} 3001 + +${cmd} ${CENTREON_PLUGINS} +... --plugin=apps::exense::step::restapi::plugin +... --hostname=${HOSTNAME} +... --port=${APIPORT} +... --proto=http +... --timeout=15 +... --token=token + + +*** Test Cases *** +list-plans ${tc} + [Tags] apps + ${command} Catenate + ... ${cmd} + ... --mode=list-plans + ... ${extraoptions} + + Ctn Run Command And Check Result As Strings ${command} ${expected_result} + + Examples: tc extraoptions expected_result -- + ... 1 ${EMPTY} List plans: [id: 66d1904664e24c6ef10f74d2][name: plop2-test] [id: 669fc855498c2a0322a6a9c5][name: test-plan] [id: 66d180a764e24c6ef10e0155][name: test-plan_Copy] + ... 2 --tenant-name='[All]' List plans: [id: 66d1904664e24c6ef10f74d2][name: plop2-test] [id: 669fc855498c2a0322a6a9c5][name: test-plan] [id: 66d180a764e24c6ef10e0155][name: test-plan_Copy] \ No newline at end of file diff --git a/tests/apps/exense/step/restapi/list-tenants.json b/tests/apps/exense/step/restapi/list-tenants.json new file mode 100644 index 000000000..1fe86cadd --- /dev/null +++ b/tests/apps/exense/step/restapi/list-tenants.json @@ -0,0 +1 @@ +{"openapi":"3.0.0","info":{"title":"List tenats","version":"1.0.0"},"servers":[{"url":"http://localhost:3002/"}],"paths":{"/rest/tenants":{"get":{"description":"","responses":{"200":{"description":"","content":{"application/json":{"example":"[\r\n {\r\n \"name\": \"[All]\",\r\n \"global\": true,\r\n \"projectId\": null\r\n },\r\n {\r\n \"name\": \"Common\",\r\n \"global\": false,\r\n \"projectId\": \"669fc509498c2a0322a6a5ad\"\r\n },\r\n {\r\n \"name\": \"test-project\",\r\n \"global\": false,\r\n \"projectId\": \"66d18fc464e24c6ef10f6f02\"\r\n }\r\n]\r\n"}},"headers":{"Access-Control-Allow-Origin":{"schema":{"type":"string"},"example":"*"},"Access-Control-Allow-Methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"Access-Control-Allow-Headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"},"Authorization":{"schema":{"type":"string"},"example":""}}}}}}}} \ No newline at end of file diff --git a/tests/apps/exense/step/restapi/list-tenants.robot b/tests/apps/exense/step/restapi/list-tenants.robot new file mode 100644 index 000000000..17b39dc35 --- /dev/null +++ b/tests/apps/exense/step/restapi/list-tenants.robot @@ -0,0 +1,35 @@ +*** Settings *** + +Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource + +Suite Setup Start Mockoon ${MOCKOON_JSON} +Suite Teardown Stop Mockoon +Test Timeout 120s + + +*** Variables *** +${MOCKOON_JSON} ${CURDIR}${/}list-tenants.json +${HOSTNAME} host.docker.internal +${APIPORT} 3002 + +${cmd} ${CENTREON_PLUGINS} +... --plugin=apps::exense::step::restapi::plugin +... --hostname=${HOSTNAME} +... --port=${APIPORT} +... --proto=http +... --timeout=15 +... --token=token + + +*** Test Cases *** +list-tenants ${tc} + [Tags] apps + ${command} Catenate + ... ${cmd} + ... --mode=list-tenants + ... ${extraoptions} + + Ctn Run Command And Check Result As Strings ${command} ${expected_result} + + Examples: tc extraoptions expected_result -- + ... 1 ${EMPTY} List tenants: [name: [All]][projectId: ][global: 1] [name: Common][projectId: 669fc509498c2a0322a6a5ad][global: 0] [name: test-project][projectId: 66d18fc464e24c6ef10f6f02][global: 0] \ No newline at end of file diff --git a/tests/apps/exense/step/restapi/plans.json b/tests/apps/exense/step/restapi/plans.json new file mode 100644 index 000000000..fa0ba8807 --- /dev/null +++ b/tests/apps/exense/step/restapi/plans.json @@ -0,0 +1 @@ +{"openapi":"3.0.0","info":{"title":"Plans","version":"1.0.0"},"servers":[{"url":"http://localhost:3000/"}],"paths":{"/rest/access/login":{"post":{"description":"","responses":{"200":{"description":"","content":{"application/json":{"example":{}}},"headers":{"Access-Control-Allow-Origin":{"schema":{"type":"string"},"example":"*"},"Access-Control-Allow-Methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"Access-Control-Allow-Headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"},"Set-Cookie":{"schema":{"type":"string"},"example":"sessionid=azertyuiop"}}}}}},"/rest/tenants/current":{"post":{"description":"","responses":{"204":{"description":"","content":{"text/html; charset=utf-8":{"example":"{}"}},"headers":{"Access-Control-Allow-Origin":{"schema":{"type":"string"},"example":"*"},"Access-Control-Allow-Methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"Access-Control-Allow-Headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"},"access-control-allow-headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"},"access-control-allow-methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"access-control-allow-origin":{"schema":{"type":"string"},"example":"*"},"content-security-policy":{"schema":{"type":"string"},"example":"default-src 'none'"},"x-content-type-options":{"schema":{"type":"string"},"example":"nosniff"}}}}}},"/rest/table/plans":{"post":{"description":"","responses":{"200":{"description":"","content":{"text/html; charset=utf-8":{"example":"{\r\n \"recordsTotal\": 11,\r\n \"recordsFiltered\": 3,\r\n \"data\": [\r\n {\r\n \"customFields\": {\r\n \"versionId\": \"66d1904664e24c6ef10f74d8\"\r\n },\r\n \"attributes\": {\r\n \"name\": \"plop2-test\",\r\n \"project\": \"66d18fc464e24c6ef10f6f02\"\r\n },\r\n \"root\": {\r\n \"_class\": \"TestCase\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"plop2-test\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d1904664e24c6ef10f74d1\"\r\n },\r\n \"functions\": null,\r\n \"subPlans\": null,\r\n \"visible\": true,\r\n \"id\": \"66d1904664e24c6ef10f74d2\"\r\n },\r\n {\r\n \"customFields\": {\r\n \"versionId\": \"669fc885498c2a0322a6aa13\"\r\n },\r\n \"attributes\": {\r\n \"name\": \"test-plan\",\r\n \"project\": \"669fc509498c2a0322a6a5ad\"\r\n },\r\n \"root\": {\r\n \"_class\": \"TestCase\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"test-plan\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"669fc899498c2a0322a6aa27\"\r\n },\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"669fc89f498c2a0322a6aa42\"\r\n }\r\n ],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"669fc855498c2a0322a6a9c4\"\r\n },\r\n \"functions\": null,\r\n \"subPlans\": null,\r\n \"visible\": true,\r\n \"id\": \"669fc855498c2a0322a6a9c5\"\r\n },\r\n {\r\n \"customFields\": {\r\n \"versionId\": \"66d180a764e24c6ef10e0159\"\r\n },\r\n \"attributes\": {\r\n \"name\": \"test-plan_Copy\",\r\n \"project\": \"669fc509498c2a0322a6a5ad\"\r\n },\r\n \"root\": {\r\n \"_class\": \"TestCase\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"test-plan\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d180a764e24c6ef10e0157\"\r\n },\r\n {\r\n \"_class\": \"CallKeyword\",\r\n \"customFields\": null,\r\n \"attributes\": {\r\n \"name\": \"EBC_Put\"\r\n },\r\n \"dynamicName\": {\r\n \"dynamic\": false,\r\n \"value\": \"\",\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"useDynamicName\": false,\r\n \"description\": null,\r\n \"children\": [],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"remote\": {\r\n \"dynamic\": false,\r\n \"value\": true,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"token\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"function\": {\r\n \"dynamic\": false,\r\n \"value\": \"{\\\"name\\\":{\\\"value\\\":\\\"EBC_Put\\\",\\\"dynamic\\\":false}}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"argument\": {\r\n \"dynamic\": false,\r\n \"value\": \"{}\",\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"resultMap\": {\r\n \"dynamic\": false,\r\n \"value\": null,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d180a764e24c6ef10e0158\"\r\n }\r\n ],\r\n \"customAttributes\": null,\r\n \"attachments\": null,\r\n \"skipNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"instrumentNode\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": \"\",\r\n \"expressionType\": null\r\n },\r\n \"continueParentNodeExecutionOnError\": {\r\n \"dynamic\": false,\r\n \"value\": false,\r\n \"expression\": null,\r\n \"expressionType\": null\r\n },\r\n \"id\": \"66d180a764e24c6ef10e0156\"\r\n },\r\n \"functions\": null,\r\n \"subPlans\": null,\r\n \"visible\": true,\r\n \"id\": \"66d180a764e24c6ef10e0155\"\r\n }\r\n ]\r\n}\r\n"}},"headers":{"Access-Control-Allow-Origin":{"schema":{"type":"string"},"example":"*"},"Access-Control-Allow-Methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"Access-Control-Allow-Headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"},"access-control-allow-headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"},"access-control-allow-methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"access-control-allow-origin":{"schema":{"type":"string"},"example":"*"},"content-security-policy":{"schema":{"type":"string"},"example":"default-src 'none'"},"x-content-type-options":{"schema":{"type":"string"},"example":"nosniff"}}}}}},"/rest/table/executions":{"post":{"description":"","responses":{"200":{"description":"","content":{"text/html; charset=utf-8":{"example":"{}"}},"headers":{"Access-Control-Allow-Origin":{"schema":{"type":"string"},"example":"*"},"Access-Control-Allow-Methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"Access-Control-Allow-Headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"},"access-control-allow-headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"},"access-control-allow-methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"access-control-allow-origin":{"schema":{"type":"string"},"example":"*"},"content-security-policy":{"schema":{"type":"string"},"example":"default-src 'none'"},"x-content-type-options":{"schema":{"type":"string"},"example":"nosniff"}}}}}}}} \ No newline at end of file diff --git a/tests/apps/exense/step/restapi/plans.robot b/tests/apps/exense/step/restapi/plans.robot new file mode 100644 index 000000000..b19367e8d --- /dev/null +++ b/tests/apps/exense/step/restapi/plans.robot @@ -0,0 +1,43 @@ +*** Settings *** + +Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource + +Suite Setup Start Mockoon ${MOCKOON_JSON} +Suite Teardown Stop Mockoon +Test Timeout 120s + + +*** Variables *** +${MOCKOON_JSON} ${CURDIR}${/}plans.json +${HOSTNAME} host.docker.internal +${APIPORT} 3000 + +${cmd} ${CENTREON_PLUGINS} +... --plugin=apps::exense::step::restapi::plugin +... --hostname=${HOSTNAME} +... --port=${APIPORT} +... --proto=http +... --timeout=15 +... --token=token + + +*** Test Cases *** +plans ${tc} + [Tags] apps + ${command} Catenate + ... ${cmd} + ... --mode=plans + ... ${extraoptions} + #Log ${cmd} + Ctn Run Command And Check Result As Strings ${command} ${expected_result} + + Examples: tc extraoptions expected_result -- + ... 1 ${EMPTY} OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100 + ... 2 --tenant-name='[All]' OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100 + ... 3 --critical-plan-execution-status='\\\%{planName} eq NORUN' OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100 + ... 4 --unknown-plan-execution-status='\\\%{planName} eq plop2-test' OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100 + ... 5 --warning-plan-execution-status='\\\%{planName} eq test-plan_Copy' OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100 + ... 6 --status-failed='\\\%{result} =~ /technical_error|failed|interrupted/i' OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100 + ... 7 --only-last-execution OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100 + ... 8 --since-timeperiod OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100 + ... 9 --filter-plan-name='test-plan' OK: All plans are ok | 'plans.detected.count'=2;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 \ No newline at end of file