Home / Class/ TestUrlAuthEdgeCases Class — langchain Architecture

TestUrlAuthEdgeCases Class — langchain Architecture

Architecture documentation for the TestUrlAuthEdgeCases class in test_auth.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b78a5e1c_0cac_9659_7fb9_742773fc11cc["TestUrlAuthEdgeCases"]
  24ba4b1a_1f94_bed7_6c96_5631284214c2["test_auth.py"]
  b78a5e1c_0cac_9659_7fb9_742773fc11cc -->|defined in| 24ba4b1a_1f94_bed7_6c96_5631284214c2
  6e203bfb_a9b4_c376_4b04_b1e6ab5c4cf3["test_parse_url_with_auth_malformed_url()"]
  b78a5e1c_0cac_9659_7fb9_742773fc11cc -->|method| 6e203bfb_a9b4_c376_4b04_b1e6ab5c4cf3
  febc02ff_0bcc_356c_d3d8_f78f36507ed1["test_parse_url_with_auth_no_port()"]
  b78a5e1c_0cac_9659_7fb9_742773fc11cc -->|method| febc02ff_0bcc_356c_d3d8_f78f36507ed1
  a6a56fb9_eec9_40dc_5f0d_6c3b10b2dad8["test_parse_url_with_auth_complex_password()"]
  b78a5e1c_0cac_9659_7fb9_742773fc11cc -->|method| a6a56fb9_eec9_40dc_5f0d_6c3b10b2dad8

Relationship Graph

Source Code

libs/partners/ollama/tests/unit_tests/test_auth.py lines 197–231

class TestUrlAuthEdgeCases:
    """Test edge cases and error conditions for URL authentication."""

    def test_parse_url_with_auth_malformed_url(self) -> None:
        """Test behavior with malformed URLs."""
        malformed_url = "not-a-valid-url"
        result = parse_url_with_auth(malformed_url)
        # Shouldn't return a URL as it wouldn't parse correctly or reach a server
        assert result == (None, None)

    def test_parse_url_with_auth_no_port(self) -> None:
        """Test URLs without explicit port numbers."""
        url = "https://user:password@ollama.example.com"
        cleaned_url, headers = parse_url_with_auth(url)

        expected_url = "https://ollama.example.com"
        expected_credentials = base64.b64encode(b"user:password").decode()
        expected_headers = {"Authorization": f"Basic {expected_credentials}"}

        assert cleaned_url == expected_url
        assert headers == expected_headers

    def test_parse_url_with_auth_complex_password(self) -> None:
        """Test with complex passwords containing special characters."""
        # Test password with colon, which is the delimiter
        url = "https://user:pass:word@ollama.example.com:11434"
        cleaned_url, headers = parse_url_with_auth(url)

        expected_url = "https://ollama.example.com:11434"
        # The parser should handle the first colon as the separator
        expected_credentials = base64.b64encode(b"user:pass:word").decode()
        expected_headers = {"Authorization": f"Basic {expected_credentials}"}

        assert cleaned_url == expected_url
        assert headers == expected_headers

Frequently Asked Questions

What is the TestUrlAuthEdgeCases class?
TestUrlAuthEdgeCases is a class in the langchain codebase, defined in libs/partners/ollama/tests/unit_tests/test_auth.py.
Where is TestUrlAuthEdgeCases defined?
TestUrlAuthEdgeCases is defined in libs/partners/ollama/tests/unit_tests/test_auth.py at line 197.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free