Skip to content

TransportServer SNI #6605

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

Merged
merged 38 commits into from
Oct 22, 2024
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4c623b3
commit poc
Sep 24, 2024
bd1a6ac
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 24, 2024
9234db3
remove build errors
Sep 24, 2024
6f6dd49
fix go tests
Sep 25, 2024
88f24b6
fix example readme linting
Sep 25, 2024
9af72cf
fix tests
Sep 25, 2024
4c3c49c
remove unnessary changes
Sep 25, 2024
c812f7d
update snaps
Sep 25, 2024
4c746b6
tls passthrough example lint
Sep 25, 2024
6a0644b
fix tests
Sep 25, 2024
7e8c45c
fix test
Sep 25, 2024
9db8c56
add new snapshot test, fix makeServerName function
Sep 26, 2024
a751f78
add test for makeServerName function
Sep 26, 2024
3d35774
add go tests
Sep 26, 2024
624e693
Merge branch 'main' into poc/transport-server-sni
Sep 26, 2024
2748b2f
change c.listeners to c.listenerHosts
Oct 7, 2024
2fb8fdf
Merge branch 'main' into poc/transport-server-sni
Oct 7, 2024
5f4ebc0
fix non tls passthrough hosts being added to tls passthrough template
Oct 7, 2024
af2c0ed
Merge branch 'main' into feat/transport-server-sni
Oct 7, 2024
87a671f
more go tests
Oct 10, 2024
ae9e4a9
Merge branch 'main' into feat/transport-server-sni
Oct 11, 2024
70debbe
add python tests
Oct 11, 2024
12e5529
Merge branch 'main' into feat/transport-server-sni
Oct 11, 2024
1b7621e
add listenerhost tests
Oct 11, 2024
c85c9a8
add docs
Oct 11, 2024
66bedf5
fix validateTSHost logic
Oct 11, 2024
7be8dc2
remove unused function
Oct 11, 2024
17b8e2f
Apply suggestions from code review
Oct 11, 2024
20d71c3
test undo enumeration
Oct 11, 2024
775a9b4
change numbers to headings
Oct 11, 2024
cc4e1fb
Merge branch 'main' into feat/transport-server-sni
Oct 14, 2024
e66a52c
make changes from code review
Oct 14, 2024
615d06e
Merge branch 'main' into feat/transport-server-sni
Oct 14, 2024
53bc93e
Merge branch 'main' into feat/transport-server-sni
Oct 15, 2024
35c1cde
Merge branch 'main' into feat/transport-server-sni
Oct 17, 2024
88ce4bf
Merge branch 'main' into feat/transport-server-sni
Oct 21, 2024
c0bde77
bash to shell
Oct 21, 2024
47959ef
Merge branch 'main' into feat/transport-server-sni
Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add listenerhost tests
  • Loading branch information
Jim Ryan committed Oct 11, 2024
commit 1b7621e08d27ff96f38cde257c8db1c205c18a03
144 changes: 141 additions & 3 deletions internal/k8s/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2021,7 +2021,7 @@ func TestAddTransportServerWithHost(t *testing.T) {

secretName := "echo-secret"

ts := createTestTransportServerWithHost("transportserver", "echo.example.com", "tcp-7777", "TCP", secretName)
ts := createTestTransportServerWithHost("transportserver", "echo.example.com", "tcp-7777", secretName)

// no problems are expected for all cases
var expectedProblems []ConfigurationProblem
Expand Down Expand Up @@ -3840,8 +3840,8 @@ func createTestTransportServer(name string, listenerName string, listenerProtoco
}
}

func createTestTransportServerWithHost(name string, host string, listenerName string, listenerProtocol string, secretName string) *conf_v1.TransportServer {
ts := createTestTransportServer(name, listenerName, listenerProtocol)
func createTestTransportServerWithHost(name string, host string, listenerName string, secretName string) *conf_v1.TransportServer {
ts := createTestTransportServer(name, listenerName, "TCP")
ts.Spec.Host = host
ts.Spec.TLS = &conf_v1.TransportServerTLS{Secret: secretName}

Expand Down Expand Up @@ -4754,3 +4754,141 @@ var (
},
}
)

func TestTransportServerListenerHostCollisions(t *testing.T) {
configuration := createTestConfiguration()

listeners := []conf_v1.Listener{
{
Name: "tcp-7777",
Port: 7777,
Protocol: "TCP",
},
{
Name: "tcp-8888",
Port: 8888,
Protocol: "TCP",
},
}

addOrUpdateGlobalConfiguration(t, configuration, listeners, noChanges, noProblems)

// Create TransportServers with the same listener and host
ts1 := createTestTransportServerWithHost("ts1", "example.com", "tcp-7777", "secret1")
ts2 := createTestTransportServerWithHost("ts2", "example.com", "tcp-7777", "secret2") // same listener and host
ts3 := createTestTransportServerWithHost("ts3", "example.org", "tcp-7777", "secret3") // different host
ts4 := createTestTransportServer("ts4", "tcp-7777", "TCP") // No host same listener
ts5 := createTestTransportServer("ts5", "tcp-7777", "TCP") // same as ts4 to induce error with empty host twice
ts6 := createTestTransportServerWithHost("ts6", "example.com", "tcp-8888", "secret4") // different listener

// Add ts1 to the configuration
expectedChanges := []ResourceChange{
{
Op: AddOrUpdate,
Resource: &TransportServerConfiguration{
ListenerPort: 7777,
TransportServer: ts1,
},
},
}
changes, problems := configuration.AddOrUpdateTransportServer(ts1)
if diff := cmp.Diff(expectedChanges, changes); diff != "" {
t.Errorf("AddOrUpdateTransportServer(ts1) returned unexpected result (-want +got):\n%s", diff)
}
if len(problems) != 0 {
t.Errorf("AddOrUpdateTransportServer(ts1) returned problems %v", problems)
}

// Try to add ts2, should be rejected due to conflict
changes, problems = configuration.AddOrUpdateTransportServer(ts2)
expectedChanges = nil // No changes expected
expectedProblems := []ConfigurationProblem{
{
Object: ts2,
IsError: false,
Reason: "Rejected",
Message: "Listener tcp-7777 with host example.com is taken by another resource",
},
}

if diff := cmp.Diff(expectedChanges, changes); diff != "" {
t.Errorf("AddOrUpdateTransportServer(ts2) returned unexpected changes (-want +got):\n%s", diff)
}
if diff := cmp.Diff(expectedProblems, problems); diff != "" {
t.Errorf("AddOrUpdateTransportServer(ts2) returned unexpected problems (-want +got):\n%s", diff)
}

// Add ts3 with a different host, should be accepted
expectedChanges = []ResourceChange{
{
Op: AddOrUpdate,
Resource: &TransportServerConfiguration{
ListenerPort: 7777,
TransportServer: ts3,
},
},
}
changes, problems = configuration.AddOrUpdateTransportServer(ts3)
if diff := cmp.Diff(expectedChanges, changes); diff != "" {
t.Errorf("AddOrUpdateTransportServer(ts3) returned unexpected result (-want +got):\n%s", diff)
}
if len(problems) != 0 {
t.Errorf("AddOrUpdateTransportServer(ts3) returned problems %v", problems)
}

// Add ts4 with no host, should be accepted
expectedChanges = []ResourceChange{
{
Op: AddOrUpdate,
Resource: &TransportServerConfiguration{
ListenerPort: 7777,
TransportServer: ts4,
},
},
}
changes, problems = configuration.AddOrUpdateTransportServer(ts4)
if diff := cmp.Diff(expectedChanges, changes); diff != "" {
t.Errorf("AddOrUpdateTransportServer(ts4) returned unexpected result (-want +got):\n%s", diff)
}
if len(problems) != 0 {
t.Errorf("AddOrUpdateTransportServer(ts4) returned problems %v", problems)
}

// Try to add ts5 with no host, should be rejected due to conflict
changes, problems = configuration.AddOrUpdateTransportServer(ts5)
expectedChanges = nil
expectedProblems = []ConfigurationProblem{
{
Object: ts5,
IsError: false,
Reason: "Rejected",
Message: "Listener tcp-7777 with host empty host is taken by another resource",
},
}

if diff := cmp.Diff(expectedChanges, changes); diff != "" {
t.Errorf("AddOrUpdateTransportServer(ts5) returned unexpected changes (-want +got):\n%s", diff)
}
if diff := cmp.Diff(expectedProblems, problems); diff != "" {
t.Errorf("AddOrUpdateTransportServer(ts5) returned unexpected problems (-want +got):\n%s", diff)
}

// Try to add ts6 with different listener, but same domain as initial ts, should be fine as different listener
changes, problems = configuration.AddOrUpdateTransportServer(ts6)
expectedChanges = []ResourceChange{
{
Op: AddOrUpdate,
Resource: &TransportServerConfiguration{
ListenerPort: 8888,
TransportServer: ts6,
},
},
}
if diff := cmp.Diff(expectedChanges, changes); diff != "" {
t.Errorf("AddOrUpdateTransportServer(ts6) returned unexpected changes (-want +got):\n%s", diff)
}

if len(problems) != 0 {
t.Errorf("AddOrUpdateTransportServer(ts6) returned problems %v", problems)
}
}
Loading