feat(order): 展示上传联系电话并隔离用户端快照
This commit is contained in:
@@ -44,6 +44,70 @@ func TestOrderDTOForUserHidesDepositHoldFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminOrderDTOIncludesUploadContactPhone(t *testing.T) {
|
||||
row := orderRow{
|
||||
RentalOrder: model.RentalOrder{
|
||||
ID: 1,
|
||||
AccountSnapshot: datatypes.JSON([]byte(`{
|
||||
"asset_summary":{
|
||||
"import_meta":{
|
||||
"uploader_name":"客服1",
|
||||
"contact_phone":"15196354603"
|
||||
}
|
||||
}
|
||||
}`)),
|
||||
},
|
||||
}
|
||||
|
||||
dto := row.toAdminDTO()
|
||||
if dto.UploadContactPhone != "15196354603" {
|
||||
t.Fatalf("upload contact phone = %q", dto.UploadContactPhone)
|
||||
}
|
||||
raw, err := json.Marshal(dto)
|
||||
if err != nil {
|
||||
t.Fatalf("Marshal() error = %v", err)
|
||||
}
|
||||
if !strings.Contains(string(raw), `"upload_contact_phone":"15196354603"`) {
|
||||
t.Fatalf("admin response missing upload contact phone: %s", raw)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserOrderDTOHidesUploadContactPhone(t *testing.T) {
|
||||
row := orderRow{
|
||||
RentalOrder: model.RentalOrder{
|
||||
ID: 1,
|
||||
OwnerID: 10,
|
||||
RenterID: 20,
|
||||
AccountSnapshot: datatypes.JSON([]byte(`{
|
||||
"asset_summary":{
|
||||
"haf_coin_amount":108000000,
|
||||
"import_meta":{
|
||||
"uploader_name":"客服1",
|
||||
"contact_phone":"15196354603"
|
||||
}
|
||||
}
|
||||
}`)),
|
||||
},
|
||||
}
|
||||
|
||||
for _, userID := range []uint64{row.OwnerID, row.RenterID} {
|
||||
dto := row.toDTOForUser(userID)
|
||||
if dto.UploadContactPhone != "" {
|
||||
t.Fatalf("user %d upload contact phone = %q, want empty", userID, dto.UploadContactPhone)
|
||||
}
|
||||
raw, err := json.Marshal(dto)
|
||||
if err != nil {
|
||||
t.Fatalf("Marshal() error = %v", err)
|
||||
}
|
||||
text := string(raw)
|
||||
for _, forbidden := range []string{"15196354603", "import_meta", "upload_contact_phone"} {
|
||||
if strings.Contains(text, forbidden) {
|
||||
t.Fatalf("user %d response contains forbidden %q: %s", userID, forbidden, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserOrderListItemDoesNotSerializeDetailFields(t *testing.T) {
|
||||
row := orderRow{
|
||||
RentalOrder: model.RentalOrder{
|
||||
|
||||
Reference in New Issue
Block a user