Beispiel #1
0
def _present_debug_token(token):
    data = {
        'userid': token.userid,
        'expires_at': utc_iso8601(token.expires) if token.expires else None,
        'issued_at': utc_iso8601(token.created),
        'expired': token.expired
    }

    if token.authclient:
        data['client'] = {
            'id': token.authclient.id,
            'name': token.authclient.name
        }

    return data
Beispiel #2
0
    def test_returns_debug_data_for_oauth_token(self, pyramid_request,
                                                token_service, oauth_token):
        pyramid_request.auth_token = oauth_token.value
        token_service.fetch.return_value = oauth_token

        result = views.debug_token(pyramid_request)

        assert result == {
            'userid': oauth_token.userid,
            'client': {
                'id': oauth_token.authclient.id,
                'name': oauth_token.authclient.name
            },
            'issued_at': utc_iso8601(oauth_token.created),
            'expires_at': utc_iso8601(oauth_token.expires),
            'expired': oauth_token.expired
        }
Beispiel #3
0
    def test_returns_debug_data_for_developer_token(self, pyramid_request,
                                                    token_service,
                                                    developer_token):
        pyramid_request.auth_token = developer_token.value
        token_service.fetch.return_value = developer_token

        result = views.debug_token(pyramid_request)

        assert result == {
            'userid': developer_token.userid,
            'issued_at': utc_iso8601(developer_token.created),
            'expires_at': None,
            'expired': False
        }
Beispiel #4
0
def test_utc_iso8601_ignores_timezone():
    t = datetime.datetime(2016, 2, 24, 18, 03, 25, 7685, Berlin())
    assert utc_iso8601(t) == '2016-02-24T18:03:25.007685+00:00'
Beispiel #5
0
def test_utc_iso8601():
    t = datetime.datetime(2016, 2, 24, 18, 03, 25, 7685)
    assert utc_iso8601(t) == '2016-02-24T18:03:25.007685+00:00'
Beispiel #6
0
def test_utc_iso8601_ignores_timezone():
    t = datetime.datetime(2016, 2, 24, 18, 03, 25, 7685, Berlin())
    assert utc_iso8601(t) == '2016-02-24T18:03:25.007685+00:00'
Beispiel #7
0
def test_utc_iso8601():
    t = datetime.datetime(2016, 2, 24, 18, 03, 25, 7685)
    assert utc_iso8601(t) == '2016-02-24T18:03:25.007685+00:00'