Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
9fda3635
Commit
9fda3635
authored
Jul 28, 2016
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
let's include the test in the PR, shall we?
parent
dbb066d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
src/ZEO/tests/test_client_credentials.py
src/ZEO/tests/test_client_credentials.py
+56
-0
No files found.
src/ZEO/tests/test_client_credentials.py
0 → 100644
View file @
9fda3635
"""Clients can pass credentials to a server.
This is an experimental feature to enable server authentication and
authorization.
"""
from
zope.testing
import
setupstack
import
unittest
import
ZEO.StorageServer
class
ClientAuthTests
(
setupstack
.
TestCase
):
def
setUp
(
self
):
self
.
setUpDirectory
()
self
.
__register
=
ZEO
.
StorageServer
.
ZEOStorage
.
register
def
tearDown
(
self
):
ZEO
.
StorageServer
.
ZEOStorage
.
register
=
self
.
__register
def
test_passing_credentials
(
self
):
# First, we'll temporarily swap the storage server register
# method with one that let's is see credentials that were passed:
creds_log
=
[]
def
register
(
zs
,
storage_id
,
read_only
,
credentials
=
self
):
creds_log
.
append
(
credentials
)
return
self
.
__register
(
zs
,
storage_id
,
read_only
)
ZEO
.
StorageServer
.
ZEOStorage
.
register
=
register
# Now start an in process server
addr
,
stop
=
ZEO
.
server
()
# If we connect, without providing credentials, then no
# credentials will be passed to register:
client
=
ZEO
.
client
(
addr
)
self
.
assertEqual
(
creds_log
,
[
self
])
client
.
close
()
creds_log
.
pop
()
# But if we pass credentials, they'll be passed to register:
creds
=
dict
(
user
=
'me'
,
password
=
'123'
)
client
=
ZEO
.
client
(
addr
,
credentials
=
creds
)
self
.
assertEqual
(
creds_log
,
[
creds
])
client
.
close
()
stop
()
def
test_suite
():
return
unittest
.
makeSuite
(
ClientAuthTests
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment