From bafac25bafa2a3cfa14be50334957db0982870d9 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Sat, 15 Oct 2016 16:07:03 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D1=81=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0?= =?UTF-8?q?=D1=87=D0=B5=D0=B9=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=20=D0=B2=20=D1=82=D0=B5=D0=BB=D0=B5=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0=20+=20=D1=82=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D1=8B=20=D0=BF=D0=BE=D0=B4=20=D1=8D=D1=82=D0=BE=D1=82=20?= =?UTF-8?q?=D0=BA=D0=B5=D0=B9=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/modules/authserver/models/Form.php | 8 ++++---- .../api/functional/authserver/AuthorizationCest.php | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/api/modules/authserver/models/Form.php b/api/modules/authserver/models/Form.php index c749538..02006d8 100644 --- a/api/modules/authserver/models/Form.php +++ b/api/modules/authserver/models/Form.php @@ -16,10 +16,10 @@ abstract class Form extends Model { public function loadByPost() { $data = Yii::$app->request->post(); - // TODO: проверить, парсит ли Yii2 raw body и что он делает, если там неспаршенный json - /*if (empty($data)) { - $data = $request->getJsonRawBody(true); - }*/ + if (empty($data)) { + // TODO: помнится у Yii2 есть механизм парсинга данных входящего запроса. Лучше будет сделать это там + $data = json_decode(Yii::$app->request->getRawBody(), true); + } return $this->load($data); } diff --git a/tests/codeception/api/functional/authserver/AuthorizationCest.php b/tests/codeception/api/functional/authserver/AuthorizationCest.php index b46f120..cf712ed 100644 --- a/tests/codeception/api/functional/authserver/AuthorizationCest.php +++ b/tests/codeception/api/functional/authserver/AuthorizationCest.php @@ -38,6 +38,17 @@ class AuthorizationCest { $this->testSuccessResponse($I); } + public function byEmailWithParamsAsJsonInPostBody(FunctionalTester $I) { + $I->wantTo('authenticate by email and password, passing values as serialized string in post body'); + $this->route->authenticate(json_encode([ + 'username' => 'admin@ely.by', + 'password' => 'password_0', + 'clientToken' => Uuid::uuid4()->toString(), + ])); + + $this->testSuccessResponse($I); + } + public function wrongArguments(FunctionalTester $I) { $I->wantTo('get error on wrong amount of arguments'); $this->route->authenticate([