mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-22 13:09:44 +05:30
Updated authserver tests
This commit is contained in:
parent
fce24aa74d
commit
fb518715ce
@ -103,10 +103,10 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($v);
|
||||
}
|
||||
|
||||
public function test_defaultScope()
|
||||
public function test_setDefaultScope()
|
||||
{
|
||||
$a = $this->returnDefault();
|
||||
$a->defaultScope('test.default');
|
||||
$a->setDefaultScope('test.default');
|
||||
|
||||
$reflector = new ReflectionClass($a);
|
||||
$requestProperty = $reflector->getProperty('defaultScope');
|
||||
@ -116,6 +116,13 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('test.default', $v);
|
||||
}
|
||||
|
||||
public function test_getDefaultScope()
|
||||
{
|
||||
$a = $this->returnDefault();
|
||||
$a->setDefaultScope('test.default');
|
||||
$this->assertEquals('test.default', $a->getDefaultScope());
|
||||
}
|
||||
|
||||
public function test_requireStateParam()
|
||||
{
|
||||
$a = $this->returnDefault();
|
||||
@ -195,6 +202,20 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException OAuth2\Exception\ClientException
|
||||
* @expectedExceptionCode 0
|
||||
*/
|
||||
public function test_checkAuthoriseParams_noRequiredState()
|
||||
{
|
||||
$a = $this->returnDefault();
|
||||
$a->requireStateParam(true);
|
||||
$a->checkAuthoriseParams(array(
|
||||
'client_id' => 1234,
|
||||
'redirect_uri' => 'http://foo/redirect'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException OAuth2\Exception\ClientException
|
||||
* @expectedExceptionCode 8
|
||||
@ -275,6 +296,37 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
||||
));
|
||||
}
|
||||
|
||||
public function test_checkAuthoriseParams_defaultScope()
|
||||
{
|
||||
$this->client->shouldReceive('getClient')->andReturn(array(
|
||||
'client_id' => 1234,
|
||||
'client_secret' => 5678,
|
||||
'redirect_uri' => 'http://foo/redirect',
|
||||
'name' => 'Example Client'
|
||||
));
|
||||
|
||||
$this->scope->shouldReceive('getScope')->andReturn(array(
|
||||
'id' => 1,
|
||||
'scope' => 'foo',
|
||||
'name' => 'Foo Name',
|
||||
'description' => 'Foo Name Description'
|
||||
));
|
||||
|
||||
$a = $this->returnDefault();
|
||||
$a->addGrantType(new OAuth2\Grant\AuthCode($a));
|
||||
$a->setDefaultScope('test.scope');
|
||||
$a->requireScopeParam(false);
|
||||
|
||||
$params = $a->checkAuthoriseParams(array(
|
||||
'client_id' => 1234,
|
||||
'redirect_uri' => 'http://foo/redirect',
|
||||
'response_type' => 'code',
|
||||
'scope' => ''
|
||||
));
|
||||
|
||||
$this->assertArrayHasKey('scopes', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException OAuth2\Exception\ClientException
|
||||
* @expectedExceptionCode 4
|
||||
|
Loading…
Reference in New Issue
Block a user