Esempio n. 1
0
def test_add_log_to_unknown_logset(mocked_url, mocked_ro_apikey, mocked_rw_apikey, capsys):
   with pytest.raises(SystemExit) as exit:
       mocked_url.return_value = LOGSET_API
       mocked_ro_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH
       mocked_rw_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH

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

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

       assert "404" in out
       assert exit.code is 1
Esempio n. 2
0
def test_add_log_to_unknown_logset(mocked_url, mocked_ro_apikey, mocked_rw_apikey, capsys):
   with pytest.raises(SystemExit) as exit:
       mocked_url.return_value = '', MOCK_API_URL
       mocked_ro_apikey.return_value = str(uuid.uuid4())
       mocked_rw_apikey.return_value = str(uuid.uuid4())

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

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

       assert "404" in out
       assert exit.code is 1
Esempio n. 3
0
def test_add_log_to_logset(mocked_url, mocked_ro_apikey, mocked_rw_apikey, capsys):
    mocked_url.return_value = '', MOCK_API_URL
    mocked_ro_apikey.return_value = str(uuid.uuid4())
    mocked_rw_apikey.return_value = str(uuid.uuid4())

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

    httpretty.register_uri(httpretty.PUT, MOCK_API_URL, status=200, content_type='application/json',
                           body=json.dumps(LOGSET_RESPONSE))

    api.add_log('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX', 'XXXXXXXX-ABCD-YYYY-DCBA-XXXXXXXXXXXX')
    out, err = capsys.readouterr()

    assert "XXXXXXXX-ABCD-YYYY-DCBA-XXXXXXXXXXXX" in out
Esempio n. 4
0
def test_add_unknown_log_to_logset(mocked_url, mocked_ro_apikey, 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())
        mocked_ro_apikey.return_value = str(uuid.uuid4())

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

        httpretty.register_uri(httpretty.PUT, MOCK_API_URL, status=400,
                               content_type='application/json')

        api.add_log('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX', 'unknown_log')
        out, err = capsys.readouterr()

        assert "400" in out
        assert exit.code is 1
Esempio n. 5
0
def test_add_log_to_unknown_logset(mocked_url, mocked_ro_apikey,
                                   mocked_rw_apikey, capsys):
    with pytest.raises(SystemExit) as exit:
        mocked_url.return_value = '', MOCK_API_URL
        mocked_ro_apikey.return_value = str(uuid.uuid4())
        mocked_rw_apikey.return_value = str(uuid.uuid4())

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

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

        assert "404" in out
        assert exit.code is 1
Esempio n. 6
0
def test_add_unknown_log_to_logset(mocked_url, mocked_ro_apikey, mocked_rw_apikey, capsys):
    with pytest.raises(SystemExit) as exit:
        mocked_url.return_value = LOGSET_API
        mocked_ro_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH
        mocked_rw_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH

        httpretty.register_uri(httpretty.GET, LOGSET_API + '/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
                               status=200,
                               content_type='application/json',
                               body=resp_ex.basic_logset_response)

        httpretty.register_uri(httpretty.PUT, LOGSET_API + '/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
                               status=400,
                               content_type='application/json')

        api.add_log('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX', 'unknown_log')
        out, err = capsys.readouterr()

        assert "400" in out
        assert exit.code is 1
Esempio n. 7
0
def test_add_log_to_logset(mocked_url, mocked_ro_apikey, mocked_rw_apikey, capsys):
    mocked_url.return_value = LOGSET_API
    mocked_ro_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH
    mocked_rw_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH

    httpretty.register_uri(httpretty.GET, LOGSET_API + '/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
                           status=200,
                           content_type='application/json',
                           body=resp_ex.basic_logset_response)

    httpretty.register_uri(httpretty.PUT, LOGSET_API + '/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
                           status=200,
                           content_type='application/json',
                           body=resp_ex.basic_logset_response_with_log)


    api.add_log('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX', 'XXXXXXXX-ABCD-YYYY-DCBA-XXXXXXXXXXXX')
    out, err = capsys.readouterr()

    assert "XXXXXXXX-ABCD-YYYY-DCBA-XXXXXXXXXXXX" in out
Esempio n. 8
0
def test_add_unknown_log_to_logset(mocked_url, mocked_ro_apikey,
                                   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())
        mocked_ro_apikey.return_value = str(uuid.uuid4())

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

        httpretty.register_uri(httpretty.PUT,
                               MOCK_API_URL,
                               status=400,
                               content_type='application/json')

        api.add_log('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX', 'unknown_log')
        out, err = capsys.readouterr()

        assert "400" in out
        assert exit.code is 1
Esempio n. 9
0
def test_add_log_to_logset(mocked_url, mocked_ro_apikey, mocked_rw_apikey,
                           capsys):
    mocked_url.return_value = '', MOCK_API_URL
    mocked_ro_apikey.return_value = str(uuid.uuid4())
    mocked_rw_apikey.return_value = str(uuid.uuid4())

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

    httpretty.register_uri(httpretty.PUT,
                           MOCK_API_URL,
                           status=200,
                           content_type='application/json',
                           body=json.dumps(LOGSET_RESPONSE))

    api.add_log('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
                'XXXXXXXX-ABCD-YYYY-DCBA-XXXXXXXXXXXX')
    out, err = capsys.readouterr()

    assert "XXXXXXXX-ABCD-YYYY-DCBA-XXXXXXXXXXXX" in out
Esempio n. 10
0
def updatelogset(command, logset_id, log_id):
    """Update a logset by adding or deleting a log."""
    if command == 'add_log':
        api.add_log(logset_id, log_id)
    elif command == 'delete_log':
        api.delete_log(logset_id, log_id)
Esempio n. 11
0
def updatelogset(command, logset_id, log_id):
    """Update a logset by adding or deleting a log."""
    if command == 'add_log':
        api.add_log(logset_id, log_id)
    elif command == 'delete_log':
        api.delete_log(logset_id, log_id)