You are here

public function AcquiaSearchTest::testCreateDerivedKey in Acquia Connector 8

Check createDerivedKey.

File

acquia_search/tests/src/Unit/AcquiaSearchTest.php, line 81

Class

AcquiaSearchTest
Isolated tests for Acquia Search.

Namespace

Drupal\Tests\acquia_search\Unit

Code

public function testCreateDerivedKey() {

  // Mimic the hashing code in the API function.
  $derivation_string = $this->id . 'solr' . $this->salt;

  // str_pad extends the string with the same string in this case
  // until it has filled 80 chars.
  $derived_key = hash_hmac('sha1', str_pad($derivation_string, 80, $derivation_string), $this->key);

  // $this->derivedKey is generated from the API function.
  // @see setUp()
  $this
    ->assertEquals($derived_key, $this->derivedKey);
}