Skip to content

Commit 4ca7db6

Browse files
author
JP
committed
fix: seed groups API and scopes in TestSeeder so OAuth2GroupApiTest passes in clean environments
1 parent a642719 commit 4ca7db6

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

database/seeds/TestSeeder.php

100644100755
Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ public function run()
455455
$this->seedApiScopes();
456456
$this->seedApiEndpointScopes();
457457
$this->seedApiScopeScopes();
458+
$this->seedGroupScopes();
458459
$this->seedTestApiEndpoints();
459460
// clients
460461
$this->seedTestUsersAndClients();
@@ -740,6 +741,13 @@ private function seedApis(){
740741
'description' => 'Api Scopes CRUD operations',
741742
'resource_server' => $resource_server,
742743
'logo' => asset('/assets/img/apis/server.png')
744+
),
745+
array(
746+
'name' => 'groups',
747+
'active' => true,
748+
'description' => 'Groups Info API',
749+
'resource_server' => $resource_server,
750+
'logo' => asset('/assets/img/apis/server.png')
743751
),
744752
];
745753

@@ -1162,7 +1170,37 @@ private function seedApiScopes(){
11621170
EntityManager::flush();
11631171
}
11641172

1165-
private function seedTestApiEndpoints(){
1173+
private function seedGroupScopes(){
1174+
$api_repository = EntityManager::getRepository(Api::class);
1175+
$api = $api_repository->findOneBy(['name' => 'groups']);
1176+
if(is_null($api)) return;
1177+
1178+
$scope_payloads = [
1179+
array(
1180+
'name' => \App\libs\OAuth2\IGroupScopes::ReadAll,
1181+
'short_description' => 'Allows access to Groups info.',
1182+
'description' => 'Allows access to Groups info.',
1183+
'api' => $api,
1184+
'system' => false,
1185+
'active' => true,
1186+
),
1187+
array(
1188+
'name' => \App\libs\OAuth2\IGroupScopes::Write,
1189+
'short_description' => 'Allows access to write Groups info.',
1190+
'description' => 'Allows access to write Groups info.',
1191+
'api' => $api,
1192+
'system' => false,
1193+
'active' => true,
1194+
),
1195+
];
1196+
1197+
foreach($scope_payloads as $payload) {
1198+
EntityManager::persist(ApiScopeFactory::build($payload));
1199+
}
1200+
EntityManager::flush();
1201+
}
1202+
1203+
private function seedTestApiEndpoints(){
11661204

11671205
$current_realm = Config::get('app.url');
11681206

0 commit comments

Comments
 (0)