Update ApiApplication method call

This commit is contained in:
Nicolas Le Goff
2014-03-05 20:58:33 +01:00
parent 5d6ee3718a
commit d1d936d8b8
5 changed files with 11 additions and 11 deletions

View File

@@ -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();

View File

@@ -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());

View File

@@ -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',

View File

@@ -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']);
}); });

View File

@@ -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);