@@ -76,6 +76,44 @@ async def test_uses_provided_secret_and_no_url_without_base(self, monkeypatch):
7676 assert resp .webhook_url is None # no AGENTEX_PUBLIC_URL configured
7777 assert resp .webhook_path == "/agents/forward/name/a/gh"
7878
79+ async def test_github_empty_secret_is_preserved (self , monkeypatch ):
80+ req = CreateWebhookTriggerRequest (
81+ agent_name = "a" ,
82+ source = AgentAPIKeyType .GITHUB ,
83+ name = "o/r" ,
84+ forward_path = "gh" ,
85+ secret = "" ,
86+ )
87+ resp , akuc = await self ._call (monkeypatch , req )
88+ assert resp .secret == ""
89+ assert akuc .create .await_args .kwargs ["api_key" ] == ""
90+
91+ async def test_forward_path_reserved_chars_are_url_encoded (self , monkeypatch ):
92+ req = CreateWebhookTriggerRequest (
93+ agent_name = "golden agent" ,
94+ source = AgentAPIKeyType .GITHUB ,
95+ name = "o/r" ,
96+ forward_path = "github-pr/cfg-9?mode=review#frag ment" ,
97+ )
98+ resp , _ = await self ._call (monkeypatch , req , base_env = "https://sgp.example.com/" )
99+
100+ assert (
101+ resp .webhook_path
102+ == "/agents/forward/name/golden%20agent/github-pr/cfg-9%3Fmode%3Dreview%23frag%20ment"
103+ )
104+ assert resp .webhook_url == f"https://sgp.example.com{ resp .webhook_path } "
105+
106+ async def test_forward_path_control_chars_rejected (self , monkeypatch ):
107+ req = CreateWebhookTriggerRequest (
108+ agent_name = "a" ,
109+ source = AgentAPIKeyType .GITHUB ,
110+ name = "o/r" ,
111+ forward_path = "github-pr/cfg-9\n next" ,
112+ )
113+ with pytest .raises (HTTPException ) as exc :
114+ await self ._call (monkeypatch , req )
115+ assert exc .value .status_code == 400
116+
79117 async def test_conflict_when_key_exists (self , monkeypatch ):
80118 req = CreateWebhookTriggerRequest (
81119 agent_name = "a" , source = AgentAPIKeyType .GITHUB , name = "o/r" , forward_path = "gh"
@@ -118,3 +156,11 @@ async def test_slack_with_provided_secret_ok(self, monkeypatch):
118156 resp , akuc = await self ._call (monkeypatch , req )
119157 assert resp .secret == "slack-signing-secret"
120158 assert akuc .create .await_args .kwargs ["api_key" ] == "slack-signing-secret"
159+
160+ async def test_secret_schema_documents_slack_requirement (self ):
161+ description = CreateWebhookTriggerRequest .model_fields ["secret" ].description
162+
163+ assert description is not None
164+ assert "For GitHub" in description
165+ assert "For Slack" in description
166+ assert "required" in description
0 commit comments