Skip to content

Commit 0635271

Browse files
committed
fixed the test_txrun
1 parent d784312 commit 0635271

40 files changed

+211
-2002
lines changed

Dockerfile

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

33
FROM php:${PHP_VERSION}-cli
44
RUN apt-get update \
@@ -8,6 +8,9 @@ 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 \
1114
&& pecl install xdebug \
1215
&& docker-php-ext-enable xdebug && \
1316
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

Dockerfile.neo4j-okta

Lines changed: 0 additions & 3 deletions
This file was deleted.

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: 2 additions & 2 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-enterprise
56+
image: neo4j:5-enterprise
5757
hostname: neo4j
5858
networks:
5959
- neo4j
@@ -62,7 +62,7 @@ services:
6262
- "11474:7474"
6363
environment:
6464
<<: *common-env
65-
NEO4J_ACCEPT_LICENSE_AGREEMENT: 'yes' # Also add this
65+
NEO4J_ACCEPT_LICENSE_AGREEMENT: 'yes'
6666
NEO4J_server_bolt_advertised__address: neo4j:7687
6767
NEO4J_server_http_advertised__address: neo4j:7474
6868

neo4j-with-okta.conf

Lines changed: 0 additions & 829 deletions
This file was deleted.

src/Authentication/BasicAuth.php

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

1414
namespace Laudis\Neo4j\Authentication;
1515

16-
use Bolt\enum\Signature;
17-
use Bolt\protocol\Response;
18-
use Bolt\protocol\V4_4;
19-
use Bolt\protocol\V5;
20-
use Bolt\protocol\V5_1;
21-
use Bolt\protocol\V5_2;
22-
use Bolt\protocol\V5_3;
23-
use Bolt\protocol\V5_4;
2416
use Exception;
2517
use Laudis\Neo4j\Bolt\BoltConnection;
2618
use Laudis\Neo4j\Bolt\BoltMessageFactory;
2719
use Laudis\Neo4j\Common\Neo4jLogger;
2820
use Laudis\Neo4j\Contracts\AuthenticateInterface;
29-
use Laudis\Neo4j\Exception\Neo4jException;
3021
use Psr\Http\Message\UriInterface;
3122

3223
/**
@@ -54,8 +45,6 @@ public function authenticateBolt(BoltConnection $connection, string $userAgent):
5445
if (method_exists($protocol, 'logon')) {
5546
$helloMetadata = ['user_agent' => $userAgent];
5647

57-
$factory->createHelloMessage($helloMetadata)->send();
58-
$response = self::getResponse($protocol);
5948
$responseHello = $factory->createHelloMessage($helloMetadata)->send()->getResponse();
6049

6150
$credentials = [
@@ -64,8 +53,6 @@ public function authenticateBolt(BoltConnection $connection, string $userAgent):
6453
'credentials' => $this->password,
6554
];
6655

67-
$factory->createLogonMessage($credentials)->send();
68-
self::getResponse($protocol);
6956
$response = $factory->createLogonMessage($credentials)->send()->getResponse();
7057

7158
/** @var array{server: string, connection_id: string, hints: list} */
@@ -88,23 +75,6 @@ public function authenticateBolt(BoltConnection $connection, string $userAgent):
8875
/**
8976
* @throws Exception
9077
*/
91-
public function logoff(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): void
92-
{
93-
$factory = $this->createMessageFactory($protocol);
94-
$factory->createLogoffMessage()->send();
95-
$protocol->getResponse();
96-
}
97-
98-
public static function getResponse(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): Response
99-
{
100-
$response = $protocol->getResponse();
101-
if ($response->signature === Signature::FAILURE) {
102-
throw Neo4jException::fromBoltResponse($response);
103-
}
104-
105-
return $response;
106-
}
107-
10878
public function toString(UriInterface $uri): string
10979
{
11080
return sprintf('Basic %s:%s@%s:%s', $this->username, '######', $uri->getHost(), $uri->getPort() ?? '');

src/Authentication/KerberosAuth.php

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

1414
namespace Laudis\Neo4j\Authentication;
1515

16-
use Bolt\enum\Signature;
17-
use Bolt\protocol\Response;
18-
use Bolt\protocol\V4_4;
19-
use Bolt\protocol\V5;
20-
use Bolt\protocol\V5_1;
21-
use Bolt\protocol\V5_2;
22-
use Bolt\protocol\V5_3;
23-
use Bolt\protocol\V5_4;
2416
use Exception;
17+
use Laudis\Neo4j\Bolt\BoltConnection;
2518
use Laudis\Neo4j\Bolt\BoltMessageFactory;
2619
use Laudis\Neo4j\Common\Neo4jLogger;
2720
use Laudis\Neo4j\Contracts\AuthenticateInterface;
28-
use Laudis\Neo4j\Exception\Neo4jException;
29-
use Psr\Http\Message\RequestInterface;
3021
use Psr\Http\Message\UriInterface;
3122
use Psr\Log\LogLevel;
3223

@@ -43,55 +34,33 @@ public function __construct(
4334
) {
4435
}
4536

46-
public function authenticateHttp(RequestInterface $request, UriInterface $uri, string $userAgent): RequestInterface
47-
{
48-
$this->logger?->log(LogLevel::DEBUG, 'Authenticating using KerberosAuth');
49-
50-
return $request->withHeader('Authorization', 'Kerberos '.$this->token)
51-
->withHeader('User-Agent', $userAgent);
52-
}
53-
5437
/**
5538
* @throws Exception
5639
*
5740
* @return array{server: string, connection_id: string, hints: list}
5841
*/
59-
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
6043
{
61-
$factory = $this->createMessageFactory($protocol);
44+
$factory = $this->createMessageFactory($connection);
6245

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

65-
$factory->createHelloMessage(['user_agent' => $userAgent])->send();
66-
67-
$response = self::getResponse($protocol);
48+
$factory->createHelloMessage(['user_agent' => $userAgent])->send()->getResponse();
6849

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

71-
$factory->createLogonMessage([
52+
$response = $factory->createLogonMessage([
7253
'scheme' => 'kerberos',
7354
'principal' => '',
7455
'credentials' => $this->token,
75-
])->send();
76-
77-
self::getResponse($protocol);
56+
])->send()->getResponse();
7857

7958
/**
8059
* @var array{server: string, connection_id: string, hints: list}
8160
*/
8261
return $response->content;
8362
}
8463

85-
public static function getResponse(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): Response
86-
{
87-
$response = $protocol->getResponse();
88-
if ($response->signature === Signature::FAILURE) {
89-
throw Neo4jException::fromBoltResponse($response);
90-
}
91-
92-
return $response;
93-
}
94-
9564
public function toString(UriInterface $uri): string
9665
{
9766
return sprintf('Kerberos %s@%s:%s', $this->token, $uri->getHost(), $uri->getPort() ?? '');
@@ -100,8 +69,8 @@ public function toString(UriInterface $uri): string
10069
/**
10170
* Helper to create the message factory.
10271
*/
103-
private function createMessageFactory(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): BoltMessageFactory
72+
private function createMessageFactory(BoltConnection $connection): BoltMessageFactory
10473
{
105-
return new BoltMessageFactory($protocol, $this->logger);
74+
return new BoltMessageFactory($connection, $this->logger);
10675
}
10776
}

src/Authentication/NoAuth.php

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

1414
namespace Laudis\Neo4j\Authentication;
1515

16-
use Bolt\enum\Signature;
17-
use Bolt\protocol\Response;
18-
use Bolt\protocol\V4_4;
19-
use Bolt\protocol\V5;
20-
use Bolt\protocol\V5_1;
21-
use Bolt\protocol\V5_2;
22-
use Bolt\protocol\V5_3;
23-
use Bolt\protocol\V5_4;
2416
use Exception;
17+
use Laudis\Neo4j\Bolt\BoltConnection;
2518
use Laudis\Neo4j\Bolt\BoltMessageFactory;
2619
use Laudis\Neo4j\Common\Neo4jLogger;
2720
use Laudis\Neo4j\Contracts\AuthenticateInterface;
28-
use Laudis\Neo4j\Exception\Neo4jException;
29-
use Psr\Http\Message\RequestInterface;
21+
use Laudis\Neo4j\Enum\ConnectionProtocol;
3022
use Psr\Http\Message\UriInterface;
31-
use Psr\Log\LogLevel;
3223

3324
use function sprintf;
3425

@@ -39,30 +30,21 @@ public function __construct(
3930
) {
4031
}
4132

42-
public function authenticateHttp(RequestInterface $request, UriInterface $uri, string $userAgent): RequestInterface
43-
{
44-
$this->logger?->log(LogLevel::DEBUG, 'Authentication disabled');
45-
46-
return $request->withHeader('User-Agent', $userAgent);
47-
}
48-
4933
/**
5034
* @throws Exception
5135
*
5236
* @return array{server: string, connection_id: string, hints: list}
5337
*/
54-
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
5539
{
56-
$factory = $this->createMessageFactory($protocol);
40+
$factory = $this->createMessageFactory($connection);
5741

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

61-
$factory->createHelloMessage($helloMetadata)->send();
62-
$response = self::getResponse($protocol);
45+
$factory->createHelloMessage($helloMetadata)->send()->getResponse();
6346

64-
$factory->createLogonMessage(['scheme' => 'none'])->send();
65-
self::getResponse($protocol);
47+
$response = $factory->createLogonMessage(['scheme' => 'none'])->send()->getResponse();
6648

6749
/** @var array{server: string, connection_id: string, hints: list} */
6850
return $response->content;
@@ -73,36 +55,19 @@ public function authenticateBolt(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol, string $
7355
'scheme' => 'none',
7456
];
7557

76-
$factory->createHelloMessage($helloMetadata)->send();
58+
$response = $factory->createHelloMessage($helloMetadata)->send()->getResponse();
7759

7860
/** @var array{server: string, connection_id: string, hints: list} */
79-
return self::getResponse($protocol)->content;
80-
}
81-
82-
public static function getResponse(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): Response
83-
{
84-
$response = $protocol->getResponse();
85-
if ($response->signature === Signature::FAILURE) {
86-
throw Neo4jException::fromBoltResponse($response);
87-
}
88-
89-
return $response;
90-
}
91-
92-
public function logoff(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): void
93-
{
94-
$factory = $this->createMessageFactory($protocol);
95-
$factory->createLogoffMessage()->send();
96-
$protocol->getResponse();
61+
return $response->content;
9762
}
9863

9964
public function toString(UriInterface $uri): string
10065
{
10166
return sprintf('No Auth %s:%s', $uri->getHost(), $uri->getPort() ?? '');
10267
}
10368

104-
private function createMessageFactory(V4_4|V5|V5_1|V5_2|V5_3|V5_4 $protocol): BoltMessageFactory
69+
private function createMessageFactory(BoltConnection $connection): BoltMessageFactory
10570
{
106-
return new BoltMessageFactory($protocol, $this->logger);
71+
return new BoltMessageFactory($connection, $this->logger);
10772
}
10873
}

src/Authentication/OpenIDConnectAuth.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
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;
2317
use Laudis\Neo4j\Bolt\BoltConnection;
2418
use Laudis\Neo4j\Bolt\BoltMessageFactory;
@@ -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 = $protocol->getResponse();
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-
$protocol->getResponse();
61+
])->send()->getResponse();
7262

7363
/**
7464
* @var array{server: string, connection_id: string, hints: list}

src/Bolt/BoltConnection.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ public function reset(): void
207207
public function begin(?string $database, ?float $timeout, BookmarkHolder $holder, ?iterable $txMetaData): void
208208
{
209209
$this->consumeResults();
210-
// ADD THIS: Authenticate the connection before beginning transaction
211-
$this->auth->authenticateBolt($this, $this->userAgent);
212210

213211
$extra = $this->buildRunExtra($database, $timeout, $holder, AccessMode::WRITE(), $txMetaData);
214212
$message = $this->messageFactory->createBeginMessage($extra);

0 commit comments

Comments
 (0)