|
19 | 19 | use Laudis\Neo4j\Bolt\BoltDriver; |
20 | 20 | use Laudis\Neo4j\Bolt\ConnectionPool; |
21 | 21 | use Laudis\Neo4j\ClientBuilder; |
| 22 | +use Laudis\Neo4j\Common\Uri; |
22 | 23 | use Laudis\Neo4j\Contracts\DriverInterface; |
23 | 24 | use Laudis\Neo4j\Contracts\TransactionInterface; |
| 25 | +use Laudis\Neo4j\Databags\DriverConfiguration; |
24 | 26 | use Laudis\Neo4j\Databags\SessionConfiguration; |
25 | 27 | use Laudis\Neo4j\Databags\Statement; |
26 | 28 | use Laudis\Neo4j\Exception\Neo4jException; |
27 | 29 | use Laudis\Neo4j\Tests\EnvironmentAwareIntegrationTest; |
| 30 | +use Psr\Log\LoggerInterface; |
| 31 | +use Psr\Log\LogLevel; |
28 | 32 | use ReflectionClass; |
29 | 33 |
|
30 | 34 | final class ClientIntegrationTest extends EnvironmentAwareIntegrationTest |
31 | 35 | { |
| 36 | + public function testDriverAuthFailureVerifyConnectivity(): void |
| 37 | + { |
| 38 | + $connection = $_ENV['CONNECTION'] ?? false; |
| 39 | + if (str_starts_with($connection, 'http')) { |
| 40 | + $this->markTestSkipped('HTTP does not support auth failure connectivity passing'); |
| 41 | + } |
| 42 | + |
| 43 | + if (!is_string($connection)) { |
| 44 | + $connection = 'bolt://localhost'; |
| 45 | + } |
| 46 | + |
| 47 | + $uri = Uri::create($connection); |
| 48 | + $uri = $uri->withUserInfo('neo4j', 'absolutelyonehundredpercentawrongpassword'); |
| 49 | + |
| 50 | + /** @noinspection PhpUnhandledExceptionInspection */ |
| 51 | + $conf = DriverConfiguration::default()->withLogger(LogLevel::DEBUG, $this->createMock(LoggerInterface::class)); |
| 52 | + $logger = $conf->getLogger(); |
| 53 | + if ($logger === null) { |
| 54 | + throw new RuntimeException('Logger not set'); |
| 55 | + } |
| 56 | + |
| 57 | + $driver = Driver::create($uri, $conf); |
| 58 | + |
| 59 | + $this->expectException(Neo4jException::class); |
| 60 | + $this->expectExceptionMessage('Neo4j errors detected. First one with code "Neo.ClientError.Security.Unauthorized" and message "The client is unauthorized due to authentication failure."'); |
| 61 | + $driver->verifyConnectivity(); |
| 62 | + } |
| 63 | + |
32 | 64 | public function testDifferentAuth(): void |
33 | 65 | { |
34 | 66 | $auth = Authenticate::fromUrl($this->getUri()); |
|
0 commit comments