Skip to content

feat: add proxy and CA certificate support#30

Merged
chonknick merged 6 commits into
mainfrom
agent/proxy-ca-cert-support
Feb 20, 2026
Merged

feat: add proxy and CA certificate support#30
chonknick merged 6 commits into
mainfrom
agent/proxy-ca-cert-support

Conversation

@chonknick

Copy link
Copy Markdown
Contributor

Adds proxy and CA certificate support to the catsu client.

Changes

  • HttpConfig: add proxy and CA certificate fields
  • Python client: add proxy and ca_cert parameters
  • Add tests for proxy and CA certificate functionality

Commits

  • feat: add proxy and CA certificate support to HttpConfig
  • feat(python): add proxy and ca_cert params to Client
  • test(python): add tests for proxy and ca_cert params

Add two new optional fields to HttpConfig:
- proxy: HTTP/HTTPS proxy URL
- ca_cert_pem: PEM-encoded CA certificate string

Update HttpClient::new() to configure reqwest with proxy and
custom root certificate when provided.
Expose proxy and ca_cert parameters in the Python Client constructor,
allowing corporate users to configure HTTP proxy and custom CA certs.
Test that Client constructor accepts proxy URL and CA certificate
parameters without panicking.
Copilot AI review requested due to automatic review settings February 20, 2026 09:54
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Feb 20, 2026

Copy link
Copy Markdown

Deploying catsu with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5b334d6
Status: ✅  Deploy successful!
Preview URL: https://aff01f7f.catsu-3ib.pages.dev
Branch Preview URL: https://agent-proxy-ca-cert-support.catsu-3ib.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Feb 20, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
catsu-docs 5b334d6 Commit Preview URL

Branch Preview URL
Feb 20 2026, 10:19 AM

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds proxy and CA certificate support to the catsu HTTP client, enabling users to configure custom proxies and certificate authorities for corporate environments or special network configurations. The changes are implemented at both the Rust core level and exposed through the Python bindings.

Changes:

  • Added proxy and ca_cert_pem fields to HttpConfig struct
  • Implemented proxy and CA certificate configuration in HttpClient::new using reqwest
  • Added Python binding parameters proxy and ca_cert to the Client.__init__ method
  • Added basic tests for configuration and error handling

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/http.rs Added proxy and ca_cert_pem fields to HttpConfig, implemented builder pattern to configure reqwest client, added basic tests for config storage
packages/python/src/lib.rs Added proxy and ca_cert parameters to Python Client constructor, mapped them to HttpConfig fields
packages/python/tests/test_client.py Added tests for proxy parameter acceptance, invalid CA certificate handling, valid CA certificate format, and combined options
Comments suppressed due to low confidence (3)

packages/python/src/lib.rs:184

  • The conditional assignments for proxy and ca_cert can be simplified. These unnecessary checks add verbosity without benefit since Option::is_some() followed by assignment is equivalent to direct assignment. Consider simplifying to:
config.proxy = proxy;
config.ca_cert_pem = ca_cert;

This matches the pattern used for max_retries and timeout above and is more concise.

        if proxy.is_some() {
            config.proxy = proxy;
        }
        if ca_cert.is_some() {
            config.ca_cert_pem = ca_cert;
        }

packages/python/tests/test_client.py:18

  • Consider adding a test for invalid proxy URL handling to match the invalid CA certificate test. This would ensure proper error handling and propagation through the Python bindings when an invalid proxy URL is provided, such as:
def test_client_with_invalid_proxy():
    from catsu import Client
    with pytest.raises(RuntimeError):
        Client(proxy="not a valid url")
def test_client_with_invalid_ca_cert():
    """Test that Client raises an error for invalid CA certificate."""
    from catsu import Client

    with pytest.raises(RuntimeError):
        Client(ca_cert="not a valid certificate")

packages/python/tests/test_client.py:36

  • The test certificate appears to have repeating placeholder data in the key and signature fields (e.g., "JJ8J8J6jJJ8J..." repeated). While this makes the test more readable as a placeholder, it would be more robust to use an actual minimal valid self-signed certificate to ensure the test accurately reflects real-world usage. The current certificate may fail parsing in ways that don't match how real certificates would fail.
    test_cert = """-----BEGIN CERTIFICATE-----
MIIBkTCB+wIJAKHBfpegPjMCMA0GCSqGSIb3DQEBCwUAMBExDzANBgNVBAMMBnVu
dXNlZDAeFw0yMzAxMDEwMDAwMDBaFw0yNDAxMDEwMDAwMDBaMBExDzANBgNVBAMM
BnVudXNlZDBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC6fGQKtQ3u3tLGDNnM8Jv2
vHNJJnKJkf8J8J6jJJ8J8J6jJJ8J8J6jJJ8J8J6jJJ8J8J6jJJ8J8J6jJJ8J8J6j
AgMBAAEwDQYJKoZIhvcNAQELBQADQQBN6V7t8Hy8cWJxmXNvh8J6jJJ8J8J6jJJ8
J8J6jJJ8J8J6jJJ8J8J6jJJ8J8J6jJJ8J8J6jJJ8J8J6jJJ8J8J6
-----END CERTIFICATE-----"""

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/http.rs
Comment on lines +196 to +213
#[test]
fn test_config_with_proxy_and_ca_cert() {
let config = HttpConfig {
proxy: Some("http://proxy.example.com:8080".to_string()),
ca_cert_pem: Some(
"-----BEGIN CERTIFICATE-----\ntest\n-----END CERTIFICATE-----".to_string(),
),
..HttpConfig::default()
};
assert_eq!(
config.proxy,
Some("http://proxy.example.com:8080".to_string())
);
assert!(config.ca_cert_pem.is_some());
assert!(config.ca_cert_pem.unwrap().contains("BEGIN CERTIFICATE"));
}

#[test]

Copilot AI Feb 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Rust tests only verify configuration storage but don't test actual HttpClient construction with proxy and CA certificate. Consider adding a test that constructs an HttpClient with these configurations to ensure they are properly applied to the underlying reqwest client:

#[test]
fn test_http_client_with_proxy() {
    let config = HttpConfig {
        proxy: Some("http://proxy.example.com:8080".to_string()),
        ..HttpConfig::default()
    };
    let client = HttpClient::new(config);
    assert!(client.is_ok());
}

This would catch any issues with the builder pattern or reqwest integration.

Copilot uses AI. Check for mistakes.
…n test

- Use filter to skip empty strings for proxy and ca_cert params
- Remove redundant is_some() guards
- Document that reqwest respects HTTP_PROXY/HTTPS_PROXY env vars when proxy=None
- Add HttpClient::new() test to verify proxy config works at runtime
@chonknick
chonknick merged commit 55c094e into main Feb 20, 2026
10 checks passed
@chonknick
chonknick deleted the agent/proxy-ca-cert-support branch February 20, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants