Skip to content

Commit d3aa65e

Browse files
committed
Added auth steps
1 parent 3083a85 commit d3aa65e

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: utf-8 -*-
3+
4+
# Copyright (c) 2002-2016 "Neo Technology,"
5+
# Network Engine for Objects in Lund AB [http://neotechnology.com]
6+
#
7+
# This file is part of Neo4j.
8+
#
9+
# Licensed under the Apache License, Version 2.0 (the "License");
10+
# you may not use this file except in compliance with the License.
11+
# You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS,
17+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# See the License for the specific language governing permissions and
19+
# limitations under the License.
20+
21+
from behave import *
22+
23+
from neo4j.v1 import GraphDatabase, basic_auth, exceptions
24+
25+
26+
@given("a driver configured with auth disabled")
27+
def step_impl(context):
28+
context.driver = GraphDatabase.driver("bolt://localhost", encrypted=False)
29+
30+
31+
@given("a driver is configured with auth enabled and correct password is provided")
32+
def step_impl(context):
33+
context.driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=False)
34+
35+
36+
@given("a driver is configured with auth enabled and the wrong password is provided")
37+
def step_impl(context):
38+
context.driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "wrong"), encrypted=False)
39+
40+
41+
@step("reading and writing to the database should be possible")
42+
def step_impl(context):
43+
session = context.driver.session()
44+
session.run("CREATE (:label1)")
45+
assert len(list(session.run("MATCH (n:label1) RETURN n"))) == 1
46+
session.close()
47+
48+
49+
@step("reading and writing to the database should not be possible")
50+
def step_impl(context):
51+
try:
52+
session = context.driver.session()
53+
session.run("CREATE (:label1)")
54+
session.close()
55+
assert False
56+
except exceptions.ProtocolError, e:
57+
pass
58+
59+
60+
@step("a `Protocol Error` is raised")
61+
def step_impl(context):
62+
pass

0 commit comments

Comments
 (0)