Skip to content

Commit b8b1cf0

Browse files
committed
Merge branch 'test_tx_func_run' into feat/tesktkit-session-run
2 parents 4e3dd50 + 1f5e57e commit b8b1cf0

File tree

68 files changed

+675
-795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+675
-795
lines changed

.github/workflows/testkit.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,5 @@ jobs:
6868
6969
- name: Run integration tests
7070
run: |
71-
docker compose up -d --remove-orphans --wait --no-build \
72-
server1 \
73-
server2 \
74-
server3 \
75-
server4 \
76-
testkit_backend
77-
78-
docker compose run --rm testkit ./testkit.sh
71+
docker compose up -d --remove-orphans --wait --no-build testkit_backend neo4j
72+
docker compose up testkit

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PHP_VERSION
1+
ARG PHP_VERSION=8.1
22

33
FROM php:${PHP_VERSION}-cli
44
RUN apt-get update \
@@ -8,9 +8,6 @@ RUN apt-get update \
88
git \
99
wget \
1010
&& docker-php-ext-install -j$(nproc) bcmath sockets \
11-
&& wget https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 \
12-
&& mv test-reporter-latest-linux-amd64 /usr/bin/cc-test-reporter \
13-
&& chmod +x /usr/bin/cc-test-reporter \
1411
&& pecl install xdebug \
1512
&& docker-php-ext-enable xdebug && \
1613
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"psr/http-factory": "^1.0",
2929
"psr/http-client": "^1.0",
3030
"php-http/message": "^1.0",
31-
"stefanak-michal/bolt": "^7.2.4",
31+
"stefanak-michal/bolt": "^7.1.4",
3232
"symfony/polyfill-php80": "^1.2",
3333
"psr/simple-cache": ">=2.0",
3434
"ext-json": "*",

docker-compose.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ services:
5353
- .env
5454
neo4j:
5555
<<: *common
56-
image: neo4j:5.23-community
56+
image: neo4j:5-enterprise
5757
hostname: neo4j
5858
networks:
5959
- neo4j
@@ -62,6 +62,7 @@ services:
6262
- "11474:7474"
6363
environment:
6464
<<: *common-env
65+
NEO4J_ACCEPT_LICENSE_AGREEMENT: 'yes'
6566
NEO4J_server_bolt_advertised__address: neo4j:7687
6667
NEO4J_server_http_advertised__address: neo4j:7474
6768

@@ -118,6 +119,7 @@ services:
118119

119120
testkit:
120121
image: python:3.13
122+
command: ./testkit.sh
121123
volumes:
122124
- .:/opt/project
123125
working_dir: /opt/project/testkit-backend
@@ -130,6 +132,9 @@ services:
130132
TEST_DRIVER_NAME: php
131133
TEST_DRIVER_REPO: /opt/project
132134
TEST_BACKEND_HOST: testkit_backend
135+
TEST_STUB_HOST: testkit
136+
depends_on:
137+
- testkit_backend
133138

134139
testkit_backend:
135140
<<: *common-php
@@ -140,7 +145,5 @@ services:
140145
- neo4j
141146
extra_hosts:
142147
- "host.docker.internal:host-gateway"
143-
depends_on:
144-
- neo4j
145148
ports:
146149
- "9876:9876"

src/Authentication/BasicAuth.php

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@
1313

1414
namespace Laudis\Neo4j\Authentication;
1515

16-
use Bolt\protocol\V4_4;
17-
use Bolt\protocol\V5;
18-
use Bolt\protocol\V5_1;
19-
use Bolt\protocol\V5_2;
20-
use Bolt\protocol\V5_3;
21-
use Bolt\protocol\V5_4;
2216
use Exception;
17+
use Laudis\Neo4j\Bolt\BoltConnection;
2318
use Laudis\Neo4j\Bolt\BoltMessageFactory;
2419
use Laudis\Neo4j\Common\Neo4jLogger;
25-
use Laudis\Neo4j\Common\ResponseHelper;
2620
use Laudis\Neo4j\Contracts\AuthenticateInterface;
2721
use Psr\Http\Message\UriInterface;
2822

@@ -43,27 +37,26 @@ public function __construct(
4337
*
4438
* @return array{server: string, connection_id: string, hints: list}
4539
*/
46-
public function authenticateBolt(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol, string $userAgent): array
40+
public function authenticateBolt(BoltConnection $connection, string $userAgent): array
4741
{
48-
$factory = $this->createMessageFactory($protocol);
42+
$factory = $this->createMessageFactory($connection);
4943

44+
$protocol = $connection->protocol();
5045
if (method_exists($protocol, 'logon')) {
5146
$helloMetadata = ['user_agent' => $userAgent];
5247

53-
$factory->createHelloMessage($helloMetadata)->send();
54-
$response = ResponseHelper::getResponse($protocol);
48+
$responseHello = $factory->createHelloMessage($helloMetadata)->send()->getResponse();
5549

5650
$credentials = [
5751
'scheme' => 'basic',
5852
'principal' => $this->username,
5953
'credentials' => $this->password,
6054
];
6155

62-
$factory->createLogonMessage($credentials)->send();
63-
ResponseHelper::getResponse($protocol);
56+
$response = $factory->createLogonMessage($credentials)->send()->getResponse();
6457

6558
/** @var array{server: string, connection_id: string, hints: list} */
66-
return $response->content;
59+
return array_merge($responseHello->content, $response->content);
6760
}
6861

6962
$helloMetadata = [
@@ -73,22 +66,15 @@ public function authenticateBolt(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol, string $
7366
'credentials' => $this->password,
7467
];
7568

76-
$factory->createHelloMessage($helloMetadata)->send();
69+
$response = $factory->createHelloMessage($helloMetadata)->send()->getResponse();
7770

7871
/** @var array{server: string, connection_id: string, hints: list} */
79-
return ResponseHelper::getResponse($protocol)->content;
72+
return $response->content;
8073
}
8174

8275
/**
8376
* @throws Exception
8477
*/
85-
public function logoff(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): void
86-
{
87-
$factory = $this->createMessageFactory($protocol);
88-
$factory->createLogoffMessage()->send();
89-
ResponseHelper::getResponse($protocol);
90-
}
91-
9278
public function toString(UriInterface $uri): string
9379
{
9480
return sprintf('Basic %s:%s@%s:%s', $this->username, '######', $uri->getHost(), $uri->getPort() ?? '');
@@ -97,8 +83,8 @@ public function toString(UriInterface $uri): string
9783
/**
9884
* Helper to create message factory.
9985
*/
100-
private function createMessageFactory(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): BoltMessageFactory
86+
private function createMessageFactory(BoltConnection $connection): BoltMessageFactory
10187
{
102-
return new BoltMessageFactory($protocol, $this->logger);
88+
return new BoltMessageFactory($connection, $this->logger);
10389
}
10490
}

src/Authentication/KerberosAuth.php

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,11 @@
1313

1414
namespace Laudis\Neo4j\Authentication;
1515

16-
use Bolt\protocol\V4_4;
17-
use Bolt\protocol\V5;
18-
use Bolt\protocol\V5_1;
19-
use Bolt\protocol\V5_2;
20-
use Bolt\protocol\V5_3;
21-
use Bolt\protocol\V5_4;
2216
use Exception;
17+
use Laudis\Neo4j\Bolt\BoltConnection;
2318
use Laudis\Neo4j\Bolt\BoltMessageFactory;
2419
use Laudis\Neo4j\Common\Neo4jLogger;
25-
use Laudis\Neo4j\Common\ResponseHelper;
2620
use Laudis\Neo4j\Contracts\AuthenticateInterface;
27-
use Psr\Http\Message\RequestInterface;
2821
use Psr\Http\Message\UriInterface;
2922
use Psr\Log\LogLevel;
3023

@@ -41,38 +34,26 @@ public function __construct(
4134
) {
4235
}
4336

44-
public function authenticateHttp(RequestInterface $request, UriInterface $uri, string $userAgent): RequestInterface
45-
{
46-
$this->logger?->log(LogLevel::DEBUG, 'Authenticating using KerberosAuth');
47-
48-
return $request->withHeader('Authorization', 'Kerberos '.$this->token)
49-
->withHeader('User-Agent', $userAgent);
50-
}
51-
5237
/**
5338
* @throws Exception
5439
*
5540
* @return array{server: string, connection_id: string, hints: list}
5641
*/
57-
public function authenticateBolt(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol, string $userAgent): array
42+
public function authenticateBolt(BoltConnection $connection, string $userAgent): array
5843
{
59-
$factory = $this->createMessageFactory($protocol);
44+
$factory = $this->createMessageFactory($connection);
6045

6146
$this->logger?->log(LogLevel::DEBUG, 'HELLO', ['user_agent' => $userAgent]);
6247

63-
$factory->createHelloMessage(['user_agent' => $userAgent])->send();
64-
65-
$response = ResponseHelper::getResponse($protocol);
48+
$factory->createHelloMessage(['user_agent' => $userAgent])->send()->getResponse();
6649

6750
$this->logger?->log(LogLevel::DEBUG, 'LOGON', ['scheme' => 'kerberos', 'principal' => '']);
6851

69-
$factory->createLogonMessage([
52+
$response = $factory->createLogonMessage([
7053
'scheme' => 'kerberos',
7154
'principal' => '',
7255
'credentials' => $this->token,
73-
])->send();
74-
75-
ResponseHelper::getResponse($protocol);
56+
])->send()->getResponse();
7657

7758
/**
7859
* @var array{server: string, connection_id: string, hints: list}
@@ -88,8 +69,8 @@ public function toString(UriInterface $uri): string
8869
/**
8970
* Helper to create the message factory.
9071
*/
91-
private function createMessageFactory(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): BoltMessageFactory
72+
private function createMessageFactory(BoltConnection $connection): BoltMessageFactory
9273
{
93-
return new BoltMessageFactory($protocol, $this->logger);
74+
return new BoltMessageFactory($connection, $this->logger);
9475
}
9576
}

src/Authentication/NoAuth.php

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,13 @@
1313

1414
namespace Laudis\Neo4j\Authentication;
1515

16-
use Bolt\protocol\V4_4;
17-
use Bolt\protocol\V5;
18-
use Bolt\protocol\V5_1;
19-
use Bolt\protocol\V5_2;
20-
use Bolt\protocol\V5_3;
21-
use Bolt\protocol\V5_4;
2216
use Exception;
17+
use Laudis\Neo4j\Bolt\BoltConnection;
2318
use Laudis\Neo4j\Bolt\BoltMessageFactory;
2419
use Laudis\Neo4j\Common\Neo4jLogger;
25-
use Laudis\Neo4j\Common\ResponseHelper;
2620
use Laudis\Neo4j\Contracts\AuthenticateInterface;
27-
use Psr\Http\Message\RequestInterface;
21+
use Laudis\Neo4j\Enum\ConnectionProtocol;
2822
use Psr\Http\Message\UriInterface;
29-
use Psr\Log\LogLevel;
3023

3124
use function sprintf;
3225

@@ -37,30 +30,21 @@ public function __construct(
3730
) {
3831
}
3932

40-
public function authenticateHttp(RequestInterface $request, UriInterface $uri, string $userAgent): RequestInterface
41-
{
42-
$this->logger?->log(LogLevel::DEBUG, 'Authentication disabled');
43-
44-
return $request->withHeader('User-Agent', $userAgent);
45-
}
46-
4733
/**
4834
* @throws Exception
4935
*
5036
* @return array{server: string, connection_id: string, hints: list}
5137
*/
52-
public function authenticateBolt(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol, string $userAgent): array
38+
public function authenticateBolt(BoltConnection $connection, string $userAgent): array
5339
{
54-
$factory = $this->createMessageFactory($protocol);
40+
$factory = $this->createMessageFactory($connection);
5541

56-
if (method_exists($protocol, 'logon')) {
42+
if ($connection->getProtocol()->compare(ConnectionProtocol::BOLT_V5_1()) >= 0) {
5743
$helloMetadata = ['user_agent' => $userAgent];
5844

59-
$factory->createHelloMessage($helloMetadata)->send();
60-
$response = ResponseHelper::getResponse($protocol);
45+
$factory->createHelloMessage($helloMetadata)->send()->getResponse();
6146

62-
$factory->createLogonMessage(['scheme' => 'none'])->send();
63-
ResponseHelper::getResponse($protocol);
47+
$response = $factory->createLogonMessage(['scheme' => 'none'])->send()->getResponse();
6448

6549
/** @var array{server: string, connection_id: string, hints: list} */
6650
return $response->content;
@@ -71,26 +55,19 @@ public function authenticateBolt(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol, string $
7155
'scheme' => 'none',
7256
];
7357

74-
$factory->createHelloMessage($helloMetadata)->send();
58+
$response = $factory->createHelloMessage($helloMetadata)->send()->getResponse();
7559

7660
/** @var array{server: string, connection_id: string, hints: list} */
77-
return ResponseHelper::getResponse($protocol)->content;
78-
}
79-
80-
public function logoff(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): void
81-
{
82-
$factory = $this->createMessageFactory($protocol);
83-
$factory->createLogoffMessage()->send();
84-
ResponseHelper::getResponse($protocol);
61+
return $response->content;
8562
}
8663

8764
public function toString(UriInterface $uri): string
8865
{
8966
return sprintf('No Auth %s:%s', $uri->getHost(), $uri->getPort() ?? '');
9067
}
9168

92-
private function createMessageFactory(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): BoltMessageFactory
69+
private function createMessageFactory(BoltConnection $connection): BoltMessageFactory
9370
{
94-
return new BoltMessageFactory($protocol, $this->logger);
71+
return new BoltMessageFactory($connection, $this->logger);
9572
}
9673
}

src/Authentication/OpenIDConnectAuth.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@
1313

1414
namespace Laudis\Neo4j\Authentication;
1515

16-
use Bolt\protocol\V4_4;
17-
use Bolt\protocol\V5;
18-
use Bolt\protocol\V5_1;
19-
use Bolt\protocol\V5_2;
20-
use Bolt\protocol\V5_3;
21-
use Bolt\protocol\V5_4;
2216
use Exception;
17+
use Laudis\Neo4j\Bolt\BoltConnection;
2318
use Laudis\Neo4j\Bolt\BoltMessageFactory;
2419
use Laudis\Neo4j\Common\Neo4jLogger;
25-
use Laudis\Neo4j\Common\ResponseHelper;
2620
use Laudis\Neo4j\Contracts\AuthenticateInterface;
2721
use Psr\Http\Message\RequestInterface;
2822
use Psr\Http\Message\UriInterface;
@@ -51,24 +45,20 @@ public function authenticateHttp(RequestInterface $request, UriInterface $uri, s
5145
*
5246
* @return array{server: string, connection_id: string, hints: list}
5347
*/
54-
public function authenticateBolt(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol, string $userAgent): array
48+
public function authenticateBolt(BoltConnection $connection, string $userAgent): array
5549
{
56-
$factory = $this->createMessageFactory($protocol);
50+
$factory = $this->createMessageFactory($connection);
5751

5852
$this->logger?->log(LogLevel::DEBUG, 'HELLO', ['user_agent' => $userAgent]);
5953

60-
$factory->createHelloMessage(['user_agent' => $userAgent])->send();
61-
62-
$response = ResponseHelper::getResponse($protocol);
54+
$factory->createHelloMessage(['user_agent' => $userAgent])->send()->getResponse();
6355

6456
$this->logger?->log(LogLevel::DEBUG, 'LOGON', ['scheme' => 'bearer']);
6557

66-
$factory->createLogonMessage([
58+
$response = $factory->createLogonMessage([
6759
'scheme' => 'bearer',
6860
'credentials' => $this->token,
69-
])->send();
70-
71-
ResponseHelper::getResponse($protocol);
61+
])->send()->getResponse();
7262

7363
/**
7464
* @var array{server: string, connection_id: string, hints: list}
@@ -84,8 +74,8 @@ public function toString(UriInterface $uri): string
8474
/**
8575
* Helper to create the message factory.
8676
*/
87-
public function createMessageFactory(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): BoltMessageFactory
77+
public function createMessageFactory(BoltConnection $connection): BoltMessageFactory
8878
{
89-
return new BoltMessageFactory($protocol, $this->logger);
79+
return new BoltMessageFactory($connection, $this->logger);
9080
}
9181
}

0 commit comments

Comments
 (0)