Let a process read the router's record of its module's own ask (issue 1189)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package process
|
||||
|
||||
import "testing"
|
||||
|
||||
// 1189/AC2: given an ask id holding a dot or a wildcard, when read, then it is refused before anything is
|
||||
// sent — proven on a Conn with no live connection at all: if Ask tried to send, it would panic on the nil
|
||||
// *nats.Conn instead of returning a clean error.
|
||||
func TestAskRefusesAnInvalidIDBeforeSendingAnything(t *testing.T) {
|
||||
c := &Conn{account: Account{Module: "mesh-mail"}}
|
||||
for _, id := range []string{"", "a.b", "a*", "a>", "ask.1", "ask.*"} {
|
||||
if _, err := c.Ask("messenger_asks", id); err == nil {
|
||||
t.Errorf("Ask(%q) was not refused", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckAskID(t *testing.T) {
|
||||
for _, id := range []string{"", "a.b", "a*b", "a>b", ".", "*"} {
|
||||
if err := checkAskID(id); err == nil {
|
||||
t.Errorf("checkAskID(%q) was accepted", id)
|
||||
}
|
||||
}
|
||||
for _, id := range []string{"ask-1", "a1b2c3", "send_42"} {
|
||||
if err := checkAskID(id); err != nil {
|
||||
t.Errorf("checkAskID(%q) was refused: %v", id, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user