Skip to content

Commit 1ffc157

Browse files
committed
created test for oidc
1 parent 86b976a commit 1ffc157

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/Integration/OIDCTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 Laudis\Neo4j\Authentication\Authenticate;
16+
use Laudis\Neo4j\ClientBuilder;
17+
use Laudis\Neo4j\Http\HttpDriver;
18+
use Monolog\Test\TestCase;
19+
use function is_string;
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

Comments
 (0)