mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 22:13:13 +00:00
Update ApiApplication method call
This commit is contained in:
@@ -64,7 +64,7 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!self::$apiInitialized) {
|
if (!self::$apiInitialized) {
|
||||||
self::$account = \API_OAuth2_Account::load_with_user(self::$DI['app'], self::$DI['oauth2-app-user_notAdmin'], self::$DI['user_notAdmin']);
|
self::$account = \API_OAuth2_Account::load_with_user(self::$DI['app'], self::$DI['oauth2-app-user-not-admin'], self::$DI['user_notAdmin']);
|
||||||
self::$account->set_revoked(false);
|
self::$account->set_revoked(false);
|
||||||
self::$token = self::$account->get_token()->get_value();
|
self::$token = self::$account->get_token()->get_value();
|
||||||
|
|
||||||
|
@@ -32,8 +32,8 @@ class OAuth2Test extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$this->queryParameters = [
|
$this->queryParameters = [
|
||||||
"response_type" => "code",
|
"response_type" => "code",
|
||||||
"client_id" => self::$DI['oauth2-app-user']->get_client_id(),
|
"client_id" => self::$DI['oauth2-app-user']->getClientId(),
|
||||||
"redirect_uri" => self::$DI['oauth2-app-user']->get_redirect_uri(),
|
"redirect_uri" => self::$DI['oauth2-app-user']->getRedirectId(),
|
||||||
"scope" => "",
|
"scope" => "",
|
||||||
"state" => "valueTest"
|
"state" => "valueTest"
|
||||||
];
|
];
|
||||||
@@ -96,7 +96,7 @@ class OAuth2Test extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
public static function getAccount()
|
public static function getAccount()
|
||||||
{
|
{
|
||||||
$sql = "SELECT api_account_id FROM api_accounts WHERE application_id = :app_id AND usr_id = :usr_id";
|
$sql = "SELECT api_account_id FROM api_accounts WHERE application_id = :app_id AND usr_id = :usr_id";
|
||||||
$t = [":app_id" => self::$DI['oauth2-app-user']->get_id(), ":usr_id" => self::$DI['user']->getId()];
|
$t = [":app_id" => self::$DI['oauth2-app-user']->getId(), ":usr_id" => self::$DI['user']->getId()];
|
||||||
$conn = self::$DI['app']['phraseanet.appbox']->get_connection();
|
$conn = self::$DI['app']['phraseanet.appbox']->get_connection();
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute($t);
|
$stmt->execute($t);
|
||||||
@@ -135,8 +135,8 @@ class OAuth2Test extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
self::$DI['client']->request('GET', '/api/oauthv2/authorize', $this->queryParameters);
|
self::$DI['client']->request('GET', '/api/oauthv2/authorize', $this->queryParameters);
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isSuccessful());
|
$this->assertTrue(self::$DI['client']->getResponse()->isSuccessful());
|
||||||
$this->assertRegExp("/" . self::$DI['oauth2-app-user']->get_client_id() . "/", self::$DI['client']->getResponse()->getContent());
|
$this->assertRegExp("/" . self::$DI['oauth2-app-user']->getCLientId() . "/", self::$DI['client']->getResponse()->getContent());
|
||||||
$this->assertRegExp("/" . str_replace("/", '\/', self::$DI['oauth2-app-user']->get_redirect_uri()) . "/", self::$DI['client']->getResponse()->getContent());
|
$this->assertRegExp("/" . str_replace("/", '\/', self::$DI['oauth2-app-user']->getRedirectUri()) . "/", self::$DI['client']->getResponse()->getContent());
|
||||||
$this->assertRegExp("/" . $this->queryParameters["response_type"] . "/", self::$DI['client']->getResponse()->getContent());
|
$this->assertRegExp("/" . $this->queryParameters["response_type"] . "/", self::$DI['client']->getResponse()->getContent());
|
||||||
$this->assertRegExp("/" . $this->queryParameters["scope"] . "/", self::$DI['client']->getResponse()->getContent());
|
$this->assertRegExp("/" . $this->queryParameters["scope"] . "/", self::$DI['client']->getResponse()->getContent());
|
||||||
$this->assertRegExp("/" . $this->queryParameters["state"] . "/", self::$DI['client']->getResponse()->getContent());
|
$this->assertRegExp("/" . $this->queryParameters["state"] . "/", self::$DI['client']->getResponse()->getContent());
|
||||||
|
@@ -376,7 +376,7 @@ class AccountTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testAUthorizedAppGrantAccessSuccessfull($revoke, $expected)
|
public function testAUthorizedAppGrantAccessSuccessfull($revoke, $expected)
|
||||||
{
|
{
|
||||||
self::$DI['client']->request('GET', '/account/security/application/' . self::$DI['oauth2-app-user']->get_id() . '/grant/', [
|
self::$DI['client']->request('GET', '/account/security/application/' . self::$DI['oauth2-app-user']->getId() . '/grant/', [
|
||||||
'revoke' => $revoke
|
'revoke' => $revoke
|
||||||
], [], [
|
], [], [
|
||||||
'HTTP_ACCEPT' => 'application/json',
|
'HTTP_ACCEPT' => 'application/json',
|
||||||
|
@@ -202,7 +202,7 @@ abstract class PhraseanetTestCase extends WebTestCase
|
|||||||
return new $DI['app']['repo.api-applications']->find(self::$fixtureIds['oauth']['user']);
|
return new $DI['app']['repo.api-applications']->find(self::$fixtureIds['oauth']['user']);
|
||||||
});
|
});
|
||||||
|
|
||||||
self::$DI['oauth2-app-user_notAdmin'] = self::$DI->share(function ($DI) {
|
self::$DI['oauth2-app-user-not-admin'] = self::$DI->share(function ($DI) {
|
||||||
return new $DI['app']['repo.api-applications']->find(self::$fixtureIds['oauth']['user-not-admin']);
|
return new $DI['app']['repo.api-applications']->find(self::$fixtureIds['oauth']['user-not-admin']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ class api_oauthv2_ApplicationTest extends \PhraseanetTestCase
|
|||||||
$found = false;
|
$found = false;
|
||||||
|
|
||||||
foreach ($apps as $app) {
|
foreach ($apps as $app) {
|
||||||
if ($app->get_id() === self::$DI['oauth2-app-user']->get_id()) {
|
if ($app->get_id() === self::$DI['oauth2-app-user']->getId()) {
|
||||||
$found = true;
|
$found = true;
|
||||||
}
|
}
|
||||||
$this->assertInstanceOf('ApiApplication', $app);
|
$this->assertInstanceOf('ApiApplication', $app);
|
||||||
@@ -55,9 +55,9 @@ class api_oauthv2_ApplicationTest extends \PhraseanetTestCase
|
|||||||
$this->assertTrue(in_array(self::$DI['oauth2-app-user']->getType(), [ApiApplication::DESKTOP_TYPE, ApiApplication::WEB_TYPE]));
|
$this->assertTrue(in_array(self::$DI['oauth2-app-user']->getType(), [ApiApplication::DESKTOP_TYPE, ApiApplication::WEB_TYPE]));
|
||||||
$this->assertTrue(is_string(self::$DI['oauth2-app-user']->getNonce()));
|
$this->assertTrue(is_string(self::$DI['oauth2-app-user']->getNonce()));
|
||||||
$this->assertEquals(64, strlen(self::$DI['oauth2-app-user']->getNonce()));
|
$this->assertEquals(64, strlen(self::$DI['oauth2-app-user']->getNonce()));
|
||||||
self::$DI['oauth2-app-user']->set_type(ApiApplication::WEB_TYPE);
|
self::$DI['oauth2-app-user']->setType(ApiApplication::WEB_TYPE);
|
||||||
$this->assertEquals(ApiApplication::WEB_TYPE, self::$DI['oauth2-app-user']->getType());
|
$this->assertEquals(ApiApplication::WEB_TYPE, self::$DI['oauth2-app-user']->getType());
|
||||||
self::$DI['oauth2-app-user']->set_type(ApiApplication::DESKTOP_TYPE);
|
self::$DI['oauth2-app-user']->setType(ApiApplication::DESKTOP_TYPE);
|
||||||
$this->assertEquals(ApiApplication::DESKTOP_TYPE, self::$DI['oauth2-app-user']->getType());
|
$this->assertEquals(ApiApplication::DESKTOP_TYPE, self::$DI['oauth2-app-user']->getType());
|
||||||
$this->assertEquals(ApiApplication::NATIVE_APP_REDIRECT_URI, self::$DI['oauth2-app-user']->getRedirectUri());
|
$this->assertEquals(ApiApplication::NATIVE_APP_REDIRECT_URI, self::$DI['oauth2-app-user']->getRedirectUri());
|
||||||
self::$DI['oauth2-app-user']->setType(ApiApplication::WEB_TYPE);
|
self::$DI['oauth2-app-user']->setType(ApiApplication::WEB_TYPE);
|
||||||
|
Reference in New Issue
Block a user