Fixes #17. Simplify redirect_uri validation rules to allow localhost

This commit is contained in:
ErickSkrauch
2022-12-10 02:51:47 +01:00
parent 9c39e97640
commit 262bdbc08e
2 changed files with 25 additions and 33 deletions

View File

@@ -6,43 +6,14 @@ namespace api\tests\functional\dev\applications;
use api\tests\_pages\OauthRoute;
use api\tests\FunctionalTester;
class CreateClientCest {
final class CreateClientCest {
/**
* @var OauthRoute
*/
private $route;
private OauthRoute $route;
public function _before(FunctionalTester $I) {
$this->route = new OauthRoute($I);
}
public function testCreateApplicationWithWrongParams(FunctionalTester $I) {
$I->amAuthenticated('admin');
$this->route->createClient('application', []);
$I->canSeeResponseCodeIs(200);
$I->canSeeResponseContainsJson([
'success' => false,
'errors' => [
'name' => 'error.name_required',
'redirectUri' => 'error.redirectUri_required',
],
]);
$this->route->createClient('application', [
'name' => 'my test oauth client',
'redirectUri' => 'localhost',
]);
$I->canSeeResponseCodeIs(200);
$I->canSeeResponseContainsJson([
'success' => false,
'errors' => [
'redirectUri' => 'error.redirectUri_invalid',
],
]);
}
public function testCreateApplication(FunctionalTester $I) {
$I->amAuthenticated('admin');
$this->route->createClient('application', [
@@ -109,4 +80,18 @@ class CreateClientCest {
]);
}
public function testCreateApplicationWithWrongParams(FunctionalTester $I): void {
$I->amAuthenticated('admin');
$this->route->createClient('application', []);
$I->canSeeResponseCodeIs(200);
$I->canSeeResponseContainsJson([
'success' => false,
'errors' => [
'name' => 'error.name_required',
'redirectUri' => 'error.redirectUri_required',
],
]);
}
}