also use port number when checking https proxy for WebhookAuthenticator

This commit is contained in:
Ryan Richard
2024-10-11 14:49:46 -07:00
parent 4d2bbac674
commit dc195536d0
4 changed files with 121 additions and 10 deletions

View File

@@ -510,7 +510,7 @@ func (c *webhookCacheFillerController) validateEndpoint(endpoint string, conditi
return nil, conditions, false, false
}
usingProxyForHost, err := c.proxyDetector.UsingProxyForHost(endpointHostPort.Host)
usingProxyForHost, err := c.proxyDetector.UsingProxyForHost(endpointHostPort.Endpoint())
if err != nil {
msg := fmt.Sprintf("%s: %s", "spec.endpoint URL error", err.Error())
conditions = append(conditions, &metav1.Condition{

View File

@@ -1068,7 +1068,10 @@ func TestController(t *testing.T) {
fakeProxyDetect := fakeproxydetect.New(true, nil)
t.Cleanup(func() {
require.Equal(t, 1, fakeProxyDetect.NumberOfInvocations())
require.Equal(t, "127.0.0.1", fakeProxyDetect.ReceivedHostDuringMostRecentInvocation())
require.Equal(t,
strings.TrimPrefix(goodWebhookAuthenticatorSpecWithCA.Endpoint, "https://"),
fakeProxyDetect.ReceivedHostDuringMostRecentInvocation(),
)
})
return fakeProxyDetect
},
@@ -1117,7 +1120,10 @@ func TestController(t *testing.T) {
fakeProxyDetect := fakeproxydetect.New(false, nil)
t.Cleanup(func() {
require.Equal(t, 1, fakeProxyDetect.NumberOfInvocations())
require.Equal(t, "127.0.0.1", fakeProxyDetect.ReceivedHostDuringMostRecentInvocation())
require.Equal(t,
strings.TrimPrefix(goodWebhookAuthenticatorSpecWithCA.Endpoint, "https://"),
fakeProxyDetect.ReceivedHostDuringMostRecentInvocation(),
)
})
return fakeProxyDetect
},
@@ -1160,7 +1166,10 @@ func TestController(t *testing.T) {
fakeProxyDetect := fakeproxydetect.New(true, nil)
t.Cleanup(func() {
require.Equal(t, 1, fakeProxyDetect.NumberOfInvocations())
require.Equal(t, "127.0.0.1", fakeProxyDetect.ReceivedHostDuringMostRecentInvocation())
require.Equal(t,
strings.TrimPrefix(goodWebhookAuthenticatorSpecWithCA.Endpoint, "https://"),
fakeProxyDetect.ReceivedHostDuringMostRecentInvocation(),
)
})
return fakeProxyDetect
},
@@ -1208,7 +1217,10 @@ func TestController(t *testing.T) {
fakeProxyDetect := fakeproxydetect.New(false, errors.New("fake proxy detector error"))
t.Cleanup(func() {
require.Equal(t, 1, fakeProxyDetect.NumberOfInvocations())
require.Equal(t, "127.0.0.1", fakeProxyDetect.ReceivedHostDuringMostRecentInvocation())
require.Equal(t,
strings.TrimPrefix(goodWebhookAuthenticatorSpecWithCA.Endpoint, "https://"),
fakeProxyDetect.ReceivedHostDuringMostRecentInvocation(),
)
})
return fakeProxyDetect
},