Skip to content

Commit

Permalink
rename verifyHMAC to hmacValid
Browse files Browse the repository at this point in the history
  • Loading branch information
Grajo committed Jun 30, 2021
1 parent 791435d commit d25d210
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Cronofy.php
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ public function executeBatch(Batch $batch): BatchResult
return $result;
}

public function verifyHMAC($hmac_header, $body)
public function hmacValid($hmac_header, $body)
{
if ($hmac_header == null || empty($hmac_header)) {
return false;
Expand Down
12 changes: 6 additions & 6 deletions tests/CronofyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,22 +721,22 @@ public function testHmacValidation()

$body = '{"example":"well-known"}';

$actual = $cronofy->verifyHMAC("NDJlMWE1YzcxYjJjMzQzNmIxNTIzNzdhNDU4ZTMwYzQ2N2ZlZTRhMGViOWE4NmNjOWEzOTA2NDBmYjQxZGQ2NA==", $body);
$actual = $cronofy->hmacValid("NDJlMWE1YzcxYjJjMzQzNmIxNTIzNzdhNDU4ZTMwYzQ2N2ZlZTRhMGViOWE4NmNjOWEzOTA2NDBmYjQxZGQ2NA==", $body);
$this->assertTrue($actual);

$actual = $cronofy->verifyHMAC("something-else", $body);
$actual = $cronofy->hmacValid("something-else", $body);
$this->assertFalse($actual);

$actual = $cronofy->verifyHMAC("something-else,NDJlMWE1YzcxYjJjMzQzNmIxNTIzNzdhNDU4ZTMwYzQ2N2ZlZTRhMGViOWE4NmNjOWEzOTA2NDBmYjQxZGQ2NA==,something-else2", $body);
$actual = $cronofy->hmacValid("something-else,NDJlMWE1YzcxYjJjMzQzNmIxNTIzNzdhNDU4ZTMwYzQ2N2ZlZTRhMGViOWE4NmNjOWEzOTA2NDBmYjQxZGQ2NA==,something-else2", $body);
$this->assertTrue($actual);

$actual = $cronofy->verifyHMAC("something-else,something-else2", $body);
$actual = $cronofy->hmacValid("something-else,something-else2", $body);
$this->assertFalse($actual);

$actual = $cronofy->verifyHMAC(null, $body);
$actual = $cronofy->hmacValid(null, $body);
$this->assertFalse($actual);

$actual = $cronofy->verifyHMAC("", $body);
$actual = $cronofy->hmacValid("", $body);
$this->assertFalse($actual);
}
}

0 comments on commit d25d210

Please sign in to comment.