@@ -105,7 +105,7 @@ def test_nlu_invalid_payload(client):
105105 """"""
106106
107107 body = json .dumps (
108- {"not_messages " : [] }, separators = ("," , ":" ), sort_keys = True
108+ {"messages " : "not-a-list" }, separators = ("," , ":" ), sort_keys = True
109109 ).encode ()
110110 signature = _sign_payload (body , app .config ["TURN_HMAC_SECRET" ])
111111
@@ -117,3 +117,31 @@ def test_nlu_invalid_payload(client):
117117 )
118118 assert response .status_code == 400
119119 assert response .json ["error" ] == "invalid payload"
120+
121+
122+ def test_nlu_status_only_payload_is_ignored (client , mocker ):
123+ """Status webhooks should be accepted and ignored."""
124+
125+ mock_build_chain = mocker .patch ("src.application.build_classify_and_update_chain" )
126+
127+ payload = {
128+ "statuses" : [
129+ {
130+ "id" : "wamid.HBgLMjc4MzYzNzg1MzEVAgARGBI2QTBBOTM1MDdFNUEwRDJDOEMA" ,
131+ "status" : "delivered" ,
132+ "timestamp" : "1773842339" ,
133+ }
134+ ]
135+ }
136+ body = json .dumps (payload , separators = ("," , ":" ), sort_keys = True ).encode ()
137+ signature = _sign_payload (body , app .config ["TURN_HMAC_SECRET" ])
138+
139+ response = client .post (
140+ "/nlu/" ,
141+ data = body ,
142+ content_type = "application/json" ,
143+ headers = {"X-Turn-Hook-Signature" : signature },
144+ )
145+ assert response .status_code == 200
146+ assert response .json == {"status" : "ignored" , "count" : 0 }
147+ mock_build_chain .assert_not_called ()
0 commit comments