-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'b-7.2.x-prepare-module-block-list-OXDEV-8489-revised2' …
…into b-7.2.x
- Loading branch information
Showing
32 changed files
with
436 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
modules: | ||
- oe_graphql_base | ||
- oe_graphql_configuration_access |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Exception; | ||
|
||
use OxidEsales\GraphQL\Base\Exception\NotFound; | ||
|
||
final class ModuleActivationBlockedException extends NotFound | ||
{ | ||
private const EXCEPTION_MESSAGE = 'Module "%s" is in the blocklist and cannot be activated.'; | ||
|
||
public function __construct(string $moduleId) | ||
{ | ||
parent::__construct(sprintf(self::EXCEPTION_MESSAGE, $moduleId)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Module/Exception/ModuleDeactivationBlockedException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Exception; | ||
|
||
use OxidEsales\GraphQL\Base\Exception\NotFound; | ||
|
||
final class ModuleDeactivationBlockedException extends NotFound | ||
{ | ||
private const EXCEPTION_MESSAGE = 'Module "%s" is in the blocklist and cannot be deactivated.'; | ||
|
||
public function __construct(string $moduleId) | ||
{ | ||
parent::__construct(sprintf(self::EXCEPTION_MESSAGE, $moduleId)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Service; | ||
|
||
use OxidEsales\EshopCommunity\Internal\Framework\DIContainer\Dao\ProjectYamlDaoInterface; | ||
|
||
class ModuleBlocklistService implements ModuleBlocklistServiceInterface | ||
{ | ||
public function __construct( | ||
private readonly string $moduleBlocklistPath, | ||
private readonly ProjectYamlDaoInterface $projectYamlDao | ||
) { | ||
} | ||
|
||
public function isModuleBlocked(string $moduleId): bool | ||
{ | ||
$resolvedPath = dirname(__FILE__) . '/../' . $this->moduleBlocklistPath; | ||
$configWrapper = $this->projectYamlDao->loadDIConfigFile($resolvedPath); | ||
$blocklistData = $configWrapper->getConfigAsArray(); | ||
|
||
return in_array($moduleId, $blocklistData['modules'], true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Service; | ||
|
||
interface ModuleBlocklistServiceInterface | ||
{ | ||
public function isModuleBlocked(string $moduleId): bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Codeception\Acceptance\Module; | ||
|
||
use Codeception\Attribute\DataProvider; | ||
use OxidEsales\GraphQL\ConfigurationAccess\Tests\Codeception\AcceptanceTester; | ||
|
||
/** | ||
* @group module_switch | ||
* @group theme_switch | ||
* @group setting_access | ||
* @group oe_graphql_configuration_access | ||
*/ | ||
final class ModuleSwitchCest extends ModuleSettingBaseCest | ||
{ | ||
#[DataProvider('moduleSwitchDataProvider')] | ||
public function testModuleSwitchAuthorized(AcceptanceTester $I, \Codeception\Example $example): void | ||
{ | ||
$I->login($this->getAdminUsername(), $this->getAdminPassword()); | ||
|
||
$result = $this->runModuleMutation( | ||
I: $I, | ||
queryName: $example['queryName'], | ||
field: $example['field'] | ||
); | ||
|
||
$I->assertArrayNotHasKey('errors', $result); | ||
$response = $result['data'][$example['queryName']]; | ||
$I->assertTrue($response); | ||
} | ||
|
||
private function runModuleMutation( | ||
AcceptanceTester $I, | ||
string $queryName, | ||
string $field | ||
): array { | ||
$I->login($this->getAdminUsername(), $this->getAdminPassword()); | ||
$I->sendGQLQuery( | ||
'mutation { | ||
' . $queryName . '(' . $field . ': "' . self::TEST_MODULE_ID . '") | ||
}' | ||
); | ||
|
||
$I->seeResponseIsJson(); | ||
return $I->grabJsonResponseAsArray(); | ||
} | ||
|
||
protected function moduleSwitchDataProvider(): \Generator | ||
{ | ||
yield ['queryName' => 'activateModule', 'field' => 'moduleId']; | ||
yield ['queryName' => 'deactivateModule', 'field' => 'moduleId']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.