|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Laudis Neo4j package. |
| 5 | + * |
| 6 | + * (c) Laudis technologies <http://laudis.tech> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Laudis\Neo4j\Tests\Integration; |
| 13 | + |
| 14 | +use function array_key_exists; |
| 15 | +use function is_string; |
| 16 | +use Laudis\Neo4j\Authentication\Authenticate; |
| 17 | +use Laudis\Neo4j\ClientBuilder; |
| 18 | +use Laudis\Neo4j\Http\HttpDriver; |
| 19 | +use Monolog\Test\TestCase; |
| 20 | + |
| 21 | +/** |
| 22 | + * @psalm-suppress MissingConstructor |
| 23 | + */ |
| 24 | +final class OIDCTest extends TestCase |
| 25 | +{ |
| 26 | + public function testConnect(): void |
| 27 | + { |
| 28 | + $this->expectNotToPerformAssertions(); |
| 29 | + if (!array_key_exists('ACCESS_TOKEN_BEARER', $_ENV) || !is_string($_ENV['ACCESS_TOKEN_BEARER'])) { |
| 30 | + $this->markTestSkipped('No OIDC token provided'); |
| 31 | + } |
| 32 | + |
| 33 | + /** @var mixed */ |
| 34 | + $connections = $_ENV['NEO4J_CONNECTIONS'] ?? ''; |
| 35 | + $connections = is_string($connections) ? $connections : ''; |
| 36 | + foreach (explode(',', $connections) as $connection) { |
| 37 | + $driver = ClientBuilder::create() |
| 38 | + ->withDriver('default', $connection, Authenticate::oidc($_ENV['ACCESS_TOKEN_BEARER'])) |
| 39 | + ->build() |
| 40 | + ->getDriver('default'); |
| 41 | + |
| 42 | + if ($driver instanceof HttpDriver) { |
| 43 | + continue; |
| 44 | + } |
| 45 | + |
| 46 | + $driver->createSession()->run('RETURN 1'); |
| 47 | + } |
| 48 | + } |
| 49 | +} |
0 commit comments