mirror of
				https://github.com/elyby/accounts.git
				synced 2025-05-31 14:11:46 +05:30 
			
		
		
		
	Все действия, связанные с аккаунтами, теперь вызываются через url `/api/v1/accounts/<id>/<action>`. Добавлена вменяемая система разграничения прав на основе RBAC. Теперь oAuth2 токены генерируются как случайная строка в 40 символов длинной, а не UUID. Исправлен баг с неправильным временем жизни токена в ответе успешного запроса аутентификации. Теперь все unit тесты можно успешно прогнать без наличия интернета.
		
			
				
	
	
		
			66 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
namespace codeception\api\functional;
 | 
						|
 | 
						|
use tests\codeception\api\_pages\IdentityInfoRoute;
 | 
						|
use tests\codeception\api\functional\_steps\OauthSteps;
 | 
						|
use tests\codeception\api\FunctionalTester;
 | 
						|
 | 
						|
class IdentityInfoCest {
 | 
						|
 | 
						|
    /**
 | 
						|
     * @var IdentityInfoRoute
 | 
						|
     */
 | 
						|
    private $route;
 | 
						|
 | 
						|
    public function _before(FunctionalTester $I) {
 | 
						|
        $this->route = new IdentityInfoRoute($I);
 | 
						|
    }
 | 
						|
 | 
						|
    public function testGetErrorIfNotEnoughPerms(OauthSteps $I) {
 | 
						|
        $accessToken = $I->getAccessToken();
 | 
						|
        $I->amBearerAuthenticated($accessToken);
 | 
						|
        $this->route->info();
 | 
						|
        $I->canSeeResponseCodeIs(403);
 | 
						|
        $I->canSeeResponseIsJson();
 | 
						|
        $I->canSeeResponseContainsJson([
 | 
						|
            'name' => 'Forbidden',
 | 
						|
            'status' => 403,
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
    public function testGetInfo(OauthSteps $I) {
 | 
						|
        $accessToken = $I->getAccessToken(['account_info']);
 | 
						|
        $I->amBearerAuthenticated($accessToken);
 | 
						|
        $this->route->info();
 | 
						|
        $I->canSeeResponseCodeIs(200);
 | 
						|
        $I->canSeeResponseIsJson();
 | 
						|
        $I->canSeeResponseContainsJson([
 | 
						|
            'id' => 1,
 | 
						|
            'uuid' => 'df936908-b2e1-544d-96f8-2977ec213022',
 | 
						|
            'username' => 'Admin',
 | 
						|
            'registeredAt' => 1451775316,
 | 
						|
            'profileLink' => 'http://ely.by/u1',
 | 
						|
            'preferredLanguage' => 'en',
 | 
						|
        ]);
 | 
						|
        $I->cantSeeResponseJsonMatchesJsonPath('$.email');
 | 
						|
    }
 | 
						|
 | 
						|
    public function testGetInfoWithEmail(OauthSteps $I) {
 | 
						|
        $accessToken = $I->getAccessToken(['account_info', 'account_email']);
 | 
						|
        $I->amBearerAuthenticated($accessToken);
 | 
						|
        $this->route->info();
 | 
						|
        $I->canSeeResponseCodeIs(200);
 | 
						|
        $I->canSeeResponseIsJson();
 | 
						|
        $I->canSeeResponseContainsJson([
 | 
						|
            'id' => 1,
 | 
						|
            'uuid' => 'df936908-b2e1-544d-96f8-2977ec213022',
 | 
						|
            'username' => 'Admin',
 | 
						|
            'registeredAt' => 1451775316,
 | 
						|
            'profileLink' => 'http://ely.by/u1',
 | 
						|
            'preferredLanguage' => 'en',
 | 
						|
            'email' => 'admin@ely.by',
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
}
 |