Ejemplo n.º 1
0
def update_api_key(api_key, enable):
    """
    Enable or disable an api key
    """
    if enable is not None:
        api.update(api_key, enable)
    else:
        click.echo("Example usage: lecli update apikey 12345678-aaaa-bbbb-1234-1234cb123456 "
                   "--enable")
        click.echo("Example usage: lecli update apikey 12345678-aaaa-bbbb-1234-1234cb123456 "
                   "--disable")
Ejemplo n.º 2
0
def update_api_key(api_key, enable):
    """
    Enable or disable an api key
    """
    if enable is not None:
        api.update(api_key, enable)
    else:
        click.echo(
            "Example usage: lecli update apikey 12345678-aaaa-bbbb-1234-1234cb123456 "
            "--enable")
        click.echo(
            "Example usage: lecli update apikey 12345678-aaaa-bbbb-1234-1234cb123456 "
            "--disable")
Ejemplo n.º 3
0
def test_enable_api_key(mocked_url, mocked_owner_apikey, mocked_owner_apikey_id,
                        mocked_account_resource_id, capsys):
    api_key_id = str(uuid.uuid4())
    mocked_url.return_value = '', MOCK_API_URL
    mocked_owner_apikey.return_value = str(uuid.uuid4())
    mocked_owner_apikey_id.return_value = str(uuid.uuid4())
    mocked_account_resource_id.return_value = str(uuid.uuid4())
    httpretty.register_uri(httpretty.PATCH, MOCK_API_URL,
                           status=200,
                           content_type='application/json',
                           body=json.dumps({}))

    api.update(api_key_id, True)

    out, err = capsys.readouterr()
    assert {'apikey': {'active': True}} == json.loads(httpretty.last_request().body)
    assert not err
    assert 'Enabled api key with id: %s' % api_key_id in out
Ejemplo n.º 4
0
def test_enable_api_key(mocked_url, mocked_owner_apikey,
                        mocked_owner_apikey_id, mocked_account_resource_id,
                        capsys):
    api_key_id = str(uuid.uuid4())
    mocked_url.return_value = '', MOCK_API_URL
    mocked_owner_apikey.return_value = str(uuid.uuid4())
    mocked_owner_apikey_id.return_value = str(uuid.uuid4())
    mocked_account_resource_id.return_value = str(uuid.uuid4())
    httpretty.register_uri(httpretty.PATCH,
                           MOCK_API_URL,
                           status=200,
                           content_type='application/json',
                           body=json.dumps({}))

    api.update(api_key_id, True)

    out, err = capsys.readouterr()
    assert {
        'apikey': {
            'active': True
        }
    } == json.loads(httpretty.last_request().body)
    assert not err
    assert 'Enabled api key with id: %s' % api_key_id in out