mirror of
				https://github.com/elyby/accounts.git
				synced 2025-05-31 14:11:46 +05:30 
			
		
		
		
	Добавлена поддержка авторизации с передачей параметров в теле запроса + тесты под этот кейс
This commit is contained in:
		@@ -16,10 +16,10 @@ abstract class Form extends Model {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function loadByPost() {
 | 
					    public function loadByPost() {
 | 
				
			||||||
        $data = Yii::$app->request->post();
 | 
					        $data = Yii::$app->request->post();
 | 
				
			||||||
        // TODO: проверить, парсит ли Yii2 raw body и что он делает, если там неспаршенный json
 | 
					        if (empty($data)) {
 | 
				
			||||||
        /*if (empty($data)) {
 | 
					            // TODO: помнится у Yii2 есть механизм парсинга данных входящего запроса. Лучше будет сделать это там
 | 
				
			||||||
            $data = $request->getJsonRawBody(true);
 | 
					            $data = json_decode(Yii::$app->request->getRawBody(), true);
 | 
				
			||||||
        }*/
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->load($data);
 | 
					        return $this->load($data);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,6 +38,17 @@ class AuthorizationCest {
 | 
				
			|||||||
        $this->testSuccessResponse($I);
 | 
					        $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) {
 | 
					    public function wrongArguments(FunctionalTester $I) {
 | 
				
			||||||
        $I->wantTo('get error on wrong amount of arguments');
 | 
					        $I->wantTo('get error on wrong amount of arguments');
 | 
				
			||||||
        $this->route->authenticate([
 | 
					        $this->route->authenticate([
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user