-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test case reproducing matrix-org/synapse#5677 for local users #199
Changes from 2 commits
cd709e8
05d148a
877f6a1
8209286
07afbaa
75ef397
68cf89a
ce8f3a9
ed7d66e
5435622
6ce2fc4
26aad20
9f4b9a0
a2e0d06
b10655f
b52c712
c95b011
d650c5a
815cf7b
4c95d45
ef171f3
707b530
2b4609a
700e300
56bf3e3
c0b3ecd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// +build !synapse_blacklist | ||
|
||
// Rationale for being included in Synapse's blacklist: https://github.com/matrix-org/synapse/issues/5677 | ||
package csapi_tests | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/matrix-org/complement/internal/b" | ||
"github.com/matrix-org/complement/internal/match" | ||
"github.com/matrix-org/complement/internal/must" | ||
) | ||
|
||
func TestRoomSpecificUsernameNotLeaked(t *testing.T) { | ||
// Reproduces https://github.com/matrix-org/synapse/issues/5677 | ||
// In that bug report, Alice has revealed a private name to a friend X, | ||
// and Bob can see that private name when he shouldn't be able to. | ||
// I've tweaked the names to be more traditional: Alice reveals a private name | ||
// to Bob, and Eve shouldn't be able to see that name. | ||
deployment := Deploy(t, b.BlueprintAlice) | ||
defer deployment.Destroy(t) | ||
|
||
alice := deployment.Client(t, "hs1", "@alice:hs1") | ||
bob := deployment.RegisterUser(t, "hs1", "bob", "bob-pw") | ||
eve := deployment.RegisterUser(t, "hs1", "eve", "eve-pw") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These passwords will be too short for some servers, which is probably why it 400s on Dendrite. |
||
|
||
t.Run("Usernames specific to a room aren't leaked in the user directory", func(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no real need to do this as a subtest, unless you plan to add more tests around username leaks? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fair. Could add one for avatar leaks too perhaps. |
||
// Bob creates a new room and invites Alice. She accepts. | ||
privateRoom := bob.CreateRoom(t, map[string]interface{}{ | ||
"m.federate": false, | ||
}) | ||
bob.InviteRoom(t, privateRoom, "@alice:hs1") | ||
DMRobertson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
alice.JoinRoom(t, privateRoom, nil) | ||
DMRobertson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Alice reveals her private name to Bob | ||
alice.MustDo( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do, thanks. Mind if I mark There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup! |
||
t, | ||
"PUT", | ||
[]string{"_matrix", "client", "r0", "rooms", privateRoom, "state", "m.room.member", | ||
"@alice:hs1"}, | ||
map[string]interface{}{ | ||
"displayname": "Alice Cooper", | ||
"membership": "join", | ||
}, | ||
) | ||
|
||
// Eve looks up alice in the directory using her public name | ||
res := eve.MustDo( | ||
t, | ||
"POST", | ||
[]string{"_matrix", "client", "r0", "user_directory", "search"}, | ||
map[string]interface{}{ | ||
"search_term": "alice", | ||
}, | ||
) | ||
|
||
must.MatchResponse(t, res, match.HTTPResponse{ | ||
DMRobertson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
JSON: []match.JSON{ | ||
match.JSONKeyEqual("results.0.display_name", "alice"), | ||
match.JSONKeyEqual("results.0.user_id", "@alice:hs1"), | ||
}, | ||
}) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably don't want this on Synapse's blacklist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking was that I wouldn't want synapse CI to suddenly light up red. But maybe your point is "it should do!"