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

ACP-3340: Create logic to send message to a tenant for changing config #8

Merged
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
run: composer stan

- name: Run Rector checks
run: composer rector-diff
run: composer rector-ci

- name: Run CodeStyle checks
run: composer cs-check
Expand Down
1 change: 1 addition & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace: SprykerTest

include:
- tests/SprykerTest/AsyncApi/AppKernel
- tests/SprykerTest/Glue/AppKernel
- tests/SprykerTest/Zed/AppKernel

Expand Down
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"spryker/glue-application-extension": "^1.0.0",
"spryker/kernel": "^3.30.0",
"spryker/log": "^3.0.0",
"spryker/message-broker": "^1.11.0",
"spryker/propel-encryption-behavior": "^0.1.1",
"spryker/secrets-manager": "^1.0.0",
"spryker/secrets-manager-extension": "^1.0.0",
Expand All @@ -19,14 +20,17 @@
},
"require-dev": {
"codeception/codeception": "^5.0",
"phpstan/phpstan": "1.10.66",
"codeception/module-asserts": "^3.0",
"phpstan/phpdoc-parser": "1.25.0",
"phpstan/phpstan": "1.10.66",
"rector/rector": "^0.19.0",
"spryker/code-sniffer": "*",
"spryker/container": "*",
"spryker/development": "^3.34.0",
"spryker/message-broker-aws": "^1.7.0",
"spryker/propel": "*",
"spryker/testify": "*"
"spryker/testify": "*",
"spryker/testify-async-api": "^0.1.4"
},
"autoload": {
"psr-4": {
Expand All @@ -52,8 +56,8 @@
"test": "codecept build && codecept run",
"test-cover": "codecept build && codecept run --coverage-xml",
"rector": "vendor/bin/rector process src/Spryker/ --config rector.php --ansi",
"rector-diff": "vendor/bin/rector process src/Spryker/ --config rector.php --ansi --dry-run",
"local-ci": "composer cs-fix && composer cs-check && composer stan && composer rector-diff && composer test"
"rector-ci": "vendor/bin/rector process src/Spryker/ --config rector.php --ansi --dry-run",
"local-ci": "composer cs-fix && composer cs-check && composer stan && composer rector-ci && composer test"
},
"extra": {
"branch-alias": {
Expand Down
21 changes: 21 additions & 0 deletions config/Shared/config_default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/**
* This configuration is used for TESTING only and will never be used in production!
*/

use Generated\Shared\Transfer\AppConfigUpdatedTransfer;
use Ramsey\Uuid\Uuid;
use Spryker\Shared\AppKernel\AppKernelConstants;
use Spryker\Shared\MessageBroker\MessageBrokerConstants;
use Spryker\Zed\MessageBrokerAws\MessageBrokerAwsConfig;

$config[MessageBrokerConstants::MESSAGE_TO_CHANNEL_MAP] = [
AppConfigUpdatedTransfer::class => 'app-events',
];

$config[MessageBrokerConstants::CHANNEL_TO_SENDER_TRANSPORT_MAP] = [
'app-events' => MessageBrokerAwsConfig::HTTP_CHANNEL_TRANSPORT,
];

$config[AppKernelConstants::APP_IDENTIFIER] = Uuid::uuid4()->toString();
23 changes: 0 additions & 23 deletions data/cache/propel/generated-conf/loadDatabase.php

This file was deleted.

19 changes: 13 additions & 6 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,28 @@
<config name="php_version" value="80000"/>

<file>src/</file>
<file>config/</file>
<file>tests/</file>

<exclude-pattern>src/Orm/*</exclude-pattern>
<exclude-pattern>src/Generated/*</exclude-pattern>
<exclude-pattern>*/tests/_support/_generated/*</exclude-pattern>
<exclude-pattern>*/tests/_helpers/*</exclude-pattern>
<exclude-pattern>*/tests/_output/*</exclude-pattern>

<rule ref="vendor/spryker/code-sniffer/Spryker/ruleset.xml"/>
<exclude-pattern>src/Orm/*</exclude-pattern>
<exclude-pattern>tests/_support/_generated/*</exclude-pattern>
<exclude-pattern>tests/_helpers/*</exclude-pattern>
<exclude-pattern>tests/_output/*</exclude-pattern>

<rule ref="vendor/spryker/code-sniffer/Spryker/ruleset.xml">
<exclude name="Spryker.Commenting.DocBlock"/>
<exclude name="Spryker.Commenting.DocBlockParam"/>
<exclude name="Spryker.Commenting.DocBlockReturnVoid"/>
<exclude name="Spryker.Commenting.DocBlockParamAllowDefaultValue"/>
</rule>

<rule ref="vendor/spryker/code-sniffer/SprykerStrict/ruleset.xml">
<exclude name="SprykerStrict.TypeHints.ParameterTypeHint"/>
<exclude name="SprykerStrict.TypeHints.PropertyTypeHint"/>
</rule>

<!-- Conflicting rule for constructor property promotion, this needs to be excluded otherwise Rector will refactor and CS Sniffer complains. -->
<rule ref="SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion">
<exclude name="SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion.DisallowedConstructorPropertyPromotion"/>
</rule>
Expand Down
61 changes: 41 additions & 20 deletions rector.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,61 @@
<?php

/**
* Copyright © 2021-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Set\ValueObject\SetList;
use Rector\Strict\Rector\Ternary\BooleanInTernaryOperatorRuleFixerRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src/Spryker',
__DIR__ . '/tests/SprykerTest',
]);

$rectorConfig->sets([
SetList::PHP_80
$rectorConfig->skip([
'*/_support/_generated/*',
]);

$rectorConfig->import(SetList::CODE_QUALITY);
$rectorConfig->import(SetList::CODING_STYLE);
$rectorConfig->import(SetList::DEAD_CODE);
$rectorConfig->import(SetList::STRICT_BOOLEANS);
$rectorConfig->import(SetList::NAMING);
$rectorConfig->import(SetList::PHP_82);
$rectorConfig->import(SetList::TYPE_DECLARATION);
$rectorConfig->import(SetList::EARLY_RETURN);
$rectorConfig->import(SetList::INSTANCEOF);

$rectorConfig->ruleWithConfiguration(ClassPropertyAssignToConstructorPromotionRector::class, [
ClassPropertyAssignToConstructorPromotionRector::INLINE_PUBLIC => true,
]);

$rectorConfig->skip([
RemoveUselessParamTagRector::class,
RemoveUnusedPromotedPropertyRector::class,
RemoveUselessReturnTagRector::class,
RemoveUselessVarTagRector::class,
MixedTypeRector::class,
// Ignore this rule on the AppRouteProviderPlugin as it breaks the code
CallableThisArrayToAnonymousFunctionRector::class => [
__DIR__ . '/src/Spryker/Glue/AppKernel/Plugin/RouteProvider/AppRouteProviderPlugin.php',
],
ClassPropertyAssignToConstructorPromotionRector::class => [
'**/*Bridge.php',
'**/*Plugin.php',
'**/*Facade.php',
'**/*Factory.php',
'**/*Config.php',
'**/*DependencyProvider.php',
'**/*Interface.php',
'**/*Controller.php',
__DIR__ . '/src/Spryker/Zed/AppKernel/Dependency/Client/AppKernelToSecretsManagerClientBridge.php',
__DIR__ . '/src/Spryker/Zed/AppKernel/Dependency/Facade/AppKernelToMessageBrokerFacadeBridge.php',
__DIR__ . '/src/Spryker/Zed/AppKernel/Dependency/Service/AppKernelToUtilEncodingServiceBridge.php',
__DIR__ . '/src/Spryker/Zed/AppKernel/Dependency/Service/AppKernelToUtilTextServiceBridge.php',
__DIR__ . '/src/Spryker/Glue/AppKernel/Dependency/Facade/AppKernelToAppKernelFacadeBridge.php',
],
AddParamTypeFromPropertyTypeRector::class => [
__DIR__ . '/src/Spryker/Zed/AppKernel/Dependency/Client/AppKernelToSecretsManagerClientBridge.php',
__DIR__ . '/src/Spryker/Zed/AppKernel/Dependency/Facade/AppKernelToMessageBrokerFacadeBridge.php',
__DIR__ . '/src/Spryker/Zed/AppKernel/Dependency/Service/AppKernelToUtilEncodingServiceBridge.php',
__DIR__ . '/src/Spryker/Zed/AppKernel/Dependency/Service/AppKernelToUtilTextServiceBridge.php',
__DIR__ . '/src/Spryker/Glue/AppKernel/Dependency/Facade/AppKernelToAppKernelFacadeBridge.php',
],
]);
};

50 changes: 18 additions & 32 deletions resources/api/asyncapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,41 @@ info:
title: 'PBC AsyncAPI definition.'
version: 0.1.0
channels:
app-commands:
app-events:
subscribe:
message:
oneOf:
- $ref: '#/components/messages/ConfigureApp'
- $ref: '#/components/messages/DeleteApp'
- $ref: '#/components/messages/AppConfigUpdated'
components:
messages:
ConfigureApp:
AppConfigUpdated:
x-spryker:
module: AppConfig
name: ConfigureApp
title: Configure App Command
summary: This message is sent when the PBC is connected to a client application or the PBC configuration has been updated. This message contains the PBC Glue API URL and credentials that can be used in the client application to submit requests.
headers:
$ref: '#/components/schemas/message-broker/components/schemas/headers'
name: AppConfigUpdated
title: Contains information about an updated App configuration.
summary: 'Contains information about an updated App configuration.'
payload:
$ref: '#/components/schemas/AppConfiguration'

DeleteApp:
x-spryker:
module: AppConfig
name: DeleteApp
title: Delete App Command
summary: This message is sent when the PBC disconnects from the client application.
$ref: '#/components/schemas/AppConfigUpdated'
headers:
$ref: '#/components/schemas/message-broker/components/schemas/headers'
payload:
$ref: '#/components/schemas/AppDisconnect'
schemas:
AppConfiguration:
type: object
properties:
apiUrl:
type: string
description: The URI of the PBC endpoint.
appIdentifier:
type: string
description: The app identifier to identify the PBC.
required:
- apiUrl
- appIdentifier
AppDisconnect:
AppConfigUpdated:
type: object
properties:
appIdentifier:
type: string
description: The app identifier to identify the PBC.
status:
type: boolean
description: The status of PBC (new, connected).
isActive:
type: boolean
config:
type: array
required:
- appIdentifier
- status
- isActive
- config
message-broker:
$ref: 'https://raw.githubusercontent.com/spryker/message-broker/1.6.0/resources/api/template.yml'
37 changes: 6 additions & 31 deletions src/Spryker/Glue/AppKernel/AppKernelDependencyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ class AppKernelDependencyProvider extends AbstractBundleDependencyProvider
*/
public const PLUGINS_REQUEST_DISCONNECT_VALIDATOR = 'PLUGINS_REQUEST_DISCONNECT_VALIDATOR';

/**
* @param \Spryker\Glue\Kernel\Backend\Container $glueBackendContainer
*
* @return \Spryker\Glue\Kernel\Backend\Container
*/
public function provideBackendDependencies(GlueBackendContainer $glueBackendContainer): GlueBackendContainer
{
$glueBackendContainer = parent::provideBackendDependencies($glueBackendContainer);
Expand All @@ -55,42 +50,27 @@ public function provideBackendDependencies(GlueBackendContainer $glueBackendCont
return $glueBackendContainer;
}

/**
* @param \Spryker\Glue\Kernel\Backend\Container $glueBackendContainer
*
* @return \Spryker\Glue\Kernel\Backend\Container
*/
protected function addUtilEncodingService(GlueBackendContainer $glueBackendContainer): GlueBackendContainer
{
$glueBackendContainer->set(static::SERVICE_UTIL_ENCODING, function (GlueBackendContainer $container) {
return $container->getLocator()->utilEncoding()->service();
$glueBackendContainer->set(static::SERVICE_UTIL_ENCODING, static function (GlueBackendContainer $glueBackendContainer) {
return $glueBackendContainer->getLocator()->utilEncoding()->service();
});

return $glueBackendContainer;
}

/**
* @param \Spryker\Glue\Kernel\Backend\Container $glueBackendContainer
*
* @return \Spryker\Glue\Kernel\Backend\Container
*/
protected function addAppKernelFacade(GlueBackendContainer $glueBackendContainer): GlueBackendContainer
{
$glueBackendContainer->set(static::FACADE_APP_KERNEL, function (GlueBackendContainer $container) {
return new AppKernelToAppKernelFacadeBridge($container->getLocator()->appKernel()->facade());
$glueBackendContainer->set(static::FACADE_APP_KERNEL, static function (GlueBackendContainer $glueBackendContainer): AppKernelToAppKernelFacadeBridge {
return new AppKernelToAppKernelFacadeBridge($glueBackendContainer->getLocator()->appKernel()->facade());
});

return $glueBackendContainer;
}

/**
* @param \Spryker\Glue\Kernel\Backend\Container $glueBackendContainer
*
* @return \Spryker\Glue\Kernel\Backend\Container
*/
protected function addRequestConfigureValidatorPlugins(GlueBackendContainer $glueBackendContainer): GlueBackendContainer
{
$glueBackendContainer->set(static::PLUGINS_REQUEST_CONFIGURE_VALIDATOR, function () {
$glueBackendContainer->set(static::PLUGINS_REQUEST_CONFIGURE_VALIDATOR, function (): array {
return array_merge($this->getDefaultRequestConfigureValidatorPlugins(), $this->getRequestConfigureValidatorPlugins());
});

Expand All @@ -116,14 +96,9 @@ protected function getRequestConfigureValidatorPlugins(): array
return [];
}

/**
* @param \Spryker\Glue\Kernel\Backend\Container $glueBackendContainer
*
* @return \Spryker\Glue\Kernel\Backend\Container
*/
protected function addRequestDisconnectValidatorPlugins(GlueBackendContainer $glueBackendContainer): GlueBackendContainer
{
$glueBackendContainer->set(static::PLUGINS_REQUEST_DISCONNECT_VALIDATOR, function () {
$glueBackendContainer->set(static::PLUGINS_REQUEST_DISCONNECT_VALIDATOR, function (): array {
return array_merge($this->getDefaultRequestDisconnectValidatorPlugins(), $this->getRequestDisconnectValidatorPlugins());
});

Expand Down
Loading
Loading