Skip to content

Commit

Permalink
[BE]Update APIs related with BAM to use context instead DataRepresent…
Browse files Browse the repository at this point in the history
…ers (centreon#8107)

* feat(base): add AnnotationRegistry::registerLoader to register the annotations in entities
* feat(base): add interface for serializer contexts
* feat(base): extend Webservice abstract class and separate duplicated code in trait related with dependencies
* feat(base): extend pagination service to work with context files
* feat(base): add Serializer groups to entities related with BAM and make their setters and getters to accept null values
* feat(api): update NagiosServer entity and repository to provide list of entities by IDs
* feat(api): use context for AclGroup webservice
* feat(api): use context for Image webservice
* fix(base): add docblock
* feat(api): use context in COntactGroup webservice
* feat(api): use context in Command webservice
* feat(api): use context in Escalation webservice
* feat(api): use context in Timeperiod webservice
* fix(test): improve phpunit tests
* fix(test): reduce the amount of exceptions in codestyle
* chore(dependencies): update composer dependencies
* feat(test): cover APIs with acceptance tests
* feat(test): add context information when CentreonPaginationServiceMock prepare response
* fix(test): upgrade unit tests to use WebServiceExecuteTestTrait and Interfaces for authentication
* fix(test): adjust unit texts fixtures
* fix(test): codestyle
* feat(test): extend test bootstrap to provide Serializer service from DI
* feat(base): extend Serializer service with ArrayDenormalizer
* feat(test): extend WebServiceExecuteTestTrait to mock the repositories for paginations
* feat(test): use mock of CentreonDbManager service from DI
* feat(di): separate the serialize service and object normalizer service
* fix(api): change return type of id getter of entities to be integer
* fix(test): add getters getId
* fix(test): wrong namespaces
* fix(test): improve test bootstrap to work with phing
* fix(test): adjust acceptance tests related with APIv1
* chore(dependency): update composer lock
* fix(test): remove old API tests
* chore(dependency): update composer lock
* feat(api): add alias with GET method to object centreon_configuration_remote with action list to postGetRemotesList
* chore(api): improve docblocks
* chore(api): change return type of ContactGroup::getCgActivate
* chore(style): review feedback
* chore(style): make the code to be compatible with PSR-12 too
* fix(test): reduce warnings
* chore(style): improve docblocks and codestyle
* fix(test): bot feedback

Resolve BAM-808
  • Loading branch information
vhr authored Dec 12, 2019
1 parent 58c9679 commit 918e072
Show file tree
Hide file tree
Showing 135 changed files with 3,452 additions and 3,338 deletions.
21 changes: 10 additions & 11 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,16 @@ default:
paths: [ "%paths.base%/features/CentreonModuleAPI.feature" ]
contexts: [ CentreonModuleAPIContext ]

contact_groups_api:
paths: [ "%paths.base%/features/ContactGroupsApi.feature" ]
contexts: [ ContactGroupsApiContext ]

timeperiods_api:
paths: [ "%paths.base%/features/TimeperiodsApi.feature" ]
contexts: [ TimeperiodsApiContext ]

images_api:
paths: [ "%paths.base%/features/ImagesApi.feature" ]
contexts: [ ImagesApiContext ]
api_v1:
paths:
- "%paths.base%/features/APIv1/AclGroupsApi.feature"
- "%paths.base%/features/APIv1/CommandsApi.feature"
- "%paths.base%/features/APIv1/ContactGroupsApi.feature"
- "%paths.base%/features/APIv1/EscalationsApi.feature"
- "%paths.base%/features/APIv1/ImagesApi.feature"
- "%paths.base%/features/APIv1/TimeperiodsApi.feature"
contexts:
- \Centreon\Test\Behat\CentreonAPIContext

api_v2_monitoring:
paths:
Expand Down
4 changes: 3 additions & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function loadDependencyInjector()
}

// require composer file
require __DIR__ . '/vendor/autoload.php';
$loader = require __DIR__ . '/vendor/autoload.php';

Doctrine\Common\Annotations\AnnotationRegistry::registerLoader([$loader, 'loadClass']);

require_once __DIR__ . "/container.php";
72 changes: 35 additions & 37 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions features/APIv1/AclGroupsApi.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#features/AclGroupsApi.feature
@api
Feature: Check health of the AclGroup APIs
As an authorized user via the token
I need to ensure my API handles proper actions and returns proper results

Background:
Given a Centreon server
And I have a running instance of Centreon API

@aclGroup
Scenario: Healthcheck of AclGroup APIs
# List
When I make a GET request to "/api/index.php?object=centreon_acl_group&action=list"
Then the response code should be 200
And the response has a "result" property
And the response has a "status" property
And the property "result" has value
"""
{
"pagination":{
"total":1,
"offset":0,
"limit":1
},
"entities":[
{"id":1,"name":"ALL","alias":"ALL","changed":false,"activate":true}
]
}
"""
81 changes: 81 additions & 0 deletions features/APIv1/CommandsApi.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#features/CommandsApi.feature
@api
Feature: Check health of the Command APIs
As an authorized user via the token
I need to ensure my API handles proper actions and returns proper results

Background:
Given a Centreon server
And I have a running instance of Centreon API

@command
Scenario: Healthcheck of Command APIs
# List
When I make a GET request to "/api/index.php?object=centreon_command&action=list"
Then the response code should be 200
And the response has a "result" property
And the response has a "status" property
And the property "result" has value
"""
{
"pagination":{
"total":52,
"offset":0,
"limit":52
},
"entities":[
{"id":96,"name":"check_centreon_cpu"},
{"id":4,"name":"check_centreon_dummy"},
{"id":5,"name":"check_centreon_load_average"},
{"id":97,"name":"check_centreon_memory"},
{"id":59,"name":"check_centreon_nb_connections"},
{"id":34,"name":"check_centreon_nt"},
{"id":6,"name":"check_centreon_ping"},
{"id":7,"name":"check_centreon_process"},
{"id":8,"name":"check_centreon_remote_storage"},
{"id":95,"name":"check_centreon_snmp_proc_detailed"},
{"id":94,"name":"check_centreon_snmp_value"},
{"id":62,"name":"check_centreon_traffic"},
{"id":10,"name":"check_centreon_traffic_limited"},
{"id":44,"name":"check_centreon_uptime"},
{"id":29,"name":"check_dhcp"},
{"id":30,"name":"check_dig"},
{"id":2,"name":"check_disk_smb"},
{"id":3,"name":"check_distant_disk_space"},
{"id":27,"name":"check_dns"},
{"id":28,"name":"check_ftp"},
{"id":1,"name":"check_host_alive"},
{"id":11,"name":"check_hpjd"},
{"id":12,"name":"check_http"},
{"id":13,"name":"check_https"},
{"id":76,"name":"check_load_average"},
{"id":77,"name":"check_local_cpu_load"},
{"id":15,"name":"check_local_disk"},
{"id":78,"name":"check_local_disk_space"},
{"id":16,"name":"check_local_load"},
{"id":17,"name":"check_local_procs"},
{"id":14,"name":"check_local_swap"},
{"id":18,"name":"check_local_users"},
{"id":79,"name":"check_maxq"},
{"id":24,"name":"check_nntp"},
{"id":20,"name":"check_nt_cpu"},
{"id":21,"name":"check_nt_disk"},
{"id":19,"name":"check_nt_memuse"},
{"id":25,"name":"check_pop"},
{"id":26,"name":"check_smtp"},
{"id":31,"name":"check_snmp"},
{"id":23,"name":"check_tcp"},
{"id":32,"name":"check_telnet"},
{"id":33,"name":"check_udp"},
{"id":35,"name":"host-notify-by-email"},
{"id":37,"name":"host-notify-by-epager"},
{"id":89,"name":"host-notify-by-jabber"},
{"id":41,"name":"process-service-perfdata"},
{"id":36,"name":"service-notify-by-email"},
{"id":38,"name":"service-notify-by-epager"},
{"id":90,"name":"service-notify-by-jabber"},
{"id":39,"name":"submit-host-check-result"},
{"id":40,"name":"submit-service-check-result"}
]
}
"""
31 changes: 31 additions & 0 deletions features/APIv1/ContactGroupsApi.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#features/ContactGroupsApi.feature
@api
Feature: Check health of the ContactGroup APIs
As an authorized user via the token
I need to ensure my API handles proper actions and returns proper results

Background:
Given a Centreon server
And I have a running instance of Centreon API

@contactGroup
Scenario: Healthcheck of ContactGroups APIs
# List
When I make a GET request to "/api/index.php?object=centreon_contact_groups&action=list"
Then the response code should be 200
And the response has a "result" property
And the response has a "status" property
And the property "result" has value
"""
{
"pagination":{
"total":2,
"offset":0,
"limit":2
},
"entities":[
{"id":3,"name":"Guest","activate":1},
{"id":5,"name":"Supervisors","activate":1}
]
}
"""
Loading

0 comments on commit 918e072

Please sign in to comment.