Move all tests to using new TestToken trait
This commit is contained in:
parent
79782caa95
commit
79f6519ce0
3 changed files with 6 additions and 74 deletions
|
@ -3,13 +3,14 @@
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
use Tests\TestToken;
|
||||||
use Lcobucci\JWT\Builder;
|
use Lcobucci\JWT\Builder;
|
||||||
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
class MicropubControllerTest extends TestCase
|
class MicropubControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions, TestToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a GET request for the micropub endpoint without a token gives a
|
* Test a GET request for the micropub endpoint without a token gives a
|
||||||
|
@ -314,42 +315,4 @@ class MicropubControllerTest extends TestCase
|
||||||
'swarm_url' => 'https://www.swarmapp.com/checkin/123'
|
'swarm_url' => 'https://www.swarmapp.com/checkin/123'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a valid token to be used in the tests.
|
|
||||||
*
|
|
||||||
* @return Lcobucci\JWT\Token\Plain $token
|
|
||||||
*/
|
|
||||||
private function getToken()
|
|
||||||
{
|
|
||||||
$signer = new Sha256();
|
|
||||||
$token = (new Builder())
|
|
||||||
->set('client_id', 'https://quill.p3k.io')
|
|
||||||
->set('me', 'https://jonnybarnes.localhost')
|
|
||||||
->set('scope', 'create update')
|
|
||||||
->set('issued_at', time())
|
|
||||||
->sign($signer, env('APP_KEY'))
|
|
||||||
->getToken();
|
|
||||||
|
|
||||||
return $token;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate an invalid token to be used in the tests.
|
|
||||||
*
|
|
||||||
* @return Lcobucci\JWT\Token\Plain $token
|
|
||||||
*/
|
|
||||||
private function getInvalidToken()
|
|
||||||
{
|
|
||||||
$signer = new Sha256();
|
|
||||||
$token = (new Builder())
|
|
||||||
->set('client_id', 'https://quill.p3k.io')
|
|
||||||
->set('me', 'https://jonnybarnes.localhost')
|
|
||||||
->set('scope', 'view') //error here
|
|
||||||
->set('issued_at', time())
|
|
||||||
->sign($signer, env('APP_KEY'))
|
|
||||||
->getToken();
|
|
||||||
|
|
||||||
return $token;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
use Tests\TestToken;
|
||||||
use Lcobucci\JWT\Builder;
|
use Lcobucci\JWT\Builder;
|
||||||
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
class OwnYourGramTest extends TestCase
|
class OwnYourGramTest extends TestCase
|
||||||
{
|
{
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions, TestToken;
|
||||||
|
|
||||||
public function test_ownyourgram_post()
|
public function test_ownyourgram_post()
|
||||||
{
|
{
|
||||||
|
@ -40,18 +41,4 @@ class OwnYourGramTest extends TestCase
|
||||||
'instagram_url' => 'https://www.instagram.com/p/BVC_nVTBFfi/'
|
'instagram_url' => 'https://www.instagram.com/p/BVC_nVTBFfi/'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getToken()
|
|
||||||
{
|
|
||||||
$signer = new Sha256();
|
|
||||||
$token = (new Builder())
|
|
||||||
->set('client_id', 'https://ownyourgram.com')
|
|
||||||
->set('me', config('app.url'))
|
|
||||||
->set('scope', 'create')
|
|
||||||
->set('issued_at', time())
|
|
||||||
->sign($signer, env('APP_KEY'))
|
|
||||||
->getToken();
|
|
||||||
|
|
||||||
return $token;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
use Tests\TestToken;
|
||||||
use Lcobucci\JWT\Builder;
|
use Lcobucci\JWT\Builder;
|
||||||
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
class SwarmTest extends TestCase
|
class SwarmTest extends TestCase
|
||||||
{
|
{
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions, TestToken;
|
||||||
|
|
||||||
public function test_faked_ownyourswarm_request()
|
public function test_faked_ownyourswarm_request()
|
||||||
{
|
{
|
||||||
|
@ -82,23 +83,4 @@ class SwarmTest extends TestCase
|
||||||
'swarm_url' => 'https://www.swarmapp.com/checkin/def'
|
'swarm_url' => 'https://www.swarmapp.com/checkin/def'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a valid token to be used in the tests.
|
|
||||||
*
|
|
||||||
* @return Lcobucci\JWT\Token\Plain $token
|
|
||||||
*/
|
|
||||||
private function getToken()
|
|
||||||
{
|
|
||||||
$signer = new Sha256();
|
|
||||||
$token = (new Builder())
|
|
||||||
->set('client_id', 'https://ownyourswarm.p3k.io')
|
|
||||||
->set('me', 'https://jonnybarnes.localhost')
|
|
||||||
->set('scope', 'create update')
|
|
||||||
->set('issued_at', time())
|
|
||||||
->sign($signer, env('APP_KEY'))
|
|
||||||
->getToken();
|
|
||||||
|
|
||||||
return $token;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue