Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.3対応 #164

Merged
merged 18 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
19 changes: 13 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ on:
jobs:
run-on-linux:
name: Run on Linux
runs-on: ${{ matrix.operating-system }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-18.04 ]
php: [ '7.4', '8.0', '8.1' ]
eccube_version: [ '4.2', '4.3-symfony6' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3']
db: [ 'mysql', 'mysql8', 'pgsql' ]
eccube_version: [ '4.2' ]
plugin_code: [ 'Api42' ]
include:
- db: mysql
Expand All @@ -39,6 +38,15 @@ jobs:
database_url: postgres://postgres:[email protected]:5432/eccube_db
database_server_version: 14
database_charset: utf8
exclude:
- eccube_version: 4.2
php: 8.2
- eccube_version: 4.2
php: 8.3
- eccube_version: 4.3-symfony6
php: 7.4
- eccube_version: 4.3-symfony6
php: 8.0
services:
mysql:
image: mysql:5.7
Expand Down Expand Up @@ -72,7 +80,6 @@ jobs:
- 1080:1080
- 1025:1025
steps:
- run: sudo apt-get purge -y hhvm
- name: Checkout
uses: actions/checkout@v2

Expand Down Expand Up @@ -167,7 +174,7 @@ jobs:
working-directory: 'ec-cube'
run: |
bin/console cache:clear --no-warmup
bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests
./vendor/bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests


- name: Disable Plugin
Expand Down
3 changes: 2 additions & 1 deletion Bundle/ApiBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Plugin\Api42\DependencyInjection\ApiExtension;
use Plugin\Api42\DependencyInjection\Compiler\ApiCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class ApiBundle extends Bundle
Expand All @@ -27,7 +28,7 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new ApiCompilerPass());
}

public function getContainerExtension()
public function getContainerExtension(): ?ExtensionInterface
{
return new ApiExtension();
}
Expand Down
6 changes: 3 additions & 3 deletions Controller/Admin/OAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
use League\Bundle\OAuth2ServerBundle\Manager\RefreshTokenManagerInterface;
use League\Bundle\OAuth2ServerBundle\Model\AuthorizationCode;
use League\Bundle\OAuth2ServerBundle\Model\Client;
use League\Bundle\OAuth2ServerBundle\Model\Grant;
use League\Bundle\OAuth2ServerBundle\Model\RedirectUri;
use League\Bundle\OAuth2ServerBundle\Model\Scope;
use League\Bundle\OAuth2ServerBundle\ValueObject\Grant;
use League\Bundle\OAuth2ServerBundle\ValueObject\RedirectUri;
use League\Bundle\OAuth2ServerBundle\ValueObject\Scope;
use League\Bundle\OAuth2ServerBundle\OAuth2Grants;

class OAuthController extends AbstractController
Expand Down
2 changes: 1 addition & 1 deletion EventListener/AuthorizationRequestResolveListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function onAuthorizationRequestResolve(AuthorizationRequestResolveEvent $
$event->resolveAuthorization(AuthorizationRequestResolveEvent::AUTHORIZATION_DENIED);
}
} else {
$event->setResponse(Response::create($content));
$event->setResponse(new Response($content));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Eccube\Entity\Master\Authority;
use Eccube\Plugin\AbstractPluginManager;
use Eccube\Repository\AuthorityRoleRepository;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Psr\Container\ContainerInterface;

class PluginManager extends AbstractPluginManager
{
Expand Down
2 changes: 1 addition & 1 deletion Resource/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ services:
Plugin\Api42\EventListener\UserResolveListener:
arguments:
- '@Eccube\Security\Core\User\MemberProvider'
- '@Plugin\Api42\Security\Core\Encoder\UserPasswordEncoder'
- '@Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface'
tags:
- { name: kernel.event_listener, event: league.oauth2_server.event.user_resolve, method: onUserResolve }

Expand Down
3 changes: 3 additions & 0 deletions Resource/config/services_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
services:
_defaults:
public: true
2 changes: 1 addition & 1 deletion Security/Core/Encoder/UserPasswordEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\User\UserInterface;

class UserPasswordEncoder implements UserPasswordEncoderInterface
class UserPasswordEncoder
{
/**
* @var PasswordEncoder
Expand Down
6 changes: 3 additions & 3 deletions Service/WebHookService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ class WebHookService implements EventSubscriberInterface
/**
* @var RouterInterface
*/
private $router;
private RouterInterface $router;

/**
* @var WebHookRepository
*/
private $webHookRepository;
private WebHookRepository $webHookRepository;

/**
* @var WebHookEvents
*/
private $webHookEvents;
private WebHookEvents $webHookEvents;

/**
* WebHookService constructor.
Expand Down
4 changes: 2 additions & 2 deletions Tests/GraphQL/Mutation/UpdateProductStockMutationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class UpdateProductStockMutationTest extends EccubeTestCase
public function setUp(): void
{
parent::setUp();
$types = self::$container->get(Types::class);
$this->productClassRepository = self::$container->get(ProductClassRepository::class);
$types = self::getContainer()->get(Types::class);
$this->productClassRepository = self::getContainer()->get(ProductClassRepository::class);
$this->updateProductStockMutation = new UpdateProductStockMutation($types, $this->productClassRepository, $this->entityManager);

// テスト用の商品を作成
Expand Down
10 changes: 5 additions & 5 deletions Tests/GraphQL/Mutation/UpdateShippedMutationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public function setUp(): void
{
parent::setUp();

$mailService = self::$container->get(MailService::class);
$orderStateMachine = self::$container->get(OrderStateMachine::class);
$orderStatusRepository = self::$container->get(OrderStatusRepository::class);
$types = self::$container->get(Types::class);
$shippingRepository = self::$container->get(ShippingRepository::class);
$mailService = self::getContainer()->get(MailService::class);
$orderStateMachine = self::getContainer()->get(OrderStateMachine::class);
$orderStatusRepository = self::getContainer()->get(OrderStatusRepository::class);
$types = self::getContainer()->get(Types::class);
$shippingRepository = self::getContainer()->get(ShippingRepository::class);

$this->updateShippedMutation = new UpdateShippedMutation(
$this->eccubeConfig,
Expand Down
2 changes: 1 addition & 1 deletion Tests/GraphQL/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ private function executeQuery($query, $variables = null, $readonly = false)
{
$op = OperationParams::create(['query' => $query, 'variables' => $variables], $readonly);
$helper = new Helper();
$config = ServerConfig::create()->setSchema(self::$container->get(Schema::class));
$config = ServerConfig::create()->setSchema(self::getContainer()->get(Schema::class));
$result = $helper->executeOperation($config, $op);
self::assertInstanceOf(ExecutionResult::class, $result);

Expand Down
2 changes: 1 addition & 1 deletion Tests/GraphQL/TypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TypesTest extends EccubeTestCase
public function setUp(): void
{
parent::setUp();
$this->types = self::$container->get(Types::class);
$this->types = self::getContainer()->get(Types::class);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Tests/Service/WebHookServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
class WebHookServiceTest extends EccubeTestCase
{
/** @var WebHookService */
private $service;
private ?WebHookService $service;

public function setUp(): void
{
parent::setUp();

$this->service = self::$container->get(WebHookService::class);
$this->service = self::getContainer()->get(WebHookService::class);
}

public function testCreateRequest_withSecret()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Web/Admin/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testRoutingAdminLoginCheck()
]
);

$this->assertNotNull(self::$container->get('security.token_storage')->getToken(), 'ログインしているかどうか');
$this->assertNotNull(self::getContainer()->get('security.token_storage')->getToken(), 'ログインしているかどうか');
}

public function testRoutingAdminLogin_ログインしていない場合はログイン画面を表示()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Web/Admin/OAuthControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function setUp(): void
{
parent::setUp();

$this->clientManager = self::$container->get(ClientManager::class);
$this->clientManager = self::getContainer()->get(ClientManager::class);
}

public function testRoutingAdminSettingSystemOAuth2Client()
Expand Down
26 changes: 16 additions & 10 deletions Tests/Web/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

namespace Plugin\Api42\Tests\Web;

use Eccube\Common\EccubeConfig;
use Eccube\Tests\Web\AbstractWebTestCase;
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\CryptKey;
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
use League\Bundle\OAuth2ServerBundle\Entity\AccessToken;
use League\Bundle\OAuth2ServerBundle\Entity\Scope;
use League\Bundle\OAuth2ServerBundle\Manager\Doctrine\ClientManager;
Expand All @@ -26,24 +28,28 @@
class ApiControllerTest extends AbstractWebTestCase
{
/** @var ClientManager */
private $clientManager;
private ?ClientManager $clientManager;

/** @var ClientRepositoryInterface */
private $clientRepository;
private ?ClientRepositoryInterface $clientRepository;

/** @var AccessTokenRepositoryInterface */
private $accessTokenRepository;
private ?AccessTokenRepositoryInterface $accessTokenRepository;

/** @var ScopeRepositoryInterface */
private ?ScopeRepositoryInterface $scopeRepositoryInterface;

/** @var AuthorizationServer */
private $authorizationServer;
private ?AuthorizationServer $authorizationServer;

public function setUp(): void
{
parent::setUp();
$this->clientManager = self::$container->get(ClientManager::class);
$this->clientRepository = self::$container->get(ClientRepositoryInterface::class);
$this->accessTokenRepository = self::$container->get(AccessTokenRepositoryInterface::class);
$this->authorizationServer = self::$container->get(AuthorizationServer::class);
$this->clientManager = self::getContainer()->get(ClientManager::class);
$this->clientRepository = self::getContainer()->get(ClientRepositoryInterface::class);
$this->accessTokenRepository = self::getContainer()->get(AccessTokenRepositoryInterface::class);
$this->authorizationServer = self::getContainer()->get(AuthorizationServer::class);
$this->scopeRepositoryInterface = self::getContainer()->get(ScopeRepositoryInterface::class);
}

/**
Expand Down Expand Up @@ -89,7 +95,7 @@ private function newAccessToken($scopes)

$client = new Client('', $identifier, $secret);
$client->setScopes(...array_map(function ($s) {
return new \League\Bundle\OAuth2ServerBundle\Model\Scope($s);
return new \League\Bundle\OAuth2ServerBundle\ValueObject\Scope($s);
}, $scopes));
$this->clientManager->save($client);
$clientEntity = $this->clientRepository->getClientEntity($identifier, 'authorization_code', $secret);
Expand All @@ -99,7 +105,7 @@ private function newAccessToken($scopes)
$accessTokenEntity->setClient($clientEntity);
$accessTokenEntity->setExpiryDateTime(new \DateTimeImmutable('+1 days', new \DateTimeZone('Asia/Tokyo')));
$accessTokenEntity->setUserIdentifier('admin');
$accessTokenEntity->setPrivateKey(new CryptKey(self::$container->getParameter('kernel.project_dir').'/app/PluginData/Api42/oauth/private.key'));
$accessTokenEntity->setPrivateKey(new CryptKey(self::getContainer()->get(EccubeConfig::class)->get('kernel.project_dir').'/app/PluginData/Api42/oauth/private.key'));

array_walk($scopes, function ($s) use ($accessTokenEntity) {
$scope = new Scope();
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "ec-cube/api42",
"version": "4.2.3",
"name": "ec-cube\/api42",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\は不要です。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chihiro-adachi
修正致しました。

"version": "4.3.0",
"description": "Web API",
"type": "eccube-plugin",
"require": {
"ec-cube/plugin-installer": "^2.0",
"league/oauth2-server-bundle": "^0.3",
"league/oauth2-server-bundle": "^0.5",
"nyholm/psr7": "^1.2",
"php-http/message-factory": "*",
"webonyx/graphql-php": "^14.0"
},
"extra": {
Expand Down
Loading