-
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 pull request #6 from MacPaw/develop
Release 1.1.0
- Loading branch information
Showing
24 changed files
with
663 additions
and
54 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 |
---|---|---|
|
@@ -14,11 +14,25 @@ jobs: | |
php: | ||
- '8.3' | ||
coverage: ['none'] | ||
doctrine-dbal-versions: | ||
- '^3.0' | ||
- '^4.0' | ||
symfony-versions: | ||
- '6.4.*' | ||
- '7.0.*' | ||
include: | ||
- description: 'Log Code Coverage' | ||
php: '8.3' | ||
symfony-versions: '^7.0' | ||
doctrine-dbal-versions: '^3.0' | ||
coverage: xdebug | ||
- description: 'Log Code Coverage' | ||
php: '8.3' | ||
symfony-versions: '^7.0' | ||
doctrine-dbal-versions: '^4.0' | ||
coverage: xdebug | ||
|
||
name: Test with PHP ${{ matrix.php }} Symfony ${{ matrix.symfony-versions }} ${{ matrix.description }} | ||
name: Test with PHP ${{ matrix.php }} Symfony ${{ matrix.symfony-versions }} Doctrine DBAL ${{ matrix.doctrine-dbal-versions }} ${{ matrix.description }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
@@ -49,13 +63,14 @@ jobs: | |
key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.symfony-versions }}-composer-${{ hashFiles('composer.json') }} | ||
restore-keys: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.symfony-versions }}-composer | ||
|
||
- name: Update Symfony version | ||
- name: Update package versions | ||
if: matrix.symfony-versions != '' | ||
run: | | ||
composer require symfony/config:${{ matrix.symfony-versions }} --no-update --no-scripts | ||
composer require symfony/dependency-injection:${{ matrix.symfony-versions }} --no-update --no-scripts | ||
composer require symfony/http-kernel:${{ matrix.symfony-versions }} --no-update --no-scripts | ||
composer require symfony/cache:${{ matrix.symfony-versions }} --no-update --no-scripts | ||
composer require doctrine/dbal:${{ matrix.doctrine-dbal-versions }} --no-update --no-scripts -W | ||
composer require --dev symfony/yaml:${{ matrix.symfony-versions }} --no-update --no-scripts | ||
composer require --dev symfony/phpunit-bridge:${{ matrix.symfony-versions }} --no-update --no-scripts | ||
composer require --dev symfony/framework-bundle:${{ matrix.symfony-versions }} --no-update --no-scripts | ||
|
@@ -64,7 +79,9 @@ jobs: | |
run: composer install | ||
|
||
- name: Run PHPUnit tests | ||
run: XDEBUG_MODE=coverage vendor/bin/phpunit | ||
run: | | ||
XDEBUG_MODE=off php tools/prepare-configs.php | ||
XDEBUG_MODE=coverage vendor/bin/phpunit | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/[email protected] | ||
|
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 |
---|---|---|
|
@@ -12,3 +12,4 @@ | |
/coverage | ||
/tests/App/var | ||
/var | ||
/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
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
parameters: | ||
checkGenericClassInNonGenericObjectType: false | ||
level: max | ||
paths: | ||
- src | ||
level: max | ||
paths: | ||
- src |
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,78 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Macpaw\DoctrineAwsIamRdsAuthBundle\Doctrine\Driver; | ||
|
||
use Doctrine\DBAL\Driver; | ||
use Doctrine\DBAL\Driver\API\ExceptionConverter; | ||
use Doctrine\DBAL\Driver\Connection as DriverConnection; | ||
use Doctrine\DBAL\Driver\Exception as DriverException; | ||
use Doctrine\DBAL\Exception\ConnectionException; | ||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Doctrine\DBAL\ServerVersionProvider; | ||
use Macpaw\DoctrineAwsIamRdsAuthBundle\Aws\Token\TokenProviderInterface; | ||
|
||
readonly class IamDecoratorDoctrine40 implements IamDecoratorInterface | ||
{ | ||
public function __construct( | ||
private Driver $subject, | ||
private TokenProviderInterface $tokenProvider, | ||
private string $region, | ||
) { | ||
} | ||
|
||
public function connect(array $params): DriverConnection | ||
{ | ||
// @phpstan-ignore-next-line | ||
$host = $params['host']; | ||
// @phpstan-ignore-next-line | ||
$user = $params['user']; | ||
// @phpstan-ignore-next-line | ||
$port = $params['port']; | ||
|
||
$params['password'] = $this->tokenProvider->getToken( | ||
"$host:$port", | ||
$this->region, | ||
$user, | ||
); | ||
|
||
try { | ||
return $this->subject->connect($params); | ||
} catch (\Throwable $e) { | ||
if ($this->isConnectionException($e)) { | ||
$params['password'] = $this->tokenProvider->getToken( | ||
"$host:$port", | ||
$this->region, | ||
$user, | ||
true | ||
); | ||
|
||
return $this->subject->connect($params); | ||
} | ||
|
||
throw $e; | ||
} | ||
} | ||
|
||
public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractPlatform | ||
{ | ||
return $this->subject->getDatabasePlatform($versionProvider); | ||
} | ||
|
||
public function getExceptionConverter(): ExceptionConverter | ||
{ | ||
return $this->subject->getExceptionConverter(); | ||
} | ||
|
||
private function isConnectionException(\Throwable $e): bool | ||
{ | ||
if ($e instanceof DriverException) { | ||
$driverException = $this->getExceptionConverter()->convert($e, null); | ||
|
||
return $driverException instanceof ConnectionException; | ||
} | ||
|
||
return 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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Macpaw\DoctrineAwsIamRdsAuthBundle\Doctrine\Driver; | ||
|
||
use Doctrine\DBAL\Driver; | ||
|
||
interface IamDecoratorInterface extends Driver | ||
{ | ||
} |
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,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Macpaw\DoctrineAwsIamRdsAuthBundle\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
abstract class AbstractDoctrineTestCase extends TestCase | ||
{ | ||
protected function isDoctrine40(): bool | ||
{ | ||
if (!function_exists('interface_exists')) { | ||
return class_exists('Doctrine\DBAL\ServerVersionProvider'); | ||
} | ||
|
||
return interface_exists('Doctrine\DBAL\ServerVersionProvider'); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.