Skip to content

Commit e3bb3db

Browse files
author
Zhen
committed
Adding 1.3 examples for kerberos auth token
1 parent 43df61c commit e3bb3db

File tree

3 files changed

+23
-36
lines changed

3 files changed

+23
-36
lines changed

test/examples/basic_auth_example.py renamed to test/examples/auth_example.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
# See the License for the specific language governing permissions and
1919
# limitations under the License.
2020

21-
# tag::basic-auth-import[]
22-
from neo4j.v1 import GraphDatabase
23-
# end::basic-auth-import[]
21+
from neo4j.v1 import GraphDatabase, kerberos_auth
22+
2423

2524
class BasicAuthExample:
2625
# tag::basic-auth[]
@@ -34,3 +33,23 @@ def close(self):
3433
def can_connect(self):
3534
record_list = list(self._driver.session().run("RETURN 1"))
3635
return int(record_list[0][0]) == 1
36+
37+
38+
class KerberosAuthExample:
39+
# tag::kerberos-auth[]
40+
def __init__(self, uri, ticket):
41+
self._driver = GraphDatabase.driver( uri, auth=kerberos_auth(ticket))
42+
# end::kerberos-auth[]
43+
44+
def close(self):
45+
self._driver.close()
46+
47+
48+
class CustomAuthExample:
49+
# tag::custom-auth[]
50+
def __init__(self, uri, principal, credentials, realm, scheme, parameters):
51+
self._driver = GraphDatabase.driver( uri, auth=(principal, credentials, realm, scheme, parameters))
52+
# end::custom-auth[]
53+
54+
def close(self):
55+
self._driver.close()

test/examples/custom_auth_example.py

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

test/examples/test_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_autocommit_transaction_example(self):
5555
self.assertTrue(self.person_count('Alice') > 0)
5656

5757
def test_basic_auth_example(self):
58-
from test.examples.basic_auth_example import BasicAuthExample
58+
from test.examples.auth_example import BasicAuthExample
5959

6060
example = BasicAuthExample(self.bolt_uri, self.user, self.password)
6161

0 commit comments

Comments
 (0)