Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Resource/locale/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ api:
'scope.mcp:order:read.description': 'Read %shop_name% order data'
'scope.mcp:customer:read.description': 'Read %shop_name% customer data'
'scope.mcp:plugin:read.description': 'Read %shop_name% plugin information'
'scope.acp:checkout.description': 'Check out at %shop_name% (create, update and complete orders)'
'scope.acp:catalog.description': 'Read %shop_name% catalog data'
'scope.ucp:checkout.description': 'Check out at %shop_name% (create, update and complete orders)'
'scope.ucp:cart.description': 'Operate your %shop_name% cart (add, change and remove items)'
'scope.ucp:catalog.description': 'Read %shop_name% catalog data'
'scope.ucp:identity.description': 'Link your %shop_name% member ID (identify you as a member)'
redirect_uri: Redirect URI
redirect_uri_tooltip: You can enter multiple URIs separated by commas
grant_type: Grant Type
Expand Down
6 changes: 6 additions & 0 deletions Resource/locale/messages.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ api:
'scope.mcp:order:read.description': '%shop_name%の注文データの読み取り'
'scope.mcp:customer:read.description': '%shop_name%の顧客会員データの読み取り'
'scope.mcp:plugin:read.description': '%shop_name%のプラグイン情報の読み取り'
'scope.acp:checkout.description': '%shop_name%でのチェックアウト(注文の作成・更新・確定)'
'scope.acp:catalog.description': '%shop_name%のカタログデータの読み取り'
'scope.ucp:checkout.description': '%shop_name%でのチェックアウト(注文の作成・更新・確定)'
'scope.ucp:cart.description': '%shop_name%のカートの操作(商品の追加・変更・削除)'
'scope.ucp:catalog.description': '%shop_name%のカタログデータの読み取り'
'scope.ucp:identity.description': '%shop_name%の会員IDとの連携(会員としての本人確認)'
redirect_uri: リダイレクトURI
redirect_uri_tooltip: カンマ区切りで複数のURIを入力可能
grant_type: グラントタイプ
Expand Down
63 changes: 63 additions & 0 deletions Tests/Resource/ScopeTranslationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

declare(strict_types=1);

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Plugin\Api44\Tests\Resource;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Yaml;

/**
* 権限移譲確認画面 (`admin/OAuth/authorization.twig`) は要求された scope を
* `api.admin.oauth.scope.<scope>.description` で表示する。 翻訳が無い scope は
* 翻訳キーがそのまま画面に出るため、 `scopes.available` との同期をテストで担保する。
*/
final class ScopeTranslationTest extends TestCase
{
#[DataProvider('localeProvider')]
public function testAllAvailableScopesHaveDescription(string $locale): void
{
$messages = Yaml::parseFile(__DIR__.'/../../Resource/locale/messages.'.$locale.'.yaml');
$oauth = $messages['api']['admin']['oauth'];

foreach (self::availableScopes() as $scope) {
$key = 'scope.'.$scope.'.description';
self::assertArrayHasKey(
$key,
$oauth,
sprintf('scope `%s` の説明が messages.%s.yaml に定義されていない', $scope, $locale)
);
self::assertNotSame('', trim((string) $oauth[$key]));
}
}

/**
* @return string[][]
*/
public static function localeProvider(): array
{
return [['ja'], ['en']];
}

/**
* @return list<string>
*/
private static function availableScopes(): array
{
$config = Yaml::parseFile(__DIR__.'/../../Resource/config/services.yaml');

return $config['league_oauth2_server']['scopes']['available'];
}
}