Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03deb8d9aa |
@@ -1240,9 +1240,7 @@ func TestIntegrationModeModerated(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestIntegrationModeKey checks that JOIN takes the key of
|
// TestIntegrationModeKey checks that JOIN takes the key of
|
||||||
// a +k channel as its second parameter, and that with
|
// a +k channel as its second parameter.
|
||||||
// several channels each key goes to the channel in the
|
|
||||||
// same position.
|
|
||||||
func TestIntegrationModeKey(t *testing.T) {
|
func TestIntegrationModeKey(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -1251,25 +1249,19 @@ func TestIntegrationModeKey(t *testing.T) {
|
|||||||
alice := env.dial(t)
|
alice := env.dial(t)
|
||||||
alice.register("alice")
|
alice.register("alice")
|
||||||
alice.joinAndDrain("#keyed")
|
alice.joinAndDrain("#keyed")
|
||||||
alice.joinAndDrain("#vault")
|
|
||||||
|
|
||||||
// The IRC listener cannot set +k, so the test sets the
|
// The IRC listener cannot set +k, so the test sets the
|
||||||
// keys directly.
|
// key directly.
|
||||||
for channel, key := range map[string]string{
|
chID, err := env.database.GetChannelByName(
|
||||||
"#keyed": "sesame",
|
t.Context(), "#keyed",
|
||||||
"#vault": "barley",
|
)
|
||||||
} {
|
if err != nil {
|
||||||
chID, err := env.database.GetChannelByName(
|
t.Fatalf("get channel: %v", err)
|
||||||
t.Context(), channel,
|
}
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("get channel %s: %v", channel, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = env.database.SetChannelKey(t.Context(), chID, key)
|
err = env.database.SetChannelKey(t.Context(), chID, "sesame")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("set key of %s: %v", channel, err)
|
t.Fatalf("set channel key: %v", err)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bob := env.dial(t)
|
bob := env.dial(t)
|
||||||
@@ -1282,16 +1274,6 @@ func TestIntegrationModeKey(t *testing.T) {
|
|||||||
assertContains(
|
assertContains(
|
||||||
t, lines, "JOIN #keyed", "bob joins with the key",
|
t, lines, "JOIN #keyed", "bob joins with the key",
|
||||||
)
|
)
|
||||||
|
|
||||||
carol := env.dial(t)
|
|
||||||
carol.register("carol")
|
|
||||||
|
|
||||||
lines = carol.sendAndExpect(
|
|
||||||
"JOIN #keyed,#vault sesame,barley", " 366 carol #vault ",
|
|
||||||
)
|
|
||||||
assertContains(t, lines, "JOIN #keyed", "carol joins #keyed")
|
|
||||||
assertContains(t, lines, "JOIN #vault", "carol joins #vault")
|
|
||||||
assertNotContains(t, lines, " 475 ", "carol's JOIN")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestIntegrationModeInviteOnly checks that INVITE lets a
|
// TestIntegrationModeInviteOnly checks that INVITE lets a
|
||||||
@@ -1319,58 +1301,6 @@ func TestIntegrationModeInviteOnly(t *testing.T) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestIntegrationModeInviteOnlyNeedsOperator checks that on
|
|
||||||
// a +i channel an INVITE from a member who is not a channel
|
|
||||||
// operator gets 482 and does not let the invited user in.
|
|
||||||
func TestIntegrationModeInviteOnlyNeedsOperator(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
env := newTestEnv(t)
|
|
||||||
|
|
||||||
alice := env.dial(t)
|
|
||||||
alice.register("alice")
|
|
||||||
alice.joinAndDrain("#invonly")
|
|
||||||
|
|
||||||
// Bob joins before +i is set, so he is a member but
|
|
||||||
// not an operator.
|
|
||||||
bob := env.dial(t)
|
|
||||||
bob.register("bob")
|
|
||||||
bob.joinAndDrain("#invonly")
|
|
||||||
|
|
||||||
alice.sendAndExpect("MODE #invonly +i", "+i")
|
|
||||||
|
|
||||||
carol := env.dial(t)
|
|
||||||
carol.register("carol")
|
|
||||||
|
|
||||||
lines := bob.sendAndExpect("INVITE carol #invonly", " 482 ")
|
|
||||||
assertContains(
|
|
||||||
t, lines, " 482 bob #invonly ", "bob's INVITE refused",
|
|
||||||
)
|
|
||||||
|
|
||||||
carol.sendAndExpect("JOIN #invonly", " 473 ")
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestIntegrationInviteUserOnChannel checks that inviting a
|
|
||||||
// user who is already on the channel gets 443.
|
|
||||||
func TestIntegrationInviteUserOnChannel(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
env := newTestEnv(t)
|
|
||||||
|
|
||||||
alice := env.dial(t)
|
|
||||||
alice.register("alice")
|
|
||||||
alice.joinAndDrain("#room")
|
|
||||||
|
|
||||||
bob := env.dial(t)
|
|
||||||
bob.register("bob")
|
|
||||||
bob.joinAndDrain("#room")
|
|
||||||
|
|
||||||
lines := alice.sendAndExpect("INVITE bob #room", " 443 ")
|
|
||||||
assertContains(
|
|
||||||
t, lines, " 443 alice bob #room ", "alice's INVITE refused",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestIntegrationModeSecretList checks that LIST shows a +s
|
// TestIntegrationModeSecretList checks that LIST shows a +s
|
||||||
// channel only to its members.
|
// channel only to its members.
|
||||||
func TestIntegrationModeSecretList(t *testing.T) {
|
func TestIntegrationModeSecretList(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user