Skip to content

Commit

Permalink
Adds and implements QueryAuthException interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremykendall committed Sep 3, 2013
1 parent f8403e9 commit c30d1d0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/QueryAuth/Exception/QueryAuthException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
/**
* Query Auth: Signature generation and validation for REST API query authentication
*
* @copyright 2013 Jeremy Kendall
* @license https://github.com/jeremykendall/query-auth/blob/master/LICENSE MIT
* @link https://github.com/jeremykendall/query-auth
*/

namespace QueryAuth\Exception;

interface QueryAuthException {}
2 changes: 1 addition & 1 deletion src/QueryAuth/Exception/SignatureMissingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
/**
* Exception thrown when Signature is missing
*/
class SignatureMissingException extends \Exception
class SignatureMissingException extends \Exception implements QueryAuthException
{
}
2 changes: 1 addition & 1 deletion src/QueryAuth/Exception/TimeOutOfBoundsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
/**
* Thrown when request timestamp is beyond allowable clock drift
*/
class TimeOutOfBoundsException extends \OutOfBoundsException
class TimeOutOfBoundsException extends \OutOfBoundsException implements QueryAuthException
{
}
24 changes: 24 additions & 0 deletions tests/QueryAuth/Tests/Exception/QueryAuthExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace QueryAuth\Tests;

use QueryAuth\Exception\QueryAuthException;
use QueryAuth\Exception\SignatureMissingException;
use QueryAuth\Exception\TimeOutOfBoundsException;

class QueryAuthExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testSignatureMissingException()
{
$e = new SignatureMissingException();
$this->assertInstanceOf('QueryAuth\Exception\SignatureMissingException', $e);
$this->assertInstanceOf('QueryAuth\Exception\QueryAuthException', $e);
}

public function testTimeOutOfBoundsException()
{
$e = new TimeOutOfBoundsException();
$this->assertInstanceOf('QueryAuth\Exception\TimeOutOfBoundsException', $e);
$this->assertInstanceOf('QueryAuth\Exception\QueryAuthException', $e);
}
}

0 comments on commit c30d1d0

Please sign in to comment.