コード例 #1
0
def test_delete_logset(mocked_url, mocked_rw_apikey, capsys):
    mocked_url.return_value = LOGSET_API
    mocked_rw_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH

    httpretty.register_uri(httpretty.DELETE, LOGSET_API + '/123',
                           status=204,
                           content_type='application/json')

    api.delete_logset('123')
    out, err = capsys.readouterr()

    assert "Deleted logset with id: 123" in out
コード例 #2
0
ファイル: test_logset_api.py プロジェクト: rapid7/lecli
def test_delete_logset(mocked_url, mocked_rw_apikey, capsys):
    mocked_url.return_value = '', MOCK_API_URL
    mocked_rw_apikey.return_value = str(uuid.uuid4())

    httpretty.register_uri(httpretty.DELETE, MOCK_API_URL,
                           status=204,
                           content_type='application/json')

    api.delete_logset('123')
    out, err = capsys.readouterr()

    assert not err
    assert "Deleted logset with id: 123" in out
コード例 #3
0
def test_delete_unknown_logset(mocked_url, mocked_rw_apikey, capsys):
    with pytest.raises(SystemExit) as exit:
        mocked_url.return_value = LOGSET_API
        mocked_rw_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH

        httpretty.register_uri(httpretty.DELETE, LOGSET_API + '/123',
                               status=404,
                               content_type='application/json')

        api.delete_logset('123')
        out, err = capsys.readouterr()

        assert "404" in out
        assert exit.code is 1
コード例 #4
0
def test_delete_logset(mocked_url, mocked_rw_apikey, capsys):
    mocked_url.return_value = '', MOCK_API_URL
    mocked_rw_apikey.return_value = str(uuid.uuid4())

    httpretty.register_uri(httpretty.DELETE,
                           MOCK_API_URL,
                           status=204,
                           content_type='application/json')

    api.delete_logset('123')
    out, err = capsys.readouterr()

    assert not err
    assert "Deleted logset with id: 123" in out
コード例 #5
0
ファイル: test_logset_api.py プロジェクト: rapid7/lecli
def test_delete_unknown_logset(mocked_url, mocked_rw_apikey, capsys):
    with pytest.raises(SystemExit) as exit:
        mocked_url.return_value = '', MOCK_API_URL
        mocked_rw_apikey.return_value = str(uuid.uuid4())

        httpretty.register_uri(httpretty.DELETE, MOCK_API_URL,
                               status=404,
                               content_type='application/json')

        api.delete_logset('123')
        out, err = capsys.readouterr()

        assert err
        assert "404" in out
        assert exit.code is 1
コード例 #6
0
def test_delete_unknown_logset(mocked_url, mocked_rw_apikey, capsys):
    with pytest.raises(SystemExit) as exit:
        mocked_url.return_value = '', MOCK_API_URL
        mocked_rw_apikey.return_value = str(uuid.uuid4())

        httpretty.register_uri(httpretty.DELETE,
                               MOCK_API_URL,
                               status=404,
                               content_type='application/json')

        api.delete_logset('123')
        out, err = capsys.readouterr()

        assert err
        assert "404" in out
        assert exit.code is 1
コード例 #7
0
ファイル: test_logset_api.py プロジェクト: rapid7/lecli
def test_delete_logset_with_log_in_another_logset(mocked_url, mocked_rw_apikey, mocked_ro_apikey, capsys):
    mocked_url.return_value = '', MOCK_API_URL
    mocked_rw_apikey.return_value = str(uuid.uuid4())
    mocked_ro_apikey.return_value = str(uuid.uuid4())

    httpretty.register_uri(httpretty.DELETE, MOCK_API_URL,
                           status=204, content_type='application/json')

    httpretty.register_uri(httpretty.GET, MOCK_API_URL,
                           status=200, content_type='application/json',
                           body=json.dumps({}))

    api.delete_logset('123')
    api.get_logset('456')
    out, err = capsys.readouterr()

    assert not err
コード例 #8
0
def test_delete_logset_with_log_in_another_logset(mocked_url, mocked_rw_apikey, mocked_ro_apikey, capsys):
    mocked_url.return_value = LOGSET_API
    mocked_rw_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH
    mocked_ro_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH

    httpretty.register_uri(httpretty.DELETE, LOGSET_API + '/123',
                           status=204, content_type='application/json')

    httpretty.register_uri(httpretty.GET, LOGSET_API + '/456',
                           status=200, content_type='application/json',
                           body=resp_ex.basic_logset_response_with_log)

    api.delete_logset('123')
    api.get_logset('456')
    out, err = capsys.readouterr()

    assert "XXXXXXXX-ABCD-YYYY-DCBA-XXXXXXXXXXXX" in out
コード例 #9
0
def test_delete_logset_with_log_in_another_logset(mocked_url, mocked_rw_apikey,
                                                  mocked_ro_apikey, capsys):
    mocked_url.return_value = '', MOCK_API_URL
    mocked_rw_apikey.return_value = str(uuid.uuid4())
    mocked_ro_apikey.return_value = str(uuid.uuid4())

    httpretty.register_uri(httpretty.DELETE,
                           MOCK_API_URL,
                           status=204,
                           content_type='application/json')

    httpretty.register_uri(httpretty.GET,
                           MOCK_API_URL,
                           status=200,
                           content_type='application/json',
                           body=json.dumps({}))

    api.delete_logset('123')
    api.get_logset('456')
    out, err = capsys.readouterr()

    assert not err
コード例 #10
0
def deletelogset(logset_id):
    """
    Delete a logset
    """
    api.delete_logset(logset_id)
コード例 #11
0
ファイル: commands.py プロジェクト: rapid7/lecli
def deletelogset(logset_id):
    """
    Delete a logset
    """
    api.delete_logset(logset_id)