Skip to content
Snippets Groups Projects
Commit 6b7bdcdd authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2076033 by juampy: Fixed PHP warning when looking if a REST resource...

Issue #2076033 by juampy: Fixed PHP warning when looking if a REST resource defines authentication providers.
parent bc796738
No related branches found
No related tags found
No related merge requests found
......@@ -74,7 +74,7 @@ public function dynamicRoutes(RouteBuildEvent $event) {
}
// Check if there are authentication provider restrictions in the
// configuration and apply them to the route.
if (is_array($enabled_methods[$method]['supported_auth']) && !empty($enabled_methods[$method]['supported_auth'])) {
if (!empty($enabled_methods[$method]['supported_auth']) && is_array($enabled_methods[$method]['supported_auth'])) {
$route->setOption('_auth', $enabled_methods[$method]['supported_auth']);
}
// If there is no format requirement or if it matches the
......
......@@ -95,4 +95,27 @@ public function testRead() {
$this->assertResponse(404);
$this->assertNull(drupal_json_decode($response), 'No valid JSON found.');
}
/**
* Tests the resource structure.
*/
public function testResourceStructure() {
// Enable a service with a format restriction but no authentication.
$this->enableService('entity:node', 'GET', 'json');
// Create a user account that has the required permissions to read
// resources via the REST API.
$permissions = $this->entityPermissions('node', 'view');
$permissions[] = 'restful get entity:node';
$account = $this->drupalCreateUser($permissions);
$this->drupalLogin($account);
// Create an entity programmatically.
$entity = $this->entityCreate('node');
$entity->save();
// Read it over the REST API.
$response = $this->httpRequest('entity/node/' . $entity->id(), 'GET', NULL, 'application/json');
$this->assertResponse('200', 'HTTP response code is correct.');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment