Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for connecting via proxy #140

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions test/integration/proxy_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import pytest
import pyexasol
import subprocess
import platform


@pytest.fixture
def proxy_port():
yield 8562


@pytest.fixture
def proxy(proxy_port):
os_specific_flags = ["--reuse"] if platform.system() == "Linux" else []
command = ["pproxy", "-l", f"http://:{proxy_port}/"] + os_specific_flags
pproxy = subprocess.Popen(command)

yield f"http://127.0.0.1:{proxy_port}"

pproxy.kill()


@pytest.fixture
def proxy_user():
yield "johndoe"


@pytest.fixture
def proxy_password():
yield "JohndoesPassword"


@pytest.fixture
def proxy_with_auth(proxy_port, proxy_user, proxy_password):
os_specific_flags = ["--reuse"] if platform.system() == "Linux" else []
command = [
"pproxy",
"-l",
f"http://:{proxy_port}/#{proxy_user}:{proxy_password}",
] + os_specific_flags
pproxy = subprocess.Popen(command)

yield f"http://{proxy_user}:{proxy_password}@localhost:{proxy_port}"

pproxy.kill()


@pytest.mark.configuration
def test_connect_through_proxy(dsn, user, password, schema, proxy):
with pyexasol.connect(
dsn=dsn, user=user, password=password, schema=schema, http_proxy=proxy
) as connection:
result = connection.execute("SELECT 1;")
expected = 1
actual = result.fetchval()
assert expected == actual


@pytest.mark.configuration
def test_connect_through_proxy_with_authentication(
dsn, user, password, schema, proxy_with_auth
):
with pyexasol.connect(
dsn=dsn, user=user, password=password, schema=schema, http_proxy=proxy_with_auth
) as connection:
result = connection.execute("SELECT 1;")
expected = 1
actual = result.fetchval()
assert expected == actual
Loading