Added Rabbit MQ config

added endpoint /api/v1/users/{id}

scope users-read-all

Change-Id: Ibe066b728b460052c619a2fcb0e83b8225543a1f
Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
smarcet 2020-06-21 00:56:08 -03:00
parent a20eb03b69
commit 68c10a2765
19 changed files with 1259 additions and 384 deletions

View File

@ -65,4 +65,18 @@ BANNING_ENABLE=
SUPPORT_EMAIL=
USER_SPAM_PROCESSOR_TO=
MAIL_FROM_EMAIL="noreply@openstack.org"
MAIL_FROM_NAME="noreply@openstack.org"
MAIL_FROM_NAME="noreply@openstack.org"
## RABBIT MQ
RABBITMQ_EXCHANGE_NAME=databus-exchange
RABBITMQ_HOST=
RABBITMQ_PORT=5671
RABBITMQ_VHOST=databus
RABBITMQ_LOGIN=admin
RABBITMQ_PASSWORD=1qaz2wsx
RABBITMQ_QUEUE=default
RABBITMQ_SSL=true
RABBITMQ_SSL_CAFILE=/certs/rabbit/ca-osf.pem
RABBITMQ_SSL_LOCALCERT=/certs/rabbit/client-cert-osf.pem
RABBITMQ_SSL_LOCALKEY=/certs/rabbit/client-key-osf.pem
RABBITMQ_SSL_VERIFY_PEER=false

View File

@ -13,53 +13,66 @@
**/
use App\Http\Controllers\GetAllTrait;
use App\Http\Utils\PagingConstants;
use App\ModelSerializers\SerializerRegistry;
use Auth\Repositories\IUserRepository;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Validator;
use models\exceptions\EntityNotFoundException;
use models\exceptions\ValidationException;
use OAuth2\Builders\IdTokenBuilder;
use OAuth2\IResourceServerContext;
use OAuth2\Repositories\IClientRepository;
use OAuth2\ResourceServer\IUserService;
use utils\Filter;
use utils\FilterParser;
use Utils\Http\HttpContentType;
use utils\OrderParser;
use utils\PagingInfo;
use Utils\Services\ILogService;
use Exception;
/**
* Class OAuth2UserApiController
* @package App\Http\Controllers\Api\OAuth2
*/
final class OAuth2UserApiController extends OAuth2ProtectedController
final class OAuth2UserApiController extends OAuth2ProtectedController
{
use GetAllTrait;
protected function getAllSerializerType():string{
protected function getAllSerializerType(): string
{
return SerializerRegistry::SerializerType_Private;
}
/**
* @return array
*/
protected function getFilterRules():array
protected function getFilterRules(): array
{
return [
'first_name' => ['=@', '=='],
'last_name' => ['=@', '=='],
'email' => ['=@', '=='],
'last_name' => ['=@', '=='],
'email' => ['=@', '=='],
];
}
public function getOrderRules():array{
public function getOrderRules(): array
{
return [];
}
/**
* @return array
*/
protected function getFilterValidatorRules():array
protected function getFilterValidatorRules(): array
{
return [
'first_name' => 'sometimes|required|string',
'last_name' => 'sometimes|required|string',
'email' => 'sometimes|required|string',
'first_name' => 'sometimes|required|string',
'last_name' => 'sometimes|required|string',
'email' => 'sometimes|required|string',
];
}
@ -97,10 +110,10 @@ use Exception;
)
{
parent::__construct($resource_server_context, $log_service);
$this->repository = $repository;
$this->user_service = $user_service;
$this->repository = $repository;
$this->user_service = $user_service;
$this->client_repository = $client_repository;
$this->id_token_builder = $id_token_builder;
$this->id_token_builder = $id_token_builder;
}
/**
@ -109,13 +122,10 @@ use Exception;
*/
public function me()
{
try
{
try {
$data = $this->user_service->getCurrentUserInfo();
return $this->ok($data);
}
catch(Exception $ex)
{
} catch (Exception $ex) {
$this->log_service->error($ex);
return $this->error500($ex);
}
@ -123,11 +133,10 @@ use Exception;
public function userInfo()
{
try
{
$claims = $this->user_service->getCurrentUserInfoClaims();
try {
$claims = $this->user_service->getCurrentUserInfoClaims();
$client_id = $this->resource_server_context->getCurrentClientId();
$client = $this->client_repository->getClientById($client_id);
$client = $this->client_repository->getClientById($client_id);
// The UserInfo Claims MUST be returned as the members of a JSON object unless a signed or encrypted response
// was requested during Client Registration.
@ -135,29 +144,47 @@ use Exception;
$sig_alg = $user_info_response_info->getSigningAlgorithm();
$enc_alg = $user_info_response_info->getEncryptionKeyAlgorithm();
$enc = $user_info_response_info->getEncryptionContentAlgorithm();
$enc = $user_info_response_info->getEncryptionContentAlgorithm();
if($sig_alg || ($enc_alg && $enc) )
{
if ($sig_alg || ($enc_alg && $enc)) {
$jwt = $this->id_token_builder->buildJWT($claims, $user_info_response_info, $client);
$http_response = Response::make($jwt->toCompactSerialization(), 200);
$http_response->header('Content-Type', HttpContentType::JWT);
$http_response->header('Cache-Control','no-cache, no-store, max-age=0, must-revalidate');
$http_response->header('Pragma','no-cache');
$http_response->header('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate');
$http_response->header('Pragma', 'no-cache');
return $http_response;
}
else
{
} else {
// return plain json
return $this->ok( $claims->toArray() );
return $this->ok($claims->toArray());
}
}
catch(Exception $ex)
{
} catch (Exception $ex) {
$this->log_service->error($ex);
return $this->error500($ex);
}
}
/**
* @param $id
* @return \Illuminate\Http\JsonResponse|mixed
*/
public function get($id)
{
try {
$user = $this->repository->getById(intval($id));
if (is_null($user)) {
throw new EntityNotFoundException();
}
return $this->ok(SerializerRegistry::getInstance()->getSerializer($user, SerializerRegistry::SerializerType_Private)->serialize());
} catch (ValidationException $ex1) {
Log::warning($ex1);
return $this->error412($ex1->getMessages());
} catch (EntityNotFoundException $ex2) {
Log::warning($ex2);
return $this->error404(['message' => $ex2->getMessage()]);
} catch (Exception $ex) {
Log::error($ex);
return $this->error500($ex);
}
}
}

View File

@ -376,6 +376,7 @@ Route::group(
Route::group(['prefix' => 'users'], function () {
Route::get('', 'OAuth2UserApiController@getAll');
Route::get('/{id}', 'OAuth2UserApiController@get');
Route::get('/me', 'OAuth2UserApiController@me');
Route::get('/info', 'OAuth2UserApiController@userInfo');
Route::post('/info', 'OAuth2UserApiController@userInfo');

View File

@ -0,0 +1,56 @@
<?php namespace App\Jobs;
/**
* Copyright 2020 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Auth\User;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;
/**
* Class PublishUserCreated
* @package App\Jobs
*/
class PublishUserCreated implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* @var int
*/
public $user_id;
/**
* @var string
*/
public $user_email;
public function __construct(User $newUser)
{
$this->user_email = $newUser->getEmail();
$this->user_id = $newUser->getId();
Log::debug(sprintf("PublishUserCreated::PublishUserCreated user %s", $this->user_email));
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
}
}

View File

@ -0,0 +1,55 @@
<?php namespace App\Jobs;
/**
* Copyright 2020 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Auth\User;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;
/**
* Class PublishUserDeleted
* @package App\Jobs
*/
class PublishUserDeleted implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* @var int
*/
public $user_id;
/**
* @var string
*/
public $user_email;
public function __construct(User $newUser)
{
$this->user_email = $newUser->getEmail();
$this->user_id = $newUser->getId();
Log::debug(sprintf("PublishUserDeleted::PublishUserDeleted user %s", $this->user_email));
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
}
}

View File

@ -0,0 +1,55 @@
<?php namespace App\Jobs;
/**
* Copyright 2020 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Auth\User;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;
/**
* Class PublishUserUpdated
* @package App\Jobs
*/
class PublishUserUpdated implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* @var int
*/
public $user_id;
/**
* @var string
*/
public $user_email;
public function __construct(User $newUser)
{
$this->user_email = $newUser->getEmail();
$this->user_id = $newUser->getId();
Log::debug(sprintf("PublishUserUpdated::PublishUserUpdated user %s", $this->user_email));
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
}
}

View File

@ -11,7 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use App\ModelSerializers\BaseSerializer;
use Auth\Group;
use Auth\User;
use Illuminate\Support\Facades\Auth;
/**
* Class BaseUserSerializer
* @package App\ModelSerializers\Auth
@ -19,23 +24,51 @@ use App\ModelSerializers\BaseSerializer;
class BaseUserSerializer extends BaseSerializer
{
protected static $array_mappings = [
'FirstName' => 'first_name:json_string',
'LastName' => 'last_name:json_string',
'FirstName' => 'first_name:json_string',
'LastName' => 'last_name:json_string',
];
}
final class PublicUserSerializer extends BaseUserSerializer {
final class PublicUserSerializer extends BaseUserSerializer
{
}
final class PrivateUserSerializer extends BaseUserSerializer {
final class PrivateUserSerializer extends BaseUserSerializer
{
protected static $array_mappings = [
'Email' => 'email:json_string',
'SpamType' => 'spam_type:json_string',
'Identifier' => 'identifier:json_string',
'LastLoginDate' => 'last_login_date:datetime_epoch',
'Active' => 'active:json_boolean',
'EmailVerified' => 'email_verified:json_boolean'
'Email' => 'email:json_string',
'Bio' => 'bio:json_string',
'Gender' => 'gender:json_string',
'SpamType' => 'spam_type:json_string',
'Identifier' => 'identifier:json_string',
'LastLoginDate' => 'last_login_date:datetime_epoch',
'Active' => 'active:json_boolean',
'EmailVerified' => 'email_verified:json_boolean'
];
/**
* @param null $expand
* @param array $fields
* @param array $relations
* @param array $params
* @return array
*/
public function serialize($expand = null, array $fields = [], array $relations = [], array $params = [])
{
$user = $this->object;
if (!$user instanceof User) return [];
$values = parent::serialize($expand, $fields, $relations, $params);
$groups = [];
foreach ($user->getGroups() as $group) {
if (!$group instanceof Group) continue;
$groups[] = $group->getSlug();
}
$values['groups'] = $groups;
return $values;
}
}

View File

@ -17,6 +17,7 @@ use App\Events\UserLocked;
use App\Events\UserPasswordResetRequestCreated;
use App\Events\UserPasswordResetSuccessful;
use App\Events\UserSpamStateUpdated;
use App\Jobs\PublishUserCreated;
use App\libs\Auth\Repositories\IUserPasswordResetRequestRepository;
use App\Mail\UserLockedEmail;
use App\Mail\UserPasswordResetMail;
@ -30,6 +31,7 @@ use Illuminate\Support\Facades\App;
use App\Events\UserCreated;
use App\Events\UserEmailVerified;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Config;
use Models\OAuth2\Client;
@ -80,6 +82,14 @@ final class EventServiceProvider extends ServiceProvider
Mail::queue(new WelcomeNewUserEmail($user));
if(!$user->isEmailVerified() && !$user->hasCreator())
$user_service->sendVerificationEmail($user);
try {
if(Config::get("queue.enable_message_broker", false) == true)
PublishUserCreated::dispatch($user)->onConnection('message_broker');
}
catch (\Exception $ex){
Log::warning($ex);
}
});
Event::listen(UserSpamStateUpdated::class, function($event)

View File

@ -11,11 +11,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use App\Jobs\PublishUserUpdated;
use App\libs\Auth\Factories\GroupFactory;
use App\libs\Auth\Repositories\IGroupRepository;
use App\Services\AbstractService;
use Auth\Group;
use Auth\Repositories\IUserRepository;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use models\exceptions\EntityNotFoundException;
use models\exceptions\ValidationException;
use models\utils\IEntity;
@ -148,6 +152,14 @@ final class GroupService extends AbstractService implements IGroupService
throw new EntityNotFoundException();
$user->addToGroup($group);
try {
if(Config::get("queue.enable_message_broker", false) == true)
PublishUserUpdated::dispatch($user)->onConnection('message_broker');
}
catch (\Exception $ex){
Log::warning($ex);
}
});
}
@ -165,6 +177,14 @@ final class GroupService extends AbstractService implements IGroupService
throw new EntityNotFoundException();
$user->removeFromGroup($group);
try {
if(Config::get("queue.enable_message_broker", false) == true)
PublishUserUpdated::dispatch($user)->onConnection('message_broker');
}
catch (\Exception $ex){
Log::warning($ex);
}
});
}
}

View File

@ -12,12 +12,16 @@
* limitations under the License.
**/
use App\Events\UserEmailUpdated;
use App\Jobs\PublishUserCreated;
use App\Jobs\PublishUserDeleted;
use App\Jobs\PublishUserUpdated;
use App\libs\Auth\Factories\UserFactory;
use App\libs\Auth\Repositories\IGroupRepository;
use App\Services\AbstractService;
use Auth\IUserNameGeneratorService;
use Auth\Repositories\IUserRepository;
use Auth\User;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;
use models\exceptions\EntityNotFoundException;
@ -258,6 +262,14 @@ final class UserService extends AbstractService implements IUserService
Event::fire(new UserEmailUpdated($user->getId()));
}
try {
if(Config::get("queue.enable_message_broker", false) == true)
PublishUserUpdated::dispatch($user)->onConnection('message_broker');
}
catch (\Exception $ex){
Log::warning($ex);
}
return $user;
});
@ -275,6 +287,14 @@ final class UserService extends AbstractService implements IUserService
if(is_null($user) || !$user instanceof User)
throw new EntityNotFoundException("user not found");
$this->repository->delete($user);
try {
if(Config::get("queue.enable_message_broker", false) == true)
PublishUserDeleted::dispatch($user)->onConnection('message_broker');
}
catch (\Exception $ex){
Log::warning($ex);
}
});
}
}

View File

@ -284,7 +284,7 @@ final class AuthService implements IAuthService
{
try {
$rps = Cookie::get(IAuthService::LOGGED_RELAYING_PARTIES_COOKIE_NAME);
$rps = Cookie::get(IAuthService::LOGGED_RELAYING_PARTIES_COOKIE_NAME, "");
$zlib = CompressionAlgorithms_Registry::getInstance()->get(CompressionAlgorithmsNames::ZLib);
if (!empty($rps)) {

View File

@ -32,8 +32,8 @@ final class OAuth2AuthorizationRequestFactory
public function build(OAuth2Message $msg){
$auth_request = new OAuth2AuthorizationRequest($msg);
if( str_contains($auth_request->getScope(), OAuth2Protocol::OpenIdConnect_Scope) ) {
$scope = $auth_request->getScope();
if(!is_null($scope) && str_contains($scope, OAuth2Protocol::OpenIdConnect_Scope) ) {
$auth_request = new OAuth2AuthenticationRequest($auth_request);
}

View File

@ -16,28 +16,29 @@
"ext-json": "*",
"ext-pdo": "*",
"beberlei/DoctrineExtensions": "1.1.5",
"ezyang/htmlpurifier": "^4.10",
"ezyang/htmlpurifier": "v4.12.0",
"fideloper/proxy": "^4.0",
"glenscott/url-normalizer": "1.4.*",
"greggilbert/recaptcha": "2.1.*",
"glenscott/url-normalizer": "1.4.0",
"greggilbert/recaptcha": "2.1.1",
"guzzlehttp/guzzle": "6.3.3",
"ircmaxell/random-lib": "1.1.*",
"ircmaxell/random-lib": "1.1.0",
"jenssegers/agent": "2.6.3",
"doctrine/orm": "2.6.4",
"doctrine/persistence": "1.1.1",
"laravel-doctrine/extensions": "1.0.*",
"laravel-doctrine/migrations": "^1.2",
"laravel-doctrine/extensions": "1.0.14",
"laravel-doctrine/migrations": "1.2.0",
"laravel-doctrine/orm": "1.4.11",
"laravel/framework": "5.6.*",
"laravel/framework": "5.6.39",
"laravel/tinker": "^1.0",
"laravelcollective/html": "5.6.*",
"laravelcollective/html": "5.6.10",
"phpseclib/phpseclib": "2.0.11",
"predis/predis": "1.0.*",
"s-ichikawa/laravel-sendgrid-driver": "^2.0",
"predis/predis": "v1.0.4",
"s-ichikawa/laravel-sendgrid-driver": "2.1.0",
"smarcet/jose4php": "1.0.17",
"sokil/php-isocodes": "^3.0",
"zendframework/zend-crypt": "3.3.0",
"zendframework/zend-math": "3.1.1"
"zendframework/zend-math": "3.1.1",
"vladimir-yuldashev/laravel-queue-rabbitmq": "v7.5.0"
},
"require-dev": {
"filp/whoops": "^2.0",

1112
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@ return [
*/
'default' => env('QUEUE_DRIVER', 'database'),
'enable_message_broker' => env("ENABLE_MESSAGE_BROKER", false),
/*
|--------------------------------------------------------------------------
| Queue Connections
@ -39,6 +39,102 @@ return [
'queue' => 'default',
'expire' => 60,
],
// ...
'message_broker' => [
'driver' => 'rabbitmq',
'dsn' => env('RABBITMQ_DSN', null),
/*
* Could be one a class that implements \Interop\Amqp\AmqpConnectionFactory for example:
* - \EnqueueAmqpExt\AmqpConnectionFactory if you install enqueue/amqp-ext
* - \EnqueueAmqpLib\AmqpConnectionFactory if you install enqueue/amqp-lib
* - \EnqueueAmqpBunny\AmqpConnectionFactory if you install enqueue/amqp-bunny
*/
'factory_class' => Enqueue\AmqpLib\AmqpConnectionFactory::class,
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
'port' => env('RABBITMQ_PORT', 5672),
'vhost' => env('RABBITMQ_VHOST', 'default'),
'login' => env('RABBITMQ_LOGIN', 'guest'),
'password' => env('RABBITMQ_PASSWORD', 'guest'),
'queue' => env('RABBITMQ_QUEUE', ''),
'options' => [
'exchange' => [
'name' => env('RABBITMQ_EXCHANGE_NAME'),
/*
* Determine if exchange should be created if it does not exist.
*/
'declare' => env('RABBITMQ_EXCHANGE_DECLARE', true),
/*
* Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
*/
'type' => env('RABBITMQ_EXCHANGE_TYPE', \Interop\Amqp\AmqpTopic::TYPE_FANOUT),
'passive' => env('RABBITMQ_EXCHANGE_PASSIVE', false),
'durable' => env('RABBITMQ_EXCHANGE_DURABLE', true),
'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', true),
'arguments' => env('RABBITMQ_EXCHANGE_ARGUMENTS'),
],
'queue' => [
/*
* Determine if queue should be created if it does not exist.
*/
'declare' => env('RABBITMQ_QUEUE_DECLARE', false),
/*
* Determine if queue should be binded to the exchange created.
*/
'bind' => env('RABBITMQ_QUEUE_DECLARE_BIND', false),
/*
* Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
*/
'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
'arguments' => env('RABBITMQ_QUEUE_ARGUMENTS'),
],
],
/*
* Determine the number of seconds to sleep if there's an error communicating with rabbitmq
* If set to false, it'll throw an exception rather than doing the sleep for X seconds.
*/
'sleep_on_error' => env('RABBITMQ_ERROR_SLEEP', 5),
/*
* Optional SSL params if an SSL connection is used
* Using an SSL connection will also require to configure your RabbitMQ to enable SSL. More details can be founds here: https://www.rabbitmq.com/ssl.html
*/
'ssl_params' => [
'ssl_on' => env('RABBITMQ_SSL', false),
'cafile' => env('RABBITMQ_SSL_CAFILE', null),
'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', false),
'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
],
],
],
/*

View File

@ -73,8 +73,17 @@ class ApiEndpointSeeder extends Seeder
'scopes' => [
\App\libs\OAuth2\IUserScopes::ReadAll
],
],
// get user by id
[
'name' => 'get-user-by-id',
'active' => true,
'route' => '/api/v1/users/{id}',
'http_method' => 'GET',
'scopes' => [
\App\libs\OAuth2\IUserScopes::ReadAll
],
]
]
);
}

View File

@ -15,6 +15,7 @@
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Redis;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
/**
@ -51,6 +52,7 @@ abstract class BrowserKitTestCase extends BaseTestCase
{
Artisan::call('doctrine:migrations:migrate', ['--connection=model ']);
Mail::fake();
Queue::fake();
$this->seed('TestSeeder');
}
}

View File

@ -37,7 +37,7 @@ final class OAuth2ClientTests extends TestCase
$this->redis->flushall();
}
public function testGetClient($appName = 'Call For Presentations'):Client
public function testGetClient($appName = 'Call For Presentations'): Client
{
$repo = EntityManager::getRepository(Client::class);
$client = $repo->getByApplicationName($appName);
@ -48,11 +48,4 @@ final class OAuth2ClientTests extends TestCase
return $client;
}
public function testClearAccessTokens(){
$client = $this->testGetClient();
$this->assertTrue($client->hasAccessTokens());
$client->removeAllAccessTokens();
EntityManager::flush();
}
}

View File

@ -65,6 +65,7 @@ final class OAuth2UserRegistrationServiceApiTest extends OAuth2ProtectedApiTest
protected function getScopes()
{
$scope = [
"openid",
IUserScopes::Registration,
];