-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow adding additional IPs to MarbleRun generated certificates (#528)
* Allow adding additional IPs for Coordinator root cert * Allow adding additional IPs for Marble TLS cert --------- Signed-off-by: Daniel Weiße <[email protected]>
- Loading branch information
1 parent
1311c6a
commit 92dcebf
Showing
6 changed files
with
82 additions
and
12 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
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
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
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,52 @@ | ||
// Copyright (c) Edgeless Systems GmbH. | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
package util | ||
|
||
import ( | ||
"net" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestExtractIPsFromAltNames(t *testing.T) { | ||
testCases := map[string]struct { | ||
altNames []string | ||
wantIPs []net.IP | ||
wantDNSNames []string | ||
}{ | ||
"empty": { | ||
altNames: []string{}, | ||
wantIPs: []net.IP{}, | ||
wantDNSNames: []string{}, | ||
}, | ||
"only IPs": { | ||
altNames: []string{"192.0.2.1", "192.0.2.15"}, | ||
wantIPs: []net.IP{net.ParseIP("192.0.2.1"), net.ParseIP("192.0.2.15")}, | ||
wantDNSNames: []string{}, | ||
}, | ||
"only DNS names": { | ||
altNames: []string{"foo.bar", "example.com"}, | ||
wantIPs: []net.IP{}, | ||
wantDNSNames: []string{"foo.bar", "example.com"}, | ||
}, | ||
"mixed": { | ||
altNames: []string{"192.0.2.1", "foo.bar"}, | ||
wantIPs: []net.IP{net.ParseIP("192.0.2.1")}, | ||
wantDNSNames: []string{"foo.bar"}, | ||
}, | ||
} | ||
|
||
for name, tc := range testCases { | ||
t.Run(name, func(t *testing.T) { | ||
assert := assert.New(t) | ||
gotIPs, gotDNSNames := ExtractIPsFromAltNames(tc.altNames) | ||
assert.ElementsMatch(tc.wantIPs, gotIPs) | ||
assert.ElementsMatch(tc.wantDNSNames, gotDNSNames) | ||
}) | ||
} | ||
} |