Skip to content

Commit a5e4359

Browse files
committed
updated login logic
1 parent 5e2da96 commit a5e4359

File tree

7 files changed

+269
-81
lines changed

7 files changed

+269
-81
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ test
1111

1212
#PHP-CS-FIXER
1313
.php-cs-fixer.php
14-
.php-cs-fixer.cache
14+
.php-cs-fixer.cache
15+
tests/Unit

.php-cs-fixer.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"php":"8.3.6","version":"3.68.0:v3.68.0#73f78d8b2b34a0dd65fedb434a602ee4c2c8ad4c","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_extra_blank_lines":{"tokens":["use"]},"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_space_around_construct":{"constructs_followed_by_a_single_space":["abstract","as","case","catch","class","const_import","do","else","elseif","final","finally","for","foreach","function","function_import","if","insteadof","interface","namespace","new","private","protected","public","static","switch","trait","try","use","use_lambda","while"],"constructs_preceded_by_a_single_space":["as","else","elseif","use_lambda"]},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"attribute_placement":"ignore","on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"strict_param":true},"hashes":{"tests\/Unit\/Neo4jExceptionUnitTest.php":"0d7842780eeb9729d501831ee55df0d8","tests\/Unit\/ResultRowTest.php":"f5ee9f21d2439793a290e8ab946a7f32","tests\/Integration\/Neo4jOGMTest.php":"73136b2d28fbb4fa298467d1ab3e18c8","src\/OGM.php":"93aae9c7afc8dbfd5aa00bc1d264ad19","src\/Results\/ResultRow.php":"ad55ec1bd999a8f6ad6b18874c4017b5","src\/Results\/ResultSet.php":"5f7748a356bf0fb30403e3c5a411bd24","src\/Exception\/Neo4jException.php":"dfb0f6933b9d3913c5495ba6d801d5f1","src\/Objects\/Path.php":"88c95962a6316ba7aa2fa3f0f6e31627","src\/Objects\/Node.php":"4a8ab7b8bd1981ee4d35d8c52b81c7c3","src\/Objects\/ProfiledQueryPlanArguments.php":"1be7b230a034a72c13349a5670a34a2f","src\/Objects\/Person.php":"f2f469937660f5454761e4f31154e081","src\/Objects\/Point.php":"169715b2157e08482e420374e6ca4cc3","src\/Objects\/Bookmarks.php":"50f89ca88b2df817433ce8237ccc0f18","src\/Objects\/ResultCounters.php":"a9372c98fe7bede10cb004af30ea502f","src\/Objects\/Relationship.php":"f6347c0260780d4f5d2dc407dc97e25e","src\/Objects\/ProfiledQueryPlan.php":"d9ba608f3177426ea34d73276d75f20b","src\/Objects\/php your-script.php":"63c3a9abbf4774d1da8c5f3c9f8f455e","src\/BearerAuthentication.php":"6d1e8fa44d63a525a19e1c8a40c46170","src\/NoAuth.php":"80e445bfbd33cc7b60036db9461e0706","src\/AuthenticateInterface.php":"36290631a54b09926af0d78af8fc7282","src\/BasicAuthentication.php":"fcaea072ee441beeef8c809fdd2c234e","src\/Objects\/ResultSet.php":"f126eac07a2190797052d123971933be","tests\/resources\/expected\/complex-query-profile.php":"10f481c27e83c1478b5c0e3ad509ab26","tests\/Unit\/Neo4jQueryAPIUnitTest.php":"9d684834bd6cb7c51d4678106f1c9279","tests\/Unit\/AuthenticationTest.php":"5a82bdb87bed59515816c80b9d18400d","tests\/Integration\/Neo4jQueryAPIIntegrationTest.php":"5bb2d0f587edb31c90a9e79c5341adff","src\/Neo4jQueryAPI.php":"5cfceb37712eccb7ae0a71459b9cff60","src\/Objects\/Authentication.php":"ed994258ccebc582d42998c18e16c471","src\/Transaction.php":"3e57e12e463749f8e3aabece091c91fc"}}
1+
{"php":"8.3.6","version":"3.68.0:v3.68.0#73f78d8b2b34a0dd65fedb434a602ee4c2c8ad4c","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_extra_blank_lines":{"tokens":["use"]},"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_space_around_construct":{"constructs_followed_by_a_single_space":["abstract","as","case","catch","class","const_import","do","else","elseif","final","finally","for","foreach","function","function_import","if","insteadof","interface","namespace","new","private","protected","public","static","switch","trait","try","use","use_lambda","while"],"constructs_preceded_by_a_single_space":["as","else","elseif","use_lambda"]},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"attribute_placement":"ignore","on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"strict_param":true},"hashes":{"tests\/Unit\/Neo4jExceptionUnitTest.php":"0d7842780eeb9729d501831ee55df0d8","tests\/Unit\/ResultRowTest.php":"f5ee9f21d2439793a290e8ab946a7f32","tests\/Integration\/Neo4jOGMTest.php":"73136b2d28fbb4fa298467d1ab3e18c8","src\/OGM.php":"93aae9c7afc8dbfd5aa00bc1d264ad19","src\/Results\/ResultRow.php":"ad55ec1bd999a8f6ad6b18874c4017b5","src\/Results\/ResultSet.php":"5f7748a356bf0fb30403e3c5a411bd24","src\/Exception\/Neo4jException.php":"dfb0f6933b9d3913c5495ba6d801d5f1","src\/Objects\/Path.php":"88c95962a6316ba7aa2fa3f0f6e31627","src\/Objects\/Node.php":"4a8ab7b8bd1981ee4d35d8c52b81c7c3","src\/Objects\/ProfiledQueryPlanArguments.php":"1be7b230a034a72c13349a5670a34a2f","src\/Objects\/Person.php":"f2f469937660f5454761e4f31154e081","src\/Objects\/Point.php":"169715b2157e08482e420374e6ca4cc3","src\/Objects\/Bookmarks.php":"50f89ca88b2df817433ce8237ccc0f18","src\/Objects\/ResultCounters.php":"a9372c98fe7bede10cb004af30ea502f","src\/Objects\/Relationship.php":"f6347c0260780d4f5d2dc407dc97e25e","src\/Objects\/ProfiledQueryPlan.php":"d9ba608f3177426ea34d73276d75f20b","src\/Objects\/php your-script.php":"63c3a9abbf4774d1da8c5f3c9f8f455e","src\/Objects\/ResultSet.php":"f126eac07a2190797052d123971933be","tests\/resources\/expected\/complex-query-profile.php":"10f481c27e83c1478b5c0e3ad509ab26","src\/Transaction.php":"3e57e12e463749f8e3aabece091c91fc","tests\/Integration\/Neo4jQueryAPIIntegrationTest.php":"3330b18cf9c1395cd73a3ac9cb695253","src\/Neo4jQueryAPI.php":"6b9a0de0fc6aa8afc30dd9bc714d59c8","src\/NoAuth.php":"1db5e3d1197fe4f14e82e169d472e9d4","src\/AuthenticateInterface.php":"4f8ba55f92481b88d7a0ea556d2d24c5","src\/BasicAuthentication.php":"2fa3b9cb881ffb42c958020ea93fa3c3","src\/Objects\/Authentication.php":"9a542d736e88d3146232921a0f8f7852","tests\/Unit\/Neo4jQueryAPIUnitTest.php":"913e1850ac7b6ade459d829f299fa2bb","tests\/Unit\/AuthenticationTest.php":"b3a14c0ff573deb58f62803a08f14865","src\/BearerAuthentication.php":"d74739bcc5f7dac5a5d55084807b8713"}}

src/BearerAuthentication.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace Neo4j\QueryAPI;
44

5+
use Psr\Http\Message\MessageInterface;
56
use Psr\Http\Message\RequestInterface;
7+
use Psr\Http\Message\StreamInterface;
8+
use Psr\Http\Message\UriInterface;
69

710
class BearerAuthentication implements AuthenticateInterface
811
{
@@ -15,4 +18,89 @@ public function authenticate(RequestInterface $request): RequestInterface
1518
$authHeader = 'Bearer ' . $this->token;
1619
return $request->withHeader('Authorization', $authHeader);
1720
}
21+
22+
public function getProtocolVersion(): string
23+
{
24+
// TODO: Implement getProtocolVersion() method.
25+
}
26+
27+
public function withProtocolVersion(string $version): MessageInterface
28+
{
29+
// TODO: Implement withProtocolVersion() method.
30+
}
31+
32+
public function getHeaders(): array
33+
{
34+
// TODO: Implement getHeaders() method.
35+
}
36+
37+
public function hasHeader(string $name): bool
38+
{
39+
// TODO: Implement hasHeader() method.
40+
}
41+
42+
public function getHeader(string $name): array
43+
{
44+
// TODO: Implement getHeader() method.
45+
}
46+
47+
public function getHeaderLine(string $name): string
48+
{
49+
// TODO: Implement getHeaderLine() method.
50+
}
51+
52+
public function withHeader(string $name, $value): MessageInterface
53+
{
54+
// TODO: Implement withHeader() method.
55+
}
56+
57+
public function withAddedHeader(string $name, $value): MessageInterface
58+
{
59+
// TODO: Implement withAddedHeader() method.
60+
}
61+
62+
public function withoutHeader(string $name): MessageInterface
63+
{
64+
// TODO: Implement withoutHeader() method.
65+
}
66+
67+
public function getBody(): StreamInterface
68+
{
69+
// TODO: Implement getBody() method.
70+
}
71+
72+
public function withBody(StreamInterface $body): MessageInterface
73+
{
74+
// TODO: Implement withBody() method.
75+
}
76+
77+
public function getRequestTarget(): string
78+
{
79+
// TODO: Implement getRequestTarget() method.
80+
}
81+
82+
public function withRequestTarget(string $requestTarget): RequestInterface
83+
{
84+
// TODO: Implement withRequestTarget() method.
85+
}
86+
87+
public function getMethod(): string
88+
{
89+
// TODO: Implement getMethod() method.
90+
}
91+
92+
public function withMethod(string $method): RequestInterface
93+
{
94+
// TODO: Implement withMethod() method.
95+
}
96+
97+
public function getUri(): UriInterface
98+
{
99+
// TODO: Implement getUri() method.
100+
}
101+
102+
public function withUri(UriInterface $uri, bool $preserveHost = false): RequestInterface
103+
{
104+
// TODO: Implement withUri() method.
105+
}
18106
}

src/NoAuth.php

Lines changed: 113 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,73 @@ public function withMethod(string $method): RequestInterface
3838

3939
public function getUri(): UriInterface
4040
{
41-
return new class implements UriInterface {
41+
return new class () implements UriInterface {
4242
public function __toString(): string
4343
{
4444
return ''; // Default URI
4545
}
4646

4747
// Implement other methods as needed for UriInterface, or leave as empty methods
48-
public function getScheme(): string { return ''; }
49-
public function getAuthority(): string { return ''; }
50-
public function getUserInfo(): string { return ''; }
51-
public function getHost(): string { return ''; }
52-
public function getPort(): ?int { return null; }
53-
public function getPath(): string { return ''; }
54-
public function getQuery(): string { return ''; }
55-
public function getFragment(): string { return ''; }
56-
public function withScheme($scheme): UriInterface { return $this; }
57-
public function withUserInfo($user, $password = null): UriInterface { return $this; }
58-
public function withHost($host): UriInterface { return $this; }
59-
public function withPort($port): UriInterface { return $this; }
60-
public function withPath($path): UriInterface { return $this; }
61-
public function withQuery($query): UriInterface { return $this; }
62-
public function withFragment($fragment): UriInterface { return $this; }
48+
public function getScheme(): string
49+
{
50+
return '';
51+
}
52+
public function getAuthority(): string
53+
{
54+
return '';
55+
}
56+
public function getUserInfo(): string
57+
{
58+
return '';
59+
}
60+
public function getHost(): string
61+
{
62+
return '';
63+
}
64+
public function getPort(): ?int
65+
{
66+
return null;
67+
}
68+
public function getPath(): string
69+
{
70+
return '';
71+
}
72+
public function getQuery(): string
73+
{
74+
return '';
75+
}
76+
public function getFragment(): string
77+
{
78+
return '';
79+
}
80+
public function withScheme($scheme): UriInterface
81+
{
82+
return $this;
83+
}
84+
public function withUserInfo($user, $password = null): UriInterface
85+
{
86+
return $this;
87+
}
88+
public function withHost($host): UriInterface
89+
{
90+
return $this;
91+
}
92+
public function withPort($port): UriInterface
93+
{
94+
return $this;
95+
}
96+
public function withPath($path): UriInterface
97+
{
98+
return $this;
99+
}
100+
public function withQuery($query): UriInterface
101+
{
102+
return $this;
103+
}
104+
public function withFragment($fragment): UriInterface
105+
{
106+
return $this;
107+
}
63108
};
64109
}
65110

@@ -105,26 +150,63 @@ public function withoutHeader(string $name): MessageInterface
105150

106151
public function getBody(): StreamInterface
107152
{
108-
return new class implements StreamInterface {
153+
return new class () implements StreamInterface {
109154
public function __toString(): string
110155
{
111156
return ''; // Default empty body
112157
}
113158

114-
public function close(): void {}
115-
public function detach() {}
116-
public function getSize(): ?int { return 0; }
117-
public function tell(): int { return 0; }
118-
public function eof(): bool { return true; }
119-
public function isSeekable(): bool { return false; }
120-
public function seek($offset, $whence = SEEK_SET): void {}
121-
public function rewind(): void {}
122-
public function isWritable(): bool { return false; }
123-
public function write($string): int {}
124-
public function isReadable(): bool { return false; }
125-
public function read($length): string { return ''; }
126-
public function getContents(): string { return ''; }
127-
public function getMetadata($key = null) { return null; }
159+
public function close(): void
160+
{
161+
}
162+
public function detach()
163+
{
164+
}
165+
public function getSize(): ?int
166+
{
167+
return 0;
168+
}
169+
public function tell(): int
170+
{
171+
return 0;
172+
}
173+
public function eof(): bool
174+
{
175+
return true;
176+
}
177+
public function isSeekable(): bool
178+
{
179+
return false;
180+
}
181+
public function seek($offset, $whence = SEEK_SET): void
182+
{
183+
}
184+
public function rewind(): void
185+
{
186+
}
187+
public function isWritable(): bool
188+
{
189+
return false;
190+
}
191+
public function write($string): int
192+
{
193+
}
194+
public function isReadable(): bool
195+
{
196+
return false;
197+
}
198+
public function read($length): string
199+
{
200+
return '';
201+
}
202+
public function getContents(): string
203+
{
204+
return '';
205+
}
206+
public function getMetadata($key = null)
207+
{
208+
return null;
209+
}
128210
};
129211
}
130212

tests/Integration/Neo4jQueryAPIIntegrationTest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -230,32 +230,32 @@ public function testChildQueryPlanExistence(): void
230230

231231

232232

233-
/* public function testTransactionCommit(): void
234-
{
235-
// Begin a new transaction
236-
$tsx = $this->api->beginTransaction();
233+
/* public function testTransactionCommit(): void
234+
{
235+
// Begin a new transaction
236+
$tsx = $this->api->beginTransaction();
237237
238-
// Generate a random name for the node
239-
$name = (string)mt_rand(1, 100000);
238+
// Generate a random name for the node
239+
$name = (string)mt_rand(1, 100000);
240240
241-
// Create a node within the transaction
242-
$tsx->run("CREATE (x:Human {name: \$name})", ['name' => $name]);
241+
// Create a node within the transaction
242+
$tsx->run("CREATE (x:Human {name: \$name})", ['name' => $name]);
243243
244-
// Validate that the node does not exist in the database before the transaction is committed
245-
$results = $this->api->run("MATCH (x:Human {name: \$name}) RETURN x", ['name' => $name]);
246-
$this->assertCount(0, $results);
244+
// Validate that the node does not exist in the database before the transaction is committed
245+
$results = $this->api->run("MATCH (x:Human {name: \$name}) RETURN x", ['name' => $name]);
246+
$this->assertCount(0, $results);
247247
248-
// Validate that the node exists within the transaction
249-
$results = $tsx->run("MATCH (x:Human {name: \$name}) RETURN x", ['name' => $name]);
250-
$this->assertCount(1, $results);
248+
// Validate that the node exists within the transaction
249+
$results = $tsx->run("MATCH (x:Human {name: \$name}) RETURN x", ['name' => $name]);
250+
$this->assertCount(1, $results);
251251
252-
// Commit the transaction
253-
$tsx->commit();
252+
// Commit the transaction
253+
$tsx->commit();
254254
255-
// Validate that the node now exists in the database
256-
$results = $this->api->run("MATCH (x:Human {name: \$name}) RETURN x", ['name' => $name]);
257-
$this->assertCount(1, $results); // Updated to expect 1 result
258-
}*/
255+
// Validate that the node now exists in the database
256+
$results = $this->api->run("MATCH (x:Human {name: \$name}) RETURN x", ['name' => $name]);
257+
$this->assertCount(1, $results); // Updated to expect 1 result
258+
}*/
259259

260260

261261
/**

0 commit comments

Comments
 (0)