-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
fixes auto_join for mDNS provider #25080
Changes from all commits
8b85577
82edaad
9965274
47a39ad
7927b2c
137de00
882300c
97b83e6
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,3 @@ | ||
```release-note:bug | ||
storage/raft: Fix auto_join not working with mDNS provider. | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package vault | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// TestFormatDiscoveredAddr validates that the string returned by formatDiscoveredAddr always respect the format `host:port`. | ||
func TestFormatDiscoveredAddr(t *testing.T) { | ||
type TestCase struct { | ||
addr string | ||
port uint | ||
res string | ||
} | ||
cases := []TestCase{ | ||
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. This is mostly a question out of curiosity as opposed to something you should change, but out of interest: which of these would have failed with the old implementation? 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. All cases where the port is returned with the address failed before. For example with this case |
||
{addr: "127.0.0.1", port: uint(8200), res: "127.0.0.1:8200"}, | ||
{addr: "192.168.137.1:8201", port: uint(8200), res: "192.168.137.1:8201"}, | ||
{addr: "fe80::aa5e:45ff:fe54:c6ce", port: uint(8200), res: "[fe80::aa5e:45ff:fe54:c6ce]:8200"}, | ||
{addr: "::1", port: uint(8200), res: "[::1]:8200"}, | ||
{addr: "[::1]", port: uint(8200), res: "[::1]:8200"}, | ||
{addr: "[::1]:8201", port: uint(8200), res: "[::1]:8201"}, | ||
{addr: "[fe80::aa5e:45ff:fe54:c6ce]", port: uint(8200), res: "[fe80::aa5e:45ff:fe54:c6ce]:8200"}, | ||
{addr: "[fe80::aa5e:45ff:fe54:c6ce]:8201", port: uint(8200), res: "[fe80::aa5e:45ff:fe54:c6ce]:8201"}, | ||
} | ||
for i, c := range cases { | ||
res := formatDiscoveredAddr(c.addr, c.port) | ||
if res != c.res { | ||
t.Errorf("case %d result shoud be \"%s\" but is \"%s\"", i, c.res, res) | ||
} | ||
} | ||
} |
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.
Would be great if we could get a godoc for this function! Something starting with
// TestFormatDiscoveredAddr
and with a brief description of what it does