You are here

public function ServicesResourceNodetests::testEndpointResourceNodeUpdatePermFail in Services 7.3

Same name and namespace in other branches
  1. 6.3 tests/functional/ServicesResourceNodeTests.test \ServicesResourceNodetests::testEndpointResourceNodeUpdatePermFail()

testing node_resource Update fail with no permissions

File

tests/functional/ServicesResourceNodeTests.test, line 409
Call the endpoint tests when no authentication is being used.

Class

ServicesResourceNodetests
Run test cases for the endpoint with no authentication turned on.

Code

public function testEndpointResourceNodeUpdatePermFail() {

  // Create and log in our privileged user.
  $this->privilegedUser = $this
    ->drupalCreateUser(array(
    'administer services',
    'create page content',
    'edit own page content',
  ));
  $this
    ->drupalLogin($this->privilegedUser);

  // Create node from user no 1.
  $node = $this
    ->drupalCreateNode(array(
    'uid' => 1,
  ));

  // Try to update this node with different user not
  // having permission to edit any story content.
  $node_update = (array) $node;
  $node_update['title'] = $this
    ->randomName();
  $node_update['body'][LANGUAGE_NONE][0]['value'] = $this
    ->randomName();
  $responseArray = $this
    ->servicesPut($this->endpoint->path . '/node/' . $node->nid, array(
    'node' => $node_update,
  ));
  $this
    ->assertTrue(strpos($responseArray['status'], 'Access denied for user'), 'Updating the node failed without needed permissions. This is good!', 'NodeResource: Update');
}