Esempio n. 1
0
def test_conf():
    with temp_conf({'port': 5555}) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF_FILE'] = fn
        with server(env=env, wait=5555):
            r = requests.get('http://localhost:5555/v1/info')
            assert r.ok
Esempio n. 2
0
def test_basic():
    with temp_conf({}) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF_FILE'] = fn
        with server(env=env, wait=5000):
            r = requests.get('http://localhost:5000/v1/info')
            assert r.ok
Esempio n. 3
0
def test_cli():
    with temp_conf({}) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF_FILE'] = fn
        with server(args=('-p', '5555'), env=env, wait=5555):
            r = requests.get('http://localhost:5555/v1/info')
            assert r.ok
Esempio n. 4
0
def test_conf_auth():
    with temp_conf({
            'auth': {
                'class': 'intake.auth.secret.SecretAuth',
                'kwargs': {
                    'secret': 'test'
                }
            }
    }) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF_FILE'] = fn
        with server(env=env, wait=5000):
            # raw request
            r = requests.get('http://localhost:5000/v1/info')
            assert r.status_code == 403
            r = requests.get('http://localhost:5000/v1/info',
                             headers={'intake-secret': 'test'})
            assert r.ok

            # with cat
            with pytest.raises(Exception):
                intake.Catalog('intake://localhost:5000')

            cat = intake.Catalog(
                'intake://localhost:5000',
                storage_options={'headers': {
                    'intake-secret': 'test'
                }})
            assert 'entry1' in cat
Esempio n. 5
0
def test_cli():
    with temp_conf({}) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF_FILE'] = fn
        with server(args=('-p', '5555'), env=env, wait=5555):
            r = requests.get('http://localhost:5555/v1/info')
            assert r.ok
Esempio n. 6
0
def test_conf():
    with temp_conf({'port': 5555}) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF_FILE'] = fn
        with server(env=env, wait=5555):
            r = requests.get('http://localhost:5555/v1/info')
            assert r.ok
Esempio n. 7
0
def test_conf_auth():
    with temp_conf({'auth': {'class': 'intake.auth.secret.SecretAuth'}}) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF_FILE'] = fn
        with server(env=env, wait=5000):
            r = requests.get('http://localhost:5000/v1/info')
            assert r.status_code == 403
Esempio n. 8
0
def test_basic():
    with temp_conf({}) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF_FILE'] = fn
        with server(env=env, wait=5000):
            r = requests.get('http://localhost:5000/v1/info')
            assert r.ok
Esempio n. 9
0
def test_load_conf(conf):
    inconf = config.conf.copy()
    expected = inconf.copy()
    with temp_conf(conf) as fn:
        config.load_conf(fn)
        expected.update(conf)
        assert config.conf == expected
        config.reset_conf()
        assert config.conf == inconf
Esempio n. 10
0
def test_load_conf(conf):
    inconf = config.conf.copy()
    expected = inconf.copy()
    with temp_conf(conf) as fn:
        config.load_conf(fn)
        expected.update(conf)
        assert config.conf == expected
        config.reset_conf()
        assert config.conf == inconf
Esempio n. 11
0
def test_basic():
    with temp_conf({}) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF_FILE'] = fn
        with server(env=env, wait=5000):
            r = requests.get('http://localhost:5000/v1/info')
            assert r.ok
    with temp_conf({}) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF'] = os.path.dirname(fn)
        with server(env=env, wait=5000):
            r = requests.get('http://localhost:5000/v1/info')
            assert r.ok
    with temp_conf({}) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF'] = os.path.dirname(fn) + ":/nonexistent"
        with server(env=env, wait=5000):
            r = requests.get('http://localhost:5000/v1/info')
            assert r.ok
Esempio n. 12
0
def test_load_conf(conf):
    # This test will only work if your config is set to default
    inconf = config.defaults.copy()
    expected = inconf.copy()
    with temp_conf(conf) as fn:
        config.load_conf(fn)
        expected.update(conf)
        assert config.conf == expected
        config.reset_conf()
        assert config.conf == inconf
Esempio n. 13
0
def test_load_conf(conf):
    # This test will only work if your config is set to default
    inconf = defaults.copy()
    expected = inconf.copy()
    with temp_conf(conf) as fn:
        config = Config(fn)
        config.load(fn)
        expected.update(conf)
        assert dict(config) == expected
        config.reset()
        assert dict(config) == inconf
Esempio n. 14
0
def test_persist_modes():
    expected_never = "never"
    expected_default = "default"

    with temp_conf({}) as fn:
        env = os.environ.copy()
        env["INTAKE_CONF_FILE"] = fn
        with server(args=("-p", "5555"), env=env, wait=5555):
            cat_never = RemoteCatalog("intake://localhost:5555",
                                      persist_mode="never")
            assert cat_never.pmode == expected_never

            cat_default = RemoteCatalog("intake://localhost:5555")
            assert cat_default.pmode == expected_default
Esempio n. 15
0
def test_conf_auth():
    with temp_conf({'auth': {'class': 'intake.auth.secret.SecretAuth',
                             'kwargs': {'secret': 'test'}}}) as fn:
        env = os.environ.copy()
        env['INTAKE_CONF_FILE'] = fn
        with server(env=env, wait=5000):
            # raw request
            r = requests.get('http://localhost:5000/v1/info')
            assert r.status_code == 403
            r = requests.get('http://localhost:5000/v1/info',
                             headers={'intake-secret': 'test'})
            assert r.ok

            # with cat
            with pytest.raises(Exception):
                intake.Catalog('intake://localhost:5000')

            cat = intake.Catalog('intake://localhost:5000',
                                 storage_options={'headers':
                                                  {'intake-secret': 'test'}})
            assert 'entry1' in cat