Ejemplo n.º 1
0
def issued_tokens(request, superdesk_app, superdesk_client):
    tokens = []
    clients_data = []

    # register clients
    with superdesk_app.app_context():
        for param in request.param:
            clients_data.append({
                "name": str(ObjectId()),  # just a random string
                "client_id": str(ObjectId()),
                "password": str(ObjectId()),  # just a random string
                "scope": param
            })
            RegisterClient().run(**clients_data[-1])

    # retrieve tokens
    with superdesk_app.test_request_context():
        for client_data in clients_data:
            resp = superdesk_client.post(
                url_for('auth_server.issue_token'),
                data={'grant_type': 'client_credentials'},
                headers={
                    'Authorization':
                    _basic_auth_str(client_data['client_id'],
                                    client_data['password'])
                })
            tokens.append(json.loads(resp.data.decode('utf-8')))

    teardown_app(superdesk_app)
    del superdesk_client

    return tokens
Ejemplo n.º 2
0
def auth_server_registered_clients(request, superdesk_app):
    """
    Registers clients for auth server.
    :return: dict with clients
    """
    clients_data = []

    with superdesk_app.app_context():
        for param in request.param:
            # register clients
            clients_data.append({
                "name": str(ObjectId()),  # just a random string
                "client_id": str(ObjectId()),
                "password": str(ObjectId()),  # just a random string
                "scope": param
            })
            RegisterClient().run(**clients_data[-1])

    return clients_data