-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathredact_test.go
More file actions
60 lines (50 loc) · 1.71 KB
/
redact_test.go
File metadata and controls
60 lines (50 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package csapi_tests
import (
"testing"
"github.com/matrix-org/complement"
"github.com/matrix-org/complement/b"
"github.com/matrix-org/complement/helpers"
"github.com/matrix-org/complement/match"
"github.com/matrix-org/complement/must"
)
// Test `PUT /_matrix/client/v3/rooms/{roomId}/redact/{eventId}/{txnId} ` (redactions)
func TestRedact(t *testing.T) {
deployment := complement.Deploy(t, 1)
defer deployment.Destroy(t)
alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{
LocalpartSuffix: "alice",
})
bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{
LocalpartSuffix: "bob",
})
// Alice creates the room
roomID := alice.MustCreateRoom(t, map[string]interface{}{
// Just making it easier for everyone to join
"preset": "public_chat",
})
// Bob joins the room
bob.MustJoinRoom(t, roomID, nil)
t.Run("Event content is redacted", func(t *testing.T) {
// Alice creates an event
expectedEventContent := map[string]interface{}{
"msgtype": "m.text",
"body": "expected message body",
}
eventIDToRedact := alice.SendEventSynced(t, roomID, b.Event{
Type: "m.room.message",
Content:expectedEventContent,
})
// Bob can see the event content
eventJsonBefore := bob.MustGetEvent(t, roomID, eventIDToRedact)
must.MatchGJSON(t, eventJsonBefore, match.JSONKeyEqual("content", expectedEventContent))
// Alice redacts the event
alice.MustSendRedaction(t, roomID, map[string]interface{}{
"reason": "reasons...",
}, eventIDToRedact)
// Bob can no longer see the event content
eventJsonAfter := bob.MustGetEvent(t, roomID, eventIDToRedact)
must.MatchGJSON(t, eventJsonAfter, match.JSONKeyEqual("content", map[string]interface{}{
// no content
}))
})
}