Skip to content

Commit 2cd8427

Browse files
committed
Check connections for closure on LDAP Auth Credential expiration
1 parent c64723c commit 2cd8427

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

tests/stub/authorization.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,3 +655,70 @@ def get_vars(self, host=None):
655655

656656
def get_db(self):
657657
return None
658+
659+
660+
class NoRoutingAuthorizationTests(TestkitTestCase):
661+
def setUp(self):
662+
super().setUp()
663+
self._readServer = StubServer(9010)
664+
self._uri = "bolt://%s:%d" % (self._readServer.host,
665+
self._readServer.port)
666+
self._auth = types.AuthorizationToken(
667+
scheme="basic", principal="p", credentials="c")
668+
self._userAgent = "007"
669+
670+
def tearDown(self):
671+
self._readServer.reset()
672+
super().tearDown()
673+
674+
def read_return_1_failure_return_2_succeed_script(self):
675+
return """
676+
!: BOLT 4
677+
!: AUTO HELLO
678+
!: AUTO GOODBYE
679+
!: AUTO RESET
680+
!: ALLOW RESTART
681+
!: ALLOW CONCURRENT
682+
683+
{{
684+
C: RUN "RETURN 1 as n" {} {"mode": "r"}
685+
C: PULL {"n": 1000}
686+
S: SUCCESS {"fields": ["n"]}
687+
FAILURE {"code": "Neo.ClientError.Security.AuthorizationExpired", "message": "Authorization expired"}
688+
----
689+
C: RUN "RETURN 2 as n" {} {"mode": "r"}
690+
C: PULL {"n": 1000}
691+
S: SUCCESS {"fields": ["n"]}
692+
RECORD [1]
693+
SUCCESS {"type": "r"}
694+
C: RUN "RETURN 2 as n" {} {"mode": "r"}
695+
C: PULL {"n": 1000}
696+
S: SUCCESS {"fields": ["n"]}
697+
RECORD [1]
698+
SUCCESS {"type": "r"}
699+
}}
700+
"""
701+
702+
def test_should_drop_connection_after_AuthorizationExpired(self):
703+
self._readServer.start(
704+
script=self.read_return_1_failure_return_2_succeed_script()
705+
)
706+
driver = Driver(self._backend, self._uri, self._auth,
707+
userAgent=self._userAgent)
708+
709+
session1 = driver.session('r')
710+
session2 = driver.session('r')
711+
712+
session1.run('RETURN 2 as n').next()
713+
714+
try:
715+
session2.run('RETURN 1 as n').next()
716+
except types.DriverError as e:
717+
print(e) # should check exception
718+
719+
session2.close()
720+
session1.close()
721+
accept_count = self._readServer.count_responses("<ACCEPT>")
722+
hangup_count = self._readServer.count_responses("<HANGUP>")
723+
724+
self.assertEqual(accept_count, hangup_count)

0 commit comments

Comments
 (0)