mirror of
				https://github.com/elyby/accounts.git
				synced 2025-05-31 14:11:46 +05:30 
			
		
		
		
	Добавлен client_credentials grant для oAuth Рефакторинг структуры OauthScopes чтобы можно было разделить владельца прав на пользовательские и общие (машинные) Исправлена стилистика кода, внедряются фишки PHP 7.1
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
namespace tests\codeception\api\functional\internal;
 | 
						|
 | 
						|
use common\models\OauthScope as S;
 | 
						|
use tests\codeception\api\_pages\InternalRoute;
 | 
						|
use tests\codeception\api\functional\_steps\OauthSteps;
 | 
						|
use tests\codeception\api\FunctionalTester;
 | 
						|
 | 
						|
class BanCest {
 | 
						|
 | 
						|
    /**
 | 
						|
     * @var InternalRoute
 | 
						|
     */
 | 
						|
    private $route;
 | 
						|
 | 
						|
    public function _before(FunctionalTester $I) {
 | 
						|
        $this->route = new InternalRoute($I);
 | 
						|
    }
 | 
						|
 | 
						|
    public function testBanAccount(OauthSteps $I) {
 | 
						|
        $accessToken = $I->getAccessTokenByClientCredentialsGrant([S::ACCOUNT_BLOCK]);
 | 
						|
        $I->amBearerAuthenticated($accessToken);
 | 
						|
 | 
						|
        $this->route->ban(1);
 | 
						|
        $I->canSeeResponseCodeIs(200);
 | 
						|
        $I->canSeeResponseIsJson();
 | 
						|
        $I->canSeeResponseContainsJson([
 | 
						|
            'success' => true,
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
    public function testBanBannedAccount(OauthSteps $I) {
 | 
						|
        $accessToken = $I->getAccessTokenByClientCredentialsGrant([S::ACCOUNT_BLOCK]);
 | 
						|
        $I->amBearerAuthenticated($accessToken);
 | 
						|
 | 
						|
        $this->route->ban(10);
 | 
						|
        $I->canSeeResponseCodeIs(200);
 | 
						|
        $I->canSeeResponseIsJson();
 | 
						|
        $I->canSeeResponseContainsJson([
 | 
						|
            'success' => false,
 | 
						|
            'errors' => [
 | 
						|
                'account' => 'error.account_already_banned',
 | 
						|
            ],
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
}
 |