Наследование: extends OTP, implements otphp\HOTPInterface
 /**
  * @dataProvider testProvisioningURIData
  */
 public function testProvisioningURI($secret, $label, $counter, $issuer, $expectedResult, $exception = null, $message = null)
 {
     $hotp = new HOTP($secret);
     try {
         $hotp->setLabel($label);
         $hotp->setIssuer($issuer);
         $hotp->setInitialCount($counter);
         $this->assertEquals($expectedResult, $hotp->getProvisioningUri());
         if ($exception !== null) {
             $this->fail("The expected exception '{$exception}' was not thrown");
         }
     } catch (\Exception $e) {
         if (!$exception || !$e instanceof $exception) {
             throw $e;
         }
         $this->assertEquals($message, $e->getMessage());
     }
 }
Пример #2
0
 /**
  * @param string $lable
  * @param int $digits
  * @param string $digets
  * @param int $counter
  * @return HOTP
  */
 public static function getHotp($lable = '', $digits = 6, $digets = 'sha1', $counter = 0)
 {
     $totp = new HOTP();
     $totp->setLabel($lable)->setDigits($digits)->setDigest($digets)->setCounter($counter);
     return $totp;
 }
Пример #3
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage 'foo' digest is not supported.
  */
 public function testDigestIsNotSupported()
 {
     $otp = new HOTP();
     $otp->setDigest('foo');
 }
Пример #4
0
 private function createHOTP($digits, $digest, $counter, $secret = 'JDDK4U6G3BJLEZ7Y', $label = '*****@*****.**', $issuer = 'My Project')
 {
     $otp = new \OTPHP\HOTP();
     $otp->setLabel($label)->setDigest($digest)->setDigits($digits)->setSecret($secret)->setIssuer($issuer)->setCounter($counter);
     return $otp;
 }