generated from nginxinc/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
134 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2023 F5 Inc. All rights reserved. | ||
* Use of this source code is governed by the Apache License that can be found in the LICENSE file. | ||
*/ | ||
|
||
package configuration | ||
|
||
type TLSMode int | ||
|
||
var TLSModeMap = map[string]TLSMode{ | ||
"no-tls": TLSModeNoTLS, | ||
"ca-tls": TLSModeCaTLS, | ||
"ca-mtls": TLSModeCaMTLS, | ||
"ss-tls": TLSModeSsTLS, | ||
"ss-mtls": TLSModeSsMTLS, | ||
} | ||
|
||
const ( | ||
TLSModeNoTLS TLSMode = iota | ||
TLSModeCaTLS | ||
TLSModeCaMTLS | ||
TLSModeSsTLS | ||
TLSModeSsMTLS | ||
) | ||
|
||
func (t TLSMode) String() string { | ||
modes := []string{"no-tls", "ca-tls", "ca-mtls", "ss-tls", "ss-mtls"} | ||
if t < TLSModeNoTLS || t > TLSModeSsMTLS { | ||
return "" | ||
} | ||
return modes[t] | ||
} |
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,74 @@ | ||
/* | ||
* Copyright 2023 F5 Inc. All rights reserved. | ||
* Use of this source code is governed by the Apache License that can be found in the LICENSE file. | ||
*/ | ||
|
||
package configuration | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_String(t *testing.T) { | ||
mode := TLSModeNoTLS.String() | ||
if mode != "no-tls" { | ||
t.Errorf("Expected TLSModeNoTLS to be 'no-tls', got '%s'", mode) | ||
} | ||
|
||
mode = TLSModeCaTLS.String() | ||
if mode != "ca-tls" { | ||
t.Errorf("Expected TLSModeCaTLS to be 'ca-tls', got '%s'", mode) | ||
} | ||
|
||
mode = TLSModeCaMTLS.String() | ||
if mode != "ca-mtls" { | ||
t.Errorf("Expected TLSModeCaMTLS to be 'ca-mtls', got '%s'", mode) | ||
} | ||
|
||
mode = TLSModeSsTLS.String() | ||
if mode != "ss-tls" { | ||
t.Errorf("Expected TLSModeSsTLS to be 'ss-tls', got '%s'", mode) | ||
} | ||
|
||
mode = TLSModeSsMTLS.String() | ||
if mode != "ss-mtls" { | ||
t.Errorf("Expected TLSModeSsMTLS to be 'ss-mtls', got '%s',", mode) | ||
} | ||
|
||
mode = TLSMode(5).String() | ||
if mode != "" { | ||
t.Errorf("Expected TLSMode(5) to be '', got '%s'", mode) | ||
} | ||
} | ||
|
||
func Test_TLSModeMap(t *testing.T) { | ||
mode := TLSModeMap["no-tls"] | ||
if mode != TLSModeNoTLS { | ||
t.Errorf("Expected TLSModeMap['no-tls'] to be TLSModeNoTLS, got '%d'", mode) | ||
} | ||
|
||
mode = TLSModeMap["ca-tls"] | ||
if mode != TLSModeCaTLS { | ||
t.Errorf("Expected TLSModeMap['ca-tls'] to be TLSModeCaTLS, got '%d'", mode) | ||
} | ||
|
||
mode = TLSModeMap["ca-mtls"] | ||
if mode != TLSModeCaMTLS { | ||
t.Errorf("Expected TLSModeMap['ca-mtls'] to be TLSModeCaMTLS, got '%d'", mode) | ||
} | ||
|
||
mode = TLSModeMap["ss-tls"] | ||
if mode != TLSModeSsTLS { | ||
t.Errorf("Expected TLSModeMap['ss-tls'] to be TLSModeSsTLS, got '%d'", mode) | ||
} | ||
|
||
mode = TLSModeMap["ss-mtls"] | ||
if mode != TLSModeSsMTLS { | ||
t.Errorf("Expected TLSModeMap['ss-mtls'] to be TLSModeSsMTLS, got '%d'", mode) | ||
} | ||
|
||
mode = TLSModeMap["invalid"] | ||
if mode != TLSMode(0) { | ||
t.Errorf("Expected TLSModeMap['invalid'] to be TLSMode(0), got '%d'", mode) | ||
} | ||
} |