-
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.
add bundle setup add configurations add todo update travis ci fix version constraint bug skip test fix test test test2 test 3 test4 upsi t remove phpunit.xml from gitignore remove lts update version add codecoverage badge add coverage config add coveralls code coverage config fix version add coveralls add coveralls update coveralls.yml remove coverage clover params change coveralls package add untitests update readme and tests change readme headline
- Loading branch information
0 parents
commit 92e58bd
Showing
23 changed files
with
808 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
codecov: | ||
require_ci_to_pass: true | ||
|
||
coverage: | ||
precision: 2 | ||
round: down | ||
range: "70...100" | ||
|
||
parsers: | ||
gcov: | ||
branch_detection: | ||
conditional: yes | ||
loop: yes | ||
method: no | ||
macro: no | ||
|
||
comment: | ||
layout: "reach,diff,flags,tree" | ||
behavior: default | ||
require_changes: false |
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,2 @@ | ||
service_name: travis-ci | ||
coverage_clover: build/logs/clover.xml |
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,6 @@ | ||
/vendor/ | ||
composer.lock | ||
.DS_Store | ||
.idea | ||
/var/cache/ | ||
/build/ |
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,61 @@ | ||
language: php | ||
dist: xenial | ||
os: linux | ||
cache: | ||
directories: | ||
- $HOME/.composer/cache/files | ||
- .phpunit | ||
|
||
env: | ||
global: | ||
- deps=no | ||
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit" | ||
|
||
php: | ||
- 7.2 | ||
- 7.3 | ||
- 7.4 | ||
|
||
jobs: | ||
fast_finish: true | ||
include: | ||
# Minimum supported dependencies with the latest and oldest PHP version | ||
- php: 7.2 | ||
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="max[self]=0" | ||
|
||
# Test the latest stable release | ||
- php: 7.2 | ||
- php: 7.3 | ||
- php: 7.4 | ||
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text" | ||
|
||
# Latest commit to master | ||
- php: 7.2 | ||
env: STABILITY="dev" | ||
|
||
allow_failures: | ||
# Dev-master is allowed to fail. | ||
- env: STABILITY="dev" | ||
|
||
before_install: | ||
- export SYMFONY_PHPUNIT_DIR="$(pwd)/.phpunit" | ||
- composer require php-coveralls/php-coveralls --dev | ||
|
||
install: | ||
- travis_retry composer self-update | ||
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction | ||
- php vendor/bin/simple-phpunit install | ||
|
||
before_script: | ||
- composer config discard-changes true | ||
|
||
script: | ||
- mkdir -p build/logs | ||
- composer validate --strict --no-check-lock | ||
# simple-phpunit is the PHPUnit wrapper provided by the PHPUnit Bridge component and | ||
# it helps with testing legacy code and deprecations (composer require symfony/phpunit-bridge) | ||
- ./vendor/bin/simple-phpunit tests -v | ||
|
||
after_success: | ||
- travis_retry php vendor/bin/php-coveralls | ||
- bash <(curl -s https://codecov.io/bash) |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Marco Faul | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,48 @@ | ||
# Shopware Six (6) Developer Tool | ||
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/marcofaul/sw-dev-tool-six-bundle) | ||
[![Build Status](https://travis-ci.com/MarcoFaul/sw-dev-tool-six-bundle.svg?branch=master)](https://travis-ci.com/MarcoFaul/sw-dev-tool-six-bundle) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
[![Coverage Status](https://coveralls.io/repos/github/MarcoFaul/sw-dev-tool-six-bundle/badge.svg?branch=master)](https://coveralls.io/github/MarcoFaul/sw-dev-tool-six-bundle?branch=master) | ||
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) | ||
|
||
## Features | ||
- Set administration login token ttl (time to live) | ||
- Disable dal entity caching | ||
- Set default development parameters | ||
|
||
## Installation | ||
|
||
composer require marcofaul/sw-dev-tool-six-bundle --dev | ||
|
||
In your `AppKernel`: | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function registerBundles() | ||
{ | ||
$bundles = [ | ||
// ... | ||
new \JMS\SerializerBundle\JMSSerializerBundle(), | ||
new \MarcoFaul\SwDevToolSixBundle\SwDevToolSixBundle(), | ||
]; | ||
// ... | ||
return $bundles; | ||
} | ||
|
||
## Configuration | ||
Simply configure your shop connection over the global `config.yml`: | ||
|
||
sw_dev_tool_six: | ||
access_token_ttl: P1W | ||
enable_dal_caching: false | ||
shopware: | ||
skip_first_run_wizard_client: true | ||
enable_auto_update: false | ||
enable_api_auth_require: false | ||
enable_storefront_csrf: false | ||
|
||
## Tests | ||
|
||
php vendor/bin/simple-phpunit |
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,29 @@ | ||
{ | ||
"name": "marcofaul/sw-dev-tool-six-bundle", | ||
"description": "Helper tool for developing with showpare six", | ||
"type": "symfony-bundle", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "marcofaul", | ||
"email": "marcofaul@protonmail.com" | ||
} | ||
], | ||
"require": { | ||
"php": "~7.2", | ||
"shopware/platform": "^6.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"MarcoFaul\\SwDevToolSixBundle\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"MarcoFaul\\SwDevToolSixBundle\\Tests\\": "tests/" | ||
} | ||
}, | ||
"require-dev": { | ||
"symfony/phpunit-bridge": "^5.0" | ||
} | ||
} |
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,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.0/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
beStrictAboutCoversAnnotation="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTestsThatDoNotTestAnything="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
verbose="true" | ||
cacheResult="false" | ||
cacheTokens="false" | ||
executionOrder="random"> | ||
<php> | ||
<ini name="error_reporting" value="-1" /> | ||
<server name="KERNEL_CLASS" value="Shopware\Development\Kernel"/> | ||
<env name="APP_ENV" value="test" /> | ||
<env name="APP_DEBUG" value="1" /> | ||
<env name="APP_SECRET" value="s$cretf0rt3st" /> | ||
<env name="SHELL_VERBOSITY" value="-1" /> | ||
</php> | ||
|
||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>./src</directory> | ||
<exclude> | ||
<directory>./docs</directory> | ||
<directory>./vendor</directory> | ||
<directory>./tests</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
|
||
<logging> | ||
<log type="coverage-php" target="build/cov/coverage.cov"/> | ||
<log type="coverage-clover" target="build/logs/clover.xml"/> | ||
</logging> | ||
</phpunit> |
71 changes: 71 additions & 0 deletions
71
src/Api/EventListener/Authentication/ApiAuthenticationListenerExtension.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,71 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace MarcoFaul\SwDevToolSixBundle\Api\EventListener\Authentication; | ||
|
||
|
||
use League\OAuth2\Server\AuthorizationServer; | ||
use League\OAuth2\Server\Grant\ClientCredentialsGrant; | ||
use League\OAuth2\Server\Grant\PasswordGrant; | ||
use League\OAuth2\Server\Grant\RefreshTokenGrant; | ||
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface; | ||
use League\OAuth2\Server\Repositories\UserRepositoryInterface; | ||
use League\OAuth2\Server\ResourceServer; | ||
use Shopware\Core\Framework\Api\EventListener\Authentication\ApiAuthenticationListener; | ||
use Shopware\Core\Framework\Routing\RouteScopeRegistry; | ||
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; | ||
use Symfony\Component\HttpKernel\Event\RequestEvent; | ||
|
||
class ApiAuthenticationListenerExtension extends ApiAuthenticationListener | ||
{ | ||
/** @var AuthorizationServer */ | ||
private $authorizationServer; | ||
|
||
/** @var UserRepositoryInterface */ | ||
private $userRepository; | ||
|
||
/** @var RefreshTokenRepositoryInterface */ | ||
private $refreshTokenRepository; | ||
|
||
/** @var string */ | ||
private $accessTokenInterval; | ||
|
||
public function __construct( | ||
ResourceServer $resourceServer, | ||
AuthorizationServer $authorizationServer, | ||
UserRepositoryInterface $userRepository, | ||
RefreshTokenRepositoryInterface $refreshTokenRepository, | ||
PsrHttpFactory $psrHttpFactory, | ||
RouteScopeRegistry $routeScopeRegistry, | ||
string $accessTokenInterval | ||
) | ||
{ | ||
parent::__construct($resourceServer, $authorizationServer, $userRepository, $refreshTokenRepository, $psrHttpFactory, $routeScopeRegistry); | ||
|
||
$this->authorizationServer = $authorizationServer; | ||
$this->userRepository = $userRepository; | ||
$this->refreshTokenRepository = $refreshTokenRepository; | ||
$this->accessTokenInterval = $accessTokenInterval; | ||
|
||
} | ||
|
||
public function setupOAuth(RequestEvent $event): void | ||
{ | ||
if (!$event->isMasterRequest()) { | ||
return; | ||
} | ||
|
||
$tenMinuteInterval = new \DateInterval($this->accessTokenInterval); | ||
$oneWeekInterval = new \DateInterval($this->accessTokenInterval); | ||
|
||
$passwordGrant = new PasswordGrant($this->userRepository, $this->refreshTokenRepository); | ||
$passwordGrant->setRefreshTokenTTL($oneWeekInterval); | ||
|
||
$refreshTokenGrant = new RefreshTokenGrant($this->refreshTokenRepository); | ||
$refreshTokenGrant->setRefreshTokenTTL($oneWeekInterval); | ||
|
||
$this->authorizationServer->enableGrantType($passwordGrant, $tenMinuteInterval); | ||
$this->authorizationServer->enableGrantType($refreshTokenGrant, $tenMinuteInterval); | ||
$this->authorizationServer->enableGrantType(new ClientCredentialsGrant(), $tenMinuteInterval); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/DependencyInjection/Compiler/OverrideConfigurationPass.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,42 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MarcoFaul\SwDevToolSixBundle\DependencyInjection\Compiler; | ||
|
||
use MarcoFaul\SwDevToolSixBundle\Api\EventListener\Authentication\ApiAuthenticationListenerExtension; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Dbal\EntitySearcher; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class OverrideConfigurationPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$container->setParameter('shopware.store.frw', $container->getParameter('sw_dev_tool_six.shopware.skip_first_run_wizard_client')); | ||
$container->setParameter('shopware.auto_update.disableAutoUpdate', !$container->getParameter('sw_dev_tool_six.shopware.enable_auto_update')); | ||
$container->setParameter('shopware.api_browser.auth_required', $container->getParameter('sw_dev_tool_six.shopware.enable_api_auth_require')); | ||
$container->setParameter('storefront.csrf.enabled', $container->getParameter('sw_dev_tool_six.shopware.enable_storefront_csrf')); | ||
|
||
if ($container->getParameter('sw_dev_tool_six.enable_dal_caching') === false) { | ||
$container->getDefinition('Shopware\Core\Framework\DataAbstractionLayer\Cache\CachedEntitySearcher') | ||
->setClass(EntitySearcher::class) | ||
->setArgument(0, $container->getDefinition('Doctrine\DBAL\Connection')) | ||
->setArgument(1, $container->getDefinition('Shopware\Core\Framework\DataAbstractionLayer\Search\Parser\SqlQueryParser')) | ||
->setArgument(2, $container->getDefinition('Shopware\Core\Framework\DataAbstractionLayer\Dbal\EntityDefinitionQueryHelper')) | ||
->setArgument(3, $container->getDefinition('Shopware\Core\Framework\DataAbstractionLayer\Search\Term\SearchTermInterpreter')) | ||
->setArgument(4, $container->getDefinition('Shopware\Core\Framework\DataAbstractionLayer\Search\Term\EntityScoreQueryBuilder')); | ||
} | ||
|
||
|
||
$container->getDefinition('Shopware\Core\Framework\Api\EventListener\Authentication\ApiAuthenticationListener') | ||
->setClass(ApiAuthenticationListenerExtension::class) | ||
->addTag('kernel.event_subscriber') | ||
->setArgument(0, $container->getDefinition('shopware.api.resource_server')) | ||
->setArgument(1, $container->getDefinition('shopware.api.authorization_server')) | ||
->setArgument(2, $container->getDefinition('Shopware\Core\Framework\Api\OAuth\UserRepository')) | ||
->setArgument(3, $container->getDefinition('Shopware\Core\Framework\Api\OAuth\RefreshTokenRepository')) | ||
->setArgument(4, $container->getDefinition('Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory')) | ||
->setArgument(5, $container->getDefinition('Shopware\Core\Framework\Routing\RouteScopeRegistry')) | ||
->setArgument(6, $container->getParameter('sw_dev_tool_six.access_token_ttl')); | ||
|
||
} | ||
} |
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,32 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace MarcoFaul\SwDevToolSixBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
class Configuration implements ConfigurationInterface | ||
{ | ||
public function getConfigTreeBuilder(): TreeBuilder | ||
{ | ||
$treeBuilder = new TreeBuilder('sw_dev_tool_six'); | ||
$rootNode = $treeBuilder->getRootNode(); | ||
|
||
$rootNode | ||
->children() | ||
->scalarNode('access_token_ttl')->defaultValue('P1W')->info('Password and token ttl value. Default is PT10M')->end() | ||
->booleanNode('enable_dal_caching')->defaultFalse()->info('Disable the DAL entity searcher cache')->end() | ||
->arrayNode('shopware') | ||
->children() | ||
->scalarNode('skip_first_run_wizard_client')->defaultTrue()->info('Disables the wizard')->end() | ||
->scalarNode('enable_auto_update')->defaultFalse()->info('Disables the administration update popup')->end() | ||
->scalarNode('enable_api_auth_require')->defaultFalse()->info('Disable api auth requirement')->end() | ||
->scalarNode('enable_storefront_csrf')->defaultFalse()->info('Disables the Cross-Site-Request-Forgery security on the storefront')->end() | ||
->end() | ||
->end() | ||
|
||
->end(); | ||
return $treeBuilder; | ||
} | ||
} |
Oops, something went wrong.