Skip to content

Commit 8cffce8

Browse files
committed
test: Fix auth tests
1 parent 2a85094 commit 8cffce8

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

docker-compose-neo4j-4.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ x-shared:
33
NEO4J_AUTH: neo4j/testtest
44
NEO4J_ACCEPT_LICENSE_AGREEMENT: "yes"
55
NEO4J_dbms_security_allow__csv__import__from__file__urls: "true"
6+
NEO4J_dbms_security_auth__lock__time: 0s
67
NEO4JLABS_PLUGINS: '["apoc"]'
78

89
x-shared-cluster:

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ x-definitions:
22
x-shared-env:
33
&common-env
44
NEO4J_AUTH: neo4j/testtest
5+
NEO4J_dbms_security_auth__lock__time: 0s
56
NEO4J_PLUGINS: '["apoc"]'
67
x-shared-cluster-env:
78
&common-cluster-env

src/Neo4j/Neo4jConnectionPool.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Laudis\Neo4j\Neo4j;
1515

16+
use Bolt\error\ConnectException;
1617
use function array_unique;
1718
use function count;
1819

@@ -146,7 +147,7 @@ public function acquire(SessionConfiguration $config): Generator
146147
/** @var BoltConnection $connection */
147148
$connection = GeneratorHelper::getReturnFromGenerator($pool->acquire($config));
148149
$table = $this->routingTable($connection, $config);
149-
} catch (Throwable $e) {
150+
} catch (ConnectException $e) {
150151
// todo - once client side logging is implemented it must be conveyed here.
151152
$latestError = $e;
152153
continue; // We continue if something is wrong with the current server

tests/Integration/ClientIntegrationTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Laudis\Neo4j\Bolt\ConnectionPool;
2222
use Laudis\Neo4j\ClientBuilder;
2323
use Laudis\Neo4j\Common\DriverSetupManager;
24-
use Laudis\Neo4j\Common\Uri;
2524
use Laudis\Neo4j\Contracts\DriverInterface;
2625
use Laudis\Neo4j\Contracts\TransactionInterface;
2726
use Laudis\Neo4j\Databags\DriverConfiguration;
@@ -39,6 +38,12 @@
3938

4039
final class ClientIntegrationTest extends EnvironmentAwareIntegrationTest
4140
{
41+
public function setUp(): void
42+
{
43+
parent::setUp();
44+
$this->driver->closeConnections();
45+
}
46+
4247
public function testDriverAuthFailureVerifyConnectivity(): void
4348
{
4449
if (str_starts_with($this->uri->getScheme(), 'http')) {
@@ -47,7 +52,6 @@ public function testDriverAuthFailureVerifyConnectivity(): void
4752

4853
$uri = $this->uri->withUserInfo('neo4j', 'absolutelyonehundredpercentawrongpassword');
4954

50-
/** @noinspection PhpUnhandledExceptionInspection */
5155
$conf = DriverConfiguration::default()->withLogger(LogLevel::DEBUG, $this->createMock(LoggerInterface::class));
5256
$logger = $conf->getLogger();
5357
if ($logger === null) {
@@ -60,6 +64,7 @@ public function testDriverAuthFailureVerifyConnectivity(): void
6064
$this->expectExceptionMessage(
6165
'Neo4j errors detected. First one with code "Neo.ClientError.Security.Unauthorized" and message "The client is unauthorized due to authentication failure."'
6266
);
67+
6368
$driver->verifyConnectivity();
6469
}
6570

@@ -89,13 +94,12 @@ public function testClientAuthFailureVerifyConnectivity(): void
8994
)
9095
))->build();
9196

92-
$driver = $client->getDriver(null);
93-
9497
$this->expectException(Neo4jException::class);
9598
$this->expectExceptionMessage(
9699
'Neo4j errors detected. First one with code "Neo.ClientError.Security.Unauthorized" and message "The client is unauthorized due to authentication failure."'
97100
);
98-
$driver->verifyConnectivity();
101+
102+
$client->getDriver(null);
99103
}
100104

101105
public function testDifferentAuth(): void

0 commit comments

Comments
 (0)