Skip to content

Commit

Permalink
adding spomky
Browse files Browse the repository at this point in the history
  • Loading branch information
tymondesigns committed Aug 15, 2016
1 parent 52ac176 commit c1150a7
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 8 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"october/rain": "dev-develop",
"phpunit/phpunit": "^4.0 || ^5.0"
},
"suggest": {
"spomky-labs/jose": "Alternative for namshi/jose - Allows the use of JSON Web Encryption"
},
"autoload": {
"psr-4": {
"Tymon\\JWTAuth\\": "src/"
Expand Down
62 changes: 62 additions & 0 deletions src/Providers/JWT/Spomky.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Tymon\JWTAuth\Providers\JWT;

use Exception;
use Tymon\JWTAuth\Contracts\Providers\JWT;
use Tymon\JWTAuth\Exceptions\JWTException;
use Tymon\JWTAuth\Exceptions\TokenInvalidException;

class Spomky extends Provider implements JWT
{
/**
* @param string $secret
* @param string $algo
* @param array $keys
* @param string|null $driver
*
* @return void
*/
public function __construct($secret, $algo, array $keys = [], $driver = null)
{
parent::__construct($secret, $keys, $algo);
}

/**
* Create a JSON Web Token.
*
* @param array $payload
*
* @throws \Tymon\JWTAuth\Exceptions\JWTException
*
* @return string
*/
public function encode(array $payload)
{
//
}

/**
* Decode a JSON Web Token.
*
* @param string $token
*
* @throws \Tymon\JWTAuth\Exceptions\JWTException
*
* @return array
*/
public function decode($token)
{
//
}

}
21 changes: 13 additions & 8 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,19 @@ public function it_should_return_a_payload_when_passing_an_array_of_claims_to_ma

$expTime = $this->testNowTimestamp + 3600;

$this->claimFactory->shouldReceive('make')->once()->with('sub')->andReturn(new Subject(1));
$this->claimFactory->shouldReceive('make')->once()->with('iss')->andReturn(new Issuer('/foo'));
$this->claimFactory->shouldReceive('make')->once()->with('iat')->andReturn(new IssuedAt(123));
$this->claimFactory->shouldReceive('make')->once()->with('jti')->andReturn(new JwtId('foo'));
$this->claimFactory->shouldReceive('make')->once()->with('nbf')->andReturn(new NotBefore(123));
$this->claimFactory->shouldReceive('make')->once()->with('exp')->andReturn(new Expiration($expTime));

// $this->claimFactory->shouldReceive('get')->once()->with(Mockery::any())->andReturn(Mockery::any());
$this->claimFactory->shouldReceive('make')->once()->with('sub');
$this->claimFactory->shouldReceive('make')->once()->with('iss');
$this->claimFactory->shouldReceive('make')->once()->with('iat');
$this->claimFactory->shouldReceive('make')->once()->with('jti');
$this->claimFactory->shouldReceive('make')->once()->with('nbf');
$this->claimFactory->shouldReceive('make')->once()->with('exp');

$this->claimFactory->shouldReceive('get')->once()->with('sub', 1)->andReturn(new Subject(1));
$this->claimFactory->shouldReceive('get')->once()->with('iss', '/foo')->andReturn(new Issuer('/foo'));
$this->claimFactory->shouldReceive('get')->once()->with('iat', 123)->andReturn(new IssuedAt(123));
$this->claimFactory->shouldReceive('get')->once()->with('jti', 'foo')->andReturn(new JwtId('foo'));
$this->claimFactory->shouldReceive('get')->once()->with('nbf', 123)->andReturn(new NotBefore(123));
$this->claimFactory->shouldReceive('get')->once()->with('exp', $expTime)->andReturn(new Expiration($expTime));

$payload = $this->factory->customClaims(['sub' => 1, 'jti' => 'foo', 'iat' => 123, 'nbf' => 123])->make();

Expand Down

0 comments on commit c1150a7

Please sign in to comment.