Skip to content
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

fix: Add proxy registry key by dest server + name #21791

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Changes from 1 commit
Commits
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
improve test case scenario
Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com>
  • Loading branch information
leoluz committed Feb 5, 2025
commit 7374060a3ebc1e0e32a82b9d5f9555027b01e9f0
17 changes: 9 additions & 8 deletions server/extension/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,19 +486,21 @@ func TestCallExtension(t *testing.T) {

response1 := "response backend 1"
cluster1Name := "cluster1"
cluster1URL := "url1"
beSrv1 := startBackendTestSrv(response1)
defer beSrv1.Close()

response2 := "response backend 2"
cluster2URL := "cluster2"
cluster2Name := "cluster2"
cluster2URL := "url2"
beSrv2 := startBackendTestSrv(response2)
defer beSrv2.Close()

f.appGetterMock.On("Get", "ns1", "app1").Return(getApp(cluster1Name, "", defaultProjectName), nil)
f.appGetterMock.On("Get", "ns2", "app2").Return(getApp("", cluster2URL, defaultProjectName), nil)

withRbac(f, true, true)
withExtensionConfig(getExtensionConfigWith2Backends(extName, beSrv1.URL, cluster1Name, beSrv2.URL, cluster2URL), f)
withExtensionConfig(getExtensionConfigWith2Backends(extName, beSrv1.URL, cluster1Name, cluster1URL, beSrv2.URL, cluster2Name, cluster2URL), f)
withProject(getProjectWithDestinations("project-name", []string{cluster1Name}, []string{cluster2URL}), f)
withMetrics(f)
withUser(f, "some-user", []string{"group1", "group2"})
Expand Down Expand Up @@ -678,7 +680,7 @@ func TestCallExtension(t *testing.T) {
f.appGetterMock.On("Get", "ns1", "app1").Return(getApp(maliciousName, destinationServer, defaultProjectName), nil)

withRbac(f, true, true)
withExtensionConfig(getExtensionConfigWith2Backends(extName, "url1", "clusterName", "url2", "clusterURL"), f)
withExtensionConfig(getExtensionConfigWith2Backends(extName, "url1", "cluster1Name", "cluster1URL", "url2", "cluster2Name", "cluster2URL"), f)
withProject(getProjectWithDestinations("project-name", nil, []string{"srv1", destinationServer}), f)
withMetrics(f)
withUser(f, "some-user", []string{"group1", "group2"})
Expand Down Expand Up @@ -745,7 +747,7 @@ extensions:
return fmt.Sprintf(cfg, name, url)
}

func getExtensionConfigWith2Backends(name, url1, clusName, url2, clusURL string) string {
func getExtensionConfigWith2Backends(name, url1, clus1Name, clus1URL, url2, clus2Name, clus2URL string) string {
cfg := `
extensions:
- name: %s
Expand All @@ -757,11 +759,13 @@ extensions:
value: '$extension.auth.header'
cluster:
name: %s
server: %s
- url: %s
headers:
- name: Authorization
value: '$extension.auth.header2'
cluster:
name: %s
server: %s
- url: http://test.com
cluster:
Expand All @@ -770,10 +774,7 @@ extensions:
cluster:
name: cl2
`
// second extension is configured with the cluster url rather
// than the cluster name so we can validate that both use-cases
// are working
return fmt.Sprintf(cfg, name, url1, clusName, url2, clusURL)
return fmt.Sprintf(cfg, name, url1, clus1Name, clus1URL, url2, clus2Name, clus2URL)
}

func getExtensionConfigString() string {
Expand Down
Loading