-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from gregorip02/2.x
[2.x] new permissive authorizer
- Loading branch information
Showing
23 changed files
with
173 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Restql\Authorizers; | ||
|
||
use Restql\Authorizer; | ||
|
||
final class PermissiveAuthorizer extends Authorizer | ||
{ | ||
/** | ||
* Can get one or more resources. | ||
* | ||
* @param array $clausules | ||
* @return bool | ||
*/ | ||
public static function get($clausules = []): bool | ||
{ | ||
return true; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Testing\Feature\Clausules; | ||
|
||
use Testing\TestCase; | ||
|
||
final class WhereInClausuleTest extends TestCase | ||
{ | ||
/** | ||
* Fake in articles id. | ||
* | ||
* @var array | ||
*/ | ||
protected $articles = [1, 3, 10, 14]; | ||
|
||
/** | ||
* @test Get articles where id in (1, 14, 3, 10) | ||
*/ | ||
public function getArticlesWhereIdInUsingImplicitMethod(): void | ||
{ | ||
$response = $this->json('get', 'restql', [ | ||
'articles' => [ | ||
'whereIn' => [$this->articles], | ||
'select' => 'id' | ||
] | ||
]); | ||
|
||
$response->assertJsonCount(count($this->articles), 'data.articles'); | ||
|
||
$response->assertExactJson([ | ||
'data' => [ | ||
'articles' => array_map(function (int $id) { | ||
return ['id' => $id]; | ||
}, $this->articles) | ||
] | ||
]); | ||
|
||
$articles = $response->decodeResponseJson('data.articles.*.id'); | ||
|
||
$this->assertEquals($this->articles, $articles); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Testing\Feature\Clausules; | ||
|
||
use Testing\TestCase; | ||
|
||
final class WhereNotInClausuleTest extends TestCase | ||
{ | ||
/** | ||
* Fake not in articles. | ||
* | ||
* @var array | ||
*/ | ||
protected $articles = [4, 5, 9, 10]; | ||
|
||
/** | ||
* @test Exclude articles where id not in (4, 5, 9, 10) | ||
*/ | ||
public function excludeArticlesWhereIdNotInUsingImplicitMethod(): void | ||
{ | ||
$response = $this->json('get', 'restql', [ | ||
'articles' => [ | ||
'select' => 'id', | ||
'whereNotIn' => [$this->articles] | ||
] | ||
]); | ||
|
||
/// We get 15 by default because we are excluding [$this->articles] | ||
/// and this is rejected with others articles. | ||
$response->assertJsonCount(15, 'data.articles'); | ||
|
||
$articles = $response->decodeResponseJson('data.articles.*.id'); | ||
|
||
/// Don't see any article id defined in $this->articles in | ||
/// $articles responsed by RestQL. | ||
foreach ($this->articles as $article) { | ||
$this->assertFalse( | ||
in_array($article, $articles) | ||
); | ||
} | ||
} | ||
} |