1
0
Fork 0

Actually enable auth for Notify

master
Philip O'Toole 10 months ago
parent 097382001d
commit 173120194e

@ -175,7 +175,7 @@ func (b *Bootstrapper) notify(targets []string, id, raftAddr string) error {
Id: id,
}
for _, t := range targets {
if err := b.client.Notify(nr, t, requestTimeout); err != nil {
if err := b.client.Notify(nr, t, b.creds, requestTimeout); err != nil {
return fmt.Errorf("failed to notify node at %s: %s", t, err)
}
}

@ -299,7 +299,7 @@ func (c *Client) RemoveNode(rn *command.RemoveNodeRequest, nodeAddr string, cred
}
// Notify notifies a remote node that this node is ready to bootstrap.
func (c *Client) Notify(nr *command.NotifyRequest, nodeAddr string, timeout time.Duration) error {
func (c *Client) Notify(nr *command.NotifyRequest, nodeAddr string, creds *Credentials, timeout time.Duration) error {
conn, err := c.dial(nodeAddr, c.timeout)
if err != nil {
return err
@ -312,6 +312,7 @@ func (c *Client) Notify(nr *command.NotifyRequest, nodeAddr string, timeout time
Request: &Command_NotifyRequest{
NotifyRequest: nr,
},
Credentials: creds,
}
if err := writeCommand(conn, command, timeout); err != nil {
handleConnError(conn)

@ -294,7 +294,7 @@ func Test_NewServiceNotify(t *testing.T) {
// Test by connecting to itself.
c := NewClient(ml, 30*time.Second)
err := c.Notify(nr, s.Addr(), 5*time.Second)
err := c.Notify(nr, s.Addr(), nil, 5*time.Second)
if err != nil {
t.Fatalf("failed to notify node: %s", err)
}
@ -304,7 +304,7 @@ func Test_NewServiceNotify(t *testing.T) {
// Test when auth is enabled
credStr.HasPermOK = false
err = c.Notify(nr, s.Addr(), 5*time.Second)
err = c.Notify(nr, s.Addr(), nil, 5*time.Second)
if err == nil {
t.Fatal("should have failed to notify node due to lack of auth")
}

@ -225,7 +225,7 @@ func (n *Node) Notify(id, raftAddr string) error {
Id: n.Store.ID(),
Address: n.RaftAddr,
}
return n.Client.Notify(nr, raftAddr, 5*time.Second)
return n.Client.Notify(nr, raftAddr, nil, 5*time.Second)
}
// NodesStatus is the Go type /nodes endpoint response is marshaled into.

Loading…
Cancel
Save