Ejemplo n.º 1
0
 protected function validSSO()
 {
     $config = new SSO\Configuration($this->defaultConfig);
     $config->setCachePool(new Stash\Pool(new Stash\Driver\Ephemeral()));
     return new SSO($config);
 }
Ejemplo n.º 2
0
<?php

use Firebase\JWT\JWT;
use P7\SSO\Authorization;
use P7\SSO\Configuration;
require __DIR__ . '/../vendor/autoload.php';
$config = \VCR\VCR::configure();
$config->setMode('none');
$config->enableRequestMatchers(array('method', 'url', 'host', 'query_string', 'body', 'post_fields'));
//use memory cache driver for all tests
\P7\SSO\Configuration::setDefaultCacheDriver(new Stash\Driver\Ephemeral());
class SdkTestCase extends PHPUnit_Framework_TestCase
{
    protected $configDefault = ['environment' => 'test', 'client_id' => '560aadbdccaaf7198d000043', 'client_secret' => '9c477e0807a3d754ae14fd8276eb11541b9dbbcac98c5e6c7342ac144325ebb8', 'redirect_uri' => 'http://php_sdk.dev/callback'];
    protected function generateJwt($data = [], $options = [])
    {
        $options = array_merge(['alg' => 'RS256', 'key' => '4cee9dc4d2aaf2eb997113d6b76dc6fe'], $options);
        $now = time();
        $data = array_merge(['iss' => 'http://sso.7pass.dev', 'aud' => ['543d077b656332528d000000', $this->configDefault['client_id'], '564f035a0640fd25df00000c', '565454f10640fd1cb500043a', '56b4824f0640fd4d460000b2'], 'exp' => $now + 10, 'iat' => $now, 'auth_time' => $now, 'nonce' => 'z8jw9aVPJ9vmz01d', 'azp' => $this->configDefault['client_id'], 'sub' => '56d6c9a07eddd9781d507ea5', 'gender' => 'male', 'birthdate' => '1964-07-03', 'first_name' => 'Test', 'last_name' => 'User', 'birthdate_verified' => false, 'email' => '*****@*****.**', 'email_verified' => false, 'at_hash' => 'k4taUhrRarXC78p5qFyUfg'], $data);
        return JWT::encode($data, file_get_contents(__DIR__ . '/fixtures/certs/jwk.pem'), $options['alg'], $options['key']);
    }
    protected function getValidAuthorization($configuration = null)
    {
        if ($configuration === null) {
            $configuration = $this->getConfiguration();
        }
        return new Authorization($configuration);
    }
    protected function getConfiguration()
    {
        return new Configuration($this->configDefault);