Home / Class/ TestDictTopLevel Class — langchain Architecture

TestDictTopLevel Class — langchain Architecture

Architecture documentation for the TestDictTopLevel class in test_secret_injection.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5e2e27e7_826a_be31_1e0d_c526e9b911e2["TestDictTopLevel"]
  269160d8_4621_760e_4f43_8de24a47bd7c["test_secret_injection.py"]
  5e2e27e7_826a_be31_1e0d_c526e9b911e2 -->|defined in| 269160d8_4621_760e_4f43_8de24a47bd7c
  e8674169_ba33_65b1_116d_549ba9694fc7["test_dict_with_serializable_containing_secret()"]
  5e2e27e7_826a_be31_1e0d_c526e9b911e2 -->|method| e8674169_ba33_65b1_116d_549ba9694fc7
  251e8177_9e59_8285_bfbd_9ac4fa101037["test_dict_with_secret_no_serializable()"]
  5e2e27e7_826a_be31_1e0d_c526e9b911e2 -->|method| 251e8177_9e59_8285_bfbd_9ac4fa101037
  d6af95e5_6077_9253_e4db_419d37805b34["test_dict_with_nested_secret_no_serializable()"]
  5e2e27e7_826a_be31_1e0d_c526e9b911e2 -->|method| d6af95e5_6077_9253_e4db_419d37805b34
  7c5ac731_dccb_125d_4417_c5d68020a7bf["test_dict_with_secret_in_list()"]
  5e2e27e7_826a_be31_1e0d_c526e9b911e2 -->|method| 7c5ac731_dccb_125d_4417_c5d68020a7bf
  b2b64942_dfa8_edb2_ba15_323062960db1["test_dict_mimicking_lc_constructor_with_secret()"]
  5e2e27e7_826a_be31_1e0d_c526e9b911e2 -->|method| b2b64942_dfa8_edb2_ba15_323062960db1

Relationship Graph

Source Code

libs/core/tests/unit_tests/load/test_secret_injection.py lines 131–169

class TestDictTopLevel:
    """Tests with plain dicts at the top level."""

    def test_dict_with_serializable_containing_secret(self) -> None:
        """Dict containing a `Serializable` with secret-like dict."""
        msg = HumanMessage(
            content="Hello",
            additional_kwargs={"data": MALICIOUS_SECRET_DICT},
        )
        payload = {"message": msg}
        _assert_no_secret_leak(payload)

    def test_dict_with_secret_no_serializable(self) -> None:
        """Dict with secret-like dict, no `Serializable` objects."""
        payload = {"data": MALICIOUS_SECRET_DICT}
        _assert_no_secret_leak(payload)

    def test_dict_with_nested_secret_no_serializable(self) -> None:
        """Dict with nested secret-like dict, no `Serializable` objects."""
        payload = {"outer": {"inner": MALICIOUS_SECRET_DICT}}
        _assert_no_secret_leak(payload)

    def test_dict_with_secret_in_list(self) -> None:
        """Dict with secret-like dict in a list."""
        payload = {"items": [MALICIOUS_SECRET_DICT]}
        _assert_no_secret_leak(payload)

    def test_dict_mimicking_lc_constructor_with_secret(self) -> None:
        """Dict that looks like an LC constructor containing a secret."""
        payload = {
            "lc": 1,
            "type": "constructor",
            "id": ["langchain_core", "messages", "ai", "AIMessage"],
            "kwargs": {
                "content": "Hello",
                "additional_kwargs": {"secret": MALICIOUS_SECRET_DICT},
            },
        }
        _assert_no_secret_leak(payload)

Frequently Asked Questions

What is the TestDictTopLevel class?
TestDictTopLevel is a class in the langchain codebase, defined in libs/core/tests/unit_tests/load/test_secret_injection.py.
Where is TestDictTopLevel defined?
TestDictTopLevel is defined in libs/core/tests/unit_tests/load/test_secret_injection.py at line 131.

Analyze Your Own Codebase

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

Try Supermodel Free