This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
envoy/lds: refactor http connection manager + wasm filter
The existing code to build the HTTP connection manager is unnecessarily complex and complicated to test. This change refactor the code such that it is easier to comprehend and test. Additionally, removes the WASM stats headers for ingress so that internal mesh details (pod name, namespace, deployments etc.) are not leaked as a part of the HTTP response headers. - Removes mesh WASM config for ingress - WASM, external auth, tracing related code have been consolidated into their respective files. - HTTP connection manager is now built from its input config as opposed to passing the Configurator interface around multiple times. - Fixes incorrect test expectations when registering mock expectations for function calls. - Only adds the necessary WASM filters when `statsHeaders` are configured on the `lisenerBuilder` type. - Renames tests to match the function names and moves updated tests to their corresponding test files. Signed-off-by: Shashank Ram <[email protected]>
- Loading branch information
1 parent
3fd5cd6
commit b333f45
Showing
16 changed files
with
540 additions
and
411 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package lds | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/openservicemesh/osm/pkg/auth" | ||
"github.com/openservicemesh/osm/pkg/configurator" | ||
) | ||
|
||
func TestGetExtAuthConfig(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
authConfig *auth.ExtAuthConfig | ||
expected *auth.ExtAuthConfig | ||
}{ | ||
{ | ||
name: "Ext Auth feature is disabled", | ||
authConfig: &auth.ExtAuthConfig{ | ||
Enable: false, | ||
Address: "test.xyz", | ||
Port: 123, | ||
StatPrefix: "pref", | ||
FailureModeAllow: false, | ||
}, | ||
expected: nil, | ||
}, | ||
{ | ||
name: "Ext Auth feature is enabled", | ||
authConfig: &auth.ExtAuthConfig{ | ||
Enable: true, | ||
Address: "test.xyz", | ||
Port: 123, | ||
StatPrefix: "pref", | ||
FailureModeAllow: false, | ||
}, | ||
expected: &auth.ExtAuthConfig{ | ||
Enable: true, | ||
Address: "test.xyz", | ||
Port: 123, | ||
StatPrefix: "pref", | ||
FailureModeAllow: false, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
a := assert.New(t) | ||
mockCtrl := gomock.NewController(t) | ||
defer mockCtrl.Finish() | ||
|
||
mockConfigurator := configurator.NewMockConfigurator(mockCtrl) | ||
lb := &listenerBuilder{ | ||
cfg: mockConfigurator, | ||
} | ||
|
||
mockConfigurator.EXPECT().GetInboundExternalAuthConfig().Return(*tc.authConfig).Times(1) | ||
|
||
actual := lb.getExtAuthConfig() | ||
a.Equal(tc.expected, actual) | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.