You are here

public function AquiaAgentUnitTestCase::testAuthenticators in Acquia Connector 7.2

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

File

acquia_agent/tests/acquia_agent.test, line 402

Class

AquiaAgentUnitTestCase

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');
  }
}