You are here

public function AcquiaCryptConnectorTest::testAcquiaCryptConnector in Acquia Search 3.x

Test AcquiaCryptConnector::createDerivedKey().

File

tests/src/Unit/AcquiaCryptConnectorTest.php, line 17

Class

AcquiaCryptConnectorTest
@coversDefaultClass \Drupal\acquia_search\AcquiaCryptConnector @group Acquia Search Solr

Namespace

Drupal\Tests\acquia_search\Unit

Code

public function testAcquiaCryptConnector() {
  $salt = $this
    ->randomMachineName(20);
  $id = 'ABC-12345.env.db';
  $key = $this
    ->randomMachineName(20);
  $derivation_string = $id . 'solr' . $salt;
  $derivedKey = hash_hmac('sha1', str_pad($derivation_string, 80, $derivation_string), $key);
  $this
    ->assertEquals($derivedKey, AcquiaCryptConnector::createDerivedKey($salt, $id, $key));
}