Skip to content

Commit

Permalink
Increased coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Brecht-Precht committed Apr 15, 2016
1 parent 84fd975 commit 548c3e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
16 changes: 15 additions & 1 deletion test/Validation/YubicoOtp/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,29 @@
class ParserTest extends \PHPUnit_Framework_TestCase
{

const OTP = 'ccccccfcttfikkgitudletutjneikkrfcugnuhikdbhj';

/**
* @throws ParserException
*/
public function testParse()
public function testParseInvalid()
{
$this->setExpectedException(get_class(new ParserException()));
$parser = new Parser();
$parser->parse('');
$parser->parse('123456789');
}

/**
* @throws ParserException
*/
public function testParseValid()
{
$parser = new Parser();
$parser->parse(self::OTP);
$this->assertEquals(self::OTP, $parser->getOtpEffective());
$this->assertEmpty($parser->getPassword());
$this->assertEquals('kkgitudletutjneikkrfcugnuhikdbhj', $parser->getCiphertext());
}

}
9 changes: 6 additions & 3 deletions test/Validation/YubicoOtp/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class ValidatorTest extends \PHPUnit_Framework_TestCase
{

const PUBLIC_ID = 'ccccccfcttfik';
const PUBLIC_ID = 'ccccccfcttfi';

public function testValidateMalformed()
{
Expand All @@ -21,8 +21,11 @@ public function testValidateMalformed()
$isValid = $validator->validate('12345678', self::PUBLIC_ID);
$this->assertEquals(false, $isValid);
// Wellformed
$isValid = $validator->validate('ccccccfcttfikkgitudletutjneikkrfcugnuhikdbhj', self::PUBLIC_ID);
$this->assertEquals(false, $isValid);
$validator->validate('ccccccfcttfikkgitudletutjneikkrfcugnuhikdbhj', self::PUBLIC_ID);
$this->assertEquals(false, $validator->isValid());
// Parser
$parser = $validator->getOtpParser();
$this->assertInstanceOf('\OathServerSuite\Validation\YubicoOtp\Parser', $parser);
}

}

0 comments on commit 548c3e0

Please sign in to comment.