Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
synnefo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
synnefo
Commits
4ce259a6
Commit
4ce259a6
authored
Mar 22, 2013
by
Ilias Tsitsimpis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename AstakosClient's authenticate method to getUserInfo
parent
e3ae6f4d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
snf-astakos-client/astakosclient/__init__.py
snf-astakos-client/astakosclient/__init__.py
+2
-2
snf-astakos-client/astakosclient/tests.py
snf-astakos-client/astakosclient/tests.py
+6
-6
snf-astakos-client/docs/index.rst
snf-astakos-client/docs/index.rst
+2
-2
No files found.
snf-astakos-client/astakosclient/__init__.py
View file @
4ce259a6
...
...
@@ -168,8 +168,8 @@ class AstakosClient():
return
simplejson
.
loads
(
unicode
(
data
))
# ------------------------
def
authenticate
(
self
,
token
,
usage
=
False
):
"""
Check if user is authenticated Astakos user
def
getUserInfo
(
self
,
token
,
usage
=
False
):
"""
Authenticate user and get user's info as a dictionary
Keyword arguments:
token -- user's token (string)
...
...
snf-astakos-client/astakosclient/tests.py
View file @
4ce259a6
...
...
@@ -429,7 +429,7 @@ class TestCallAstakos(unittest.TestCase):
class
TestAuthenticate
(
unittest
.
TestCase
):
"""Test cases for function
authenticate
"""
"""Test cases for function
getUserInfo
"""
# ----------------------------------
# Test the response we get if we don't have internet access
...
...
@@ -439,7 +439,7 @@ class TestAuthenticate(unittest.TestCase):
_mockRequest
([
_requestOffline
])
try
:
client
=
AstakosClient
(
"https://example.com"
,
retry
=
3
)
client
.
authenticate
(
token_1
)
client
.
getUserInfo
(
token_1
)
except
AstakosClientException
:
pass
else
:
...
...
@@ -452,7 +452,7 @@ class TestAuthenticate(unittest.TestCase):
_mockRequest
([
_requestOk
])
try
:
client
=
AstakosClient
(
"https://example.com"
,
use_pool
=
pool
)
client
.
authenticate
(
token
)
client
.
getUserInfo
(
token
)
except
Unauthorized
:
pass
except
Exception
:
...
...
@@ -474,7 +474,7 @@ class TestAuthenticate(unittest.TestCase):
_mockRequest
([
_requestOk
])
try
:
client
=
AstakosClient
(
"https://example.com"
,
use_pool
=
pool
)
auth_info
=
client
.
authenticate
(
token
,
usage
=
usage
)
auth_info
=
client
.
getUserInfo
(
token
,
usage
=
usage
)
except
:
self
.
fail
(
"Shouldn't raise an Exception"
)
self
.
assertEqual
(
user_info
,
auth_info
)
...
...
@@ -516,12 +516,12 @@ class TestAuthenticate(unittest.TestCase):
# ----------------------------------
# Test retry functionality
def
test_OfflineRetry
(
self
):
"""Test retry functionality for
authentication
"""
"""Test retry functionality for
getUserInfo
"""
global
token_1
,
user_1
_mockRequest
([
_requestOffline
,
_requestOffline
,
_requestOk
])
try
:
client
=
AstakosClient
(
"https://example.com"
,
retry
=
2
)
auth_info
=
client
.
authenticate
(
token_1
,
usage
=
True
)
auth_info
=
client
.
getUserInfo
(
token_1
,
usage
=
True
)
except
:
self
.
fail
(
"Shouldn't raise an Exception"
)
self
.
assertEqual
(
user_1
,
auth_info
)
...
...
snf-astakos-client/docs/index.rst
View file @
4ce259a6
...
...
@@ -34,7 +34,7 @@ demonstrates how to get user's info using ``astakosclient``.
from astakosclient import AstakosClient
client = AstakosClient("https://accounts.example.com")
user_info = client.
authenticate
("UQpYas7ElzWGD5yCcEXtjw==")
user_info = client.
getUserInfo
("UQpYas7ElzWGD5yCcEXtjw==")
print user_info['username']
Another example where we ask for the username of a user with UUID:
...
...
@@ -67,7 +67,7 @@ retry=0, use_pool=False, pool_size=8, logger=None\ **)**
This class provides the following methods:
**
authenticate
(**\ token, usage=False\ **)**
**
getUserInfo
(**\ token, usage=False\ **)**
Given a valid authentication token it returns a dict with the
correspoinding user's info. If usage is set to True more
information about user's resources will be returned.
...
...
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