-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes auto_join for mDNS provider (#25080)
* fixes auto_join for mDNS provider * adds a function to format addresses returned by go-discover * adds copyright header in raft_rest.go * Adds changelog file for PR #25080, godoc for TestFormatDiscoveredAddr --------- Co-authored-by: Violet Hynes <[email protected]>
- Loading branch information
1 parent
f7c1679
commit d64856c
Showing
3 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{ | ||
{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) | ||
} | ||
} | ||
} |