fix(shangwutong): close contact sync review gaps (#4)
Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -771,6 +771,20 @@ func TestWidgetHandler_Cov3_PublicCreateContact_Success_Cov3(t *testing.T) {
|
||||
assert.Equal(t, "New Contact", resp["name"])
|
||||
}
|
||||
|
||||
func TestWidgetHandler_PublicContactIgnoresCID(t *testing.T) {
|
||||
db, router, _ := setupWidgetHandlerTest(t)
|
||||
_, _, channelAPI := seedPublicAPIInbox(t, db)
|
||||
body, _ := json.Marshal(map[string]any{"name": "Visitor", "source_id": "visitor", "channel_metadata": map[string]any{"cid": "forged"}})
|
||||
w := httptest.NewRecorder()
|
||||
req, _ := http.NewRequest(http.MethodPost, "/public/api/v1/inboxes/"+channelAPI.Identifier+"/contacts", bytes.NewReader(body))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
router.ServeHTTP(w, req)
|
||||
require.Equal(t, http.StatusOK, w.Code, w.Body.String())
|
||||
var contactInbox model.ContactInbox
|
||||
require.NoError(t, db.Where("source_id = ?", "visitor").First(&contactInbox).Error)
|
||||
assert.NotContains(t, string(contactInbox.ChannelMetadata), "forged")
|
||||
}
|
||||
|
||||
func TestWidgetHandler_Cov3_PublicUpdateContact_Success_Cov3(t *testing.T) {
|
||||
db, router, _ := setupWidgetHandlerTest(t)
|
||||
_, _, channelAPI := seedPublicAPIInbox(t, db)
|
||||
|
||||
Reference in New Issue
Block a user