You are here

public function AquiaAgentUnitTestCase::testAuthenticators in Acquia Connector 7.3

Same name and namespace in other branches
  1. 7.2 acquia_agent/tests/acquia_agent.test \AquiaAgentUnitTestCase::testAuthenticators()

Test authenticators.

File

acquia_agent/tests/acquia_agent.test, line 452
Tests the functionality of the Acquia Agent module.

Class

AquiaAgentUnitTestCase
Unit tests.

Code

public function testAuthenticators() {
  $identifier = $this
    ->randomName();
  $key = $this
    ->randomName();
  $required_keys = array(
    'time',
    'nonce',
    'hash',
  );

  // Test _acquia_agent_authenticator().
  $result = _acquia_agent_authenticator(array(), $identifier, $key);
  $valid = is_array($result);
  $this
    ->assertTrue($valid, '_acquia_agent_authenticator returns an array');
  if ($valid) {
    foreach ($required_keys as $key) {
      if (!array_key_exists($key, $result)) {
        $valid = FALSE;
        break;
      }
    }
    $this
      ->assertTrue($valid, 'Array has expected keys');
  }

  // Test _acquia_agent_create_authenticator().
  $result = _acquia_agent_create_authenticator(array(), $identifier);
  $valid = is_array($result);
  $this
    ->assertTrue($valid, '_acquia_agent_create_authenticator returns an array');
  if ($valid) {
    foreach ($required_keys as $key) {
      if (!array_key_exists($key, $result)) {
        $valid = FALSE;
        break;
      }
    }
    $this
      ->assertTrue($valid, 'Array has expected keys');
  }
}