コード例 #1
0
ファイル: test_without_sni.py プロジェクト: totem/yoda-proxy
def test_proxy_with_multiple_locations():
    with CleanupEtcdFolders(
            ['/upstreams/test-multiple-loc',
             '/global/acls/test-multiple-loc-acl1',
             '/hosts/test-multiple-loc.abc.com']):
        with MockHttpServer() as node1:
            _add_node('test-multiple-loc', 'node1', node1)
            _add_acl('test-multiple-loc-acl1', '255.255.255.255/32')
            _add_location('test-multiple-loc.abc.com',
                          'test-multiple-loc', path='/', location_name='-',
                          allowed_acls={'a1': 'test-multiple-loc-acl1'})
            _add_location('test-multiple-loc.abc.com',
                          'test-multiple-loc', path='/secure',
                          location_name='secure',
                          allowed_acls={'public': 'public'})
            # Wait for sometime changes to apply
            sleep(PROXY_REFRESH_TIME)

            # When I access secure path
            resp = _request_proxy('test-multiple-loc.abc.com', path='/secure')

            # Then:  Access is granted (but 404 is returned as page does not
            # exist)
            assert_equals(resp.status_code, 404)

            # When I access un-seure path
            resp = _request_proxy('test-multiple-loc.abc.com', path='/')

            # Then:  Access is denied (No acl to allow this path)
            assert_equals(resp.status_code, 403)
コード例 #2
0
ファイル: test_without_sni.py プロジェクト: totem/yoda-proxy
def test_proxy_with_allowed_acls():
    with CleanupEtcdFolders(
            ['/upstreams/test-allowed-acl', '/global/acls/test-allowed-acl',
             '/hosts/test-allowed-acl.abc.com']):
        with MockHttpServer() as node1:
            _add_node('test-allowed-acl', 'node1', node1)
            _add_acl('test-allowed-acl', '255.255.255.255/32')
            _add_location('test-allowed-acl.abc.com', 'test-allowed-acl',
                          allowed_acls={'a1': 'test-allowed-acl'})
            # Wait for sometime changes to apply
            sleep(PROXY_REFRESH_TIME)

            resp = _request_proxy('test-allowed-acl.abc.com')
            assert_equals(resp.status_code, 403)