Skip to content

Commit

Permalink
Fix several errors
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhemN committed Oct 20, 2015
1 parent 0c7f045 commit bb512c1
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion TOTP/TOTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function generateTOTP($stamp, $key)
*/
public function validate($key, $totp, $stamp = null)
{
return $this->validator($key, $totp, $stamp);
return $this->validator->validate($key, $totp, $stamp);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion TOTP/TOTPTimeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function setStampLength($stampLength = null)
$stampLength = self::DEFAULT_STAMP_LENGTH;
}
$stampLength = intval($stampLength);
if (empty($stampLength) or $stampLength < 0) {
if (empty($stampLength) || $stampLength < 0) {
throw new InvalidArgumentException('Stamp length must be greater than 0 and positive.');
}
$this->stampLength = $stampLength;
Expand Down
6 changes: 5 additions & 1 deletion TOTP/TOTPValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ class TOTPValidator
/**
* @var TOTPTimeManager
*/
protected $timeManager;
private $timeManager;
/**
* @var int|null
*/
private $window;

/**
* @param TOTPTimeManager|int|null $stampLength Stamp length in seconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace EXSyst\Component\Security\TOTP\Tests;
namespace EXSyst\Component\Security\Tests\TOTP;

use EXSyst\Component\Security\TOTP\TOTPKeyGenerator;

Expand All @@ -22,7 +22,7 @@ public function testKeyGeneration()
for ($i = 0; $i < 15; ++$i) {
$length = rand(8, 100);
$key = TOTPKeyGenerator::generate($length);
$this->assertRegExp(sprintf('#[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]{%d}#', $length), $key);
$this->assertRegExp(sprintf('#[%s]{%d}#', $this->characters, $length), $key);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace EXSyst\Component\Security\TOTP\Tests;
namespace EXSyst\Component\Security\Tests\TOTP;

use EXSyst\Component\Security\TOTP\TOTPTimeManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace EXSyst\Component\Security\TOTP\Tests;
namespace EXSyst\Component\Security\Tests\TOTP;

use EXSyst\Component\Security\TOTP\TOTPGenerator;
use EXSyst\Component\Security\TOTP\TOTPKeyGenerator;
Expand Down
2 changes: 0 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<testsuites>
<testsuite name="EXSyst Security Component Test Suite">
<directory>./Tests/</directory>
<directory>./TOTP/Tests/</directory>
</testsuite>
</testsuites>
<filter>
Expand All @@ -21,7 +20,6 @@
<exclude>
<directory>./vendor</directory>
<directory>./Tests/</directory>
<directory>./TOTP/Tests/</directory>
</exclude>
</whitelist>
</filter>
Expand Down

0 comments on commit bb512c1

Please sign in to comment.