예제 #1
0
def test_cdis_list_api_key(client, oauth_client):
    n_keys = 3
    for _ in range(n_keys):
        get_api_key(client)
    response = client.get('/credentials/cdis/')
    assert 'jtis' in response.json
    assert len(response.json['jtis']) == n_keys
    assert response.status_code == 200
예제 #2
0
def test_cdis_list_api_key(client, oauth_client, encoded_creds_jwt):
    encoded_credentials_jwt = encoded_creds_jwt["jwt"]
    n_keys = 3
    for _ in range(n_keys):
        get_api_key(client, encoded_credentials_jwt)
    response = client.get(
        "/credentials/cdis/",
        headers={"Authorization": "Bearer " + str(encoded_credentials_jwt)},
    )
    assert "jtis" in response.json
    assert len(response.json["jtis"]) == n_keys
    assert response.status_code == 200
예제 #3
0
def test_cdis_create_api_key_with_disallowed_scope(
    client, oauth_client, encoded_creds_jwt
):
    """
    Test ``POST /credentials/cdis``.
    """
    encoded_credentials_jwt = encoded_creds_jwt["jwt"]
    response = get_api_key(client, encoded_credentials_jwt, scope=["credentials"])
    assert response.status_code == 400
예제 #4
0
def test_cdis_get_access_token(client, oauth_client):
    """
    Test ``POST /credentials/cdis/access_token``.
    """
    response = get_api_key(client)
    api_key = response.json['api_key']
    path = '/credentials/cdis/access_token'
    data = {'api_key': api_key}
    response = client.post(path, data=data)
    assert 'access_token' in response.json
예제 #5
0
def test_cdis_get_access_token(client, oauth_client, encoded_creds_jwt):
    """
    Test ``POST /credentials/cdis/access_token``.
    """
    encoded_credentials_jwt = encoded_creds_jwt["jwt"]
    response = get_api_key(client, encoded_credentials_jwt)
    api_key = response.json["api_key"]
    path = "/credentials/cdis/access_token"
    data = {"api_key": api_key}
    response = client.post(
        path,
        data=data,
        headers={"Authorization": "Bearer " + str(encoded_credentials_jwt)},
    )
    assert "access_token" in response.json
예제 #6
0
def test_cdis_create_api_key_with_disallowed_scope(client, oauth_client):
    """
    Test ``POST /credentials/cdis``.
    """
    response = get_api_key(client, scope=['credentials'])
    assert response.status_code == 400