Revision f74d2b69

b/snf-astakos-client/astakosclient/__init__.py
168 168
        return simplejson.loads(unicode(data))
169 169

  
170 170
    # ------------------------
171
    def authenticate(self, token, usage=False):
172
        """Check if user is authenticated Astakos user
171
    def getUserInfo(self, token, usage=False):
172
        """Authenticate user and get user's info as a dictionary
173 173

  
174 174
        Keyword arguments:
175 175
        token   -- user's token (string)
b/snf-astakos-client/astakosclient/tests.py
429 429

  
430 430

  
431 431
class TestAuthenticate(unittest.TestCase):
432
    """Test cases for function authenticate"""
432
    """Test cases for function getUserInfo"""
433 433

  
434 434
    # ----------------------------------
435 435
    # Test the response we get if we don't have internet access
......
439 439
        _mockRequest([_requestOffline])
440 440
        try:
441 441
            client = AstakosClient("https://example.com", retry=3)
442
            client.authenticate(token_1)
442
            client.getUserInfo(token_1)
443 443
        except AstakosClientException:
444 444
            pass
445 445
        else:
......
452 452
        _mockRequest([_requestOk])
453 453
        try:
454 454
            client = AstakosClient("https://example.com", use_pool=pool)
455
            client.authenticate(token)
455
            client.getUserInfo(token)
456 456
        except Unauthorized:
457 457
            pass
458 458
        except Exception:
......
474 474
        _mockRequest([_requestOk])
475 475
        try:
476 476
            client = AstakosClient("https://example.com", use_pool=pool)
477
            auth_info = client.authenticate(token, usage=usage)
477
            auth_info = client.getUserInfo(token, usage=usage)
478 478
        except:
479 479
            self.fail("Shouldn't raise an Exception")
480 480
        self.assertEqual(user_info, auth_info)
......
516 516
    # ----------------------------------
517 517
    # Test retry functionality
518 518
    def test_OfflineRetry(self):
519
        """Test retry functionality for authentication"""
519
        """Test retry functionality for getUserInfo"""
520 520
        global token_1, user_1
521 521
        _mockRequest([_requestOffline, _requestOffline, _requestOk])
522 522
        try:
523 523
            client = AstakosClient("https://example.com", retry=2)
524
            auth_info = client.authenticate(token_1, usage=True)
524
            auth_info = client.getUserInfo(token_1, usage=True)
525 525
        except:
526 526
            self.fail("Shouldn't raise an Exception")
527 527
        self.assertEqual(user_1, auth_info)
b/snf-astakos-client/docs/index.rst
34 34
    from astakosclient import AstakosClient
35 35

  
36 36
    client = AstakosClient("https://accounts.example.com")
37
    user_info = client.authenticate("UQpYas7ElzWGD5yCcEXtjw==")
37
    user_info = client.getUserInfo("UQpYas7ElzWGD5yCcEXtjw==")
38 38
    print user_info['username']
39 39

  
40 40
Another example where we ask for the username of a user with UUID:
......
67 67

  
68 68
    This class provides the following methods:
69 69

  
70
    **authenticate(**\ token, usage=False\ **)**
70
    **getUserInfo(**\ token, usage=False\ **)**
71 71
        Given a valid authentication token it returns a dict with the
72 72
        correspoinding user's info. If usage is set to True more
73 73
        information about user's resources will be returned.

Also available in: Unified diff