-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add probe path for whitelisting #6505
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
Changes from 4 commits
210e735
dc01d9a
71236b5
24d4e54
974a09f
6ffd879
bd9ad84
ff40cb5
170b37f
7fbb6fe
def9ba5
36e59ba
c847700
d7c9b3b
bb80418
2ea9a2b
1864bb1
fe01449
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||
| apiVersion: authentication.istio.io/v1alpha1 | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 436 in 28f2a24
But could you please consider this https://github.com/knative/serving/pull/6505/files#r365568314 first?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if i add the policy to serving-tests or serving-tests-alt, it would affect the other tests run on these ns as it would require token to call the service end point.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. I wondered we can set |
||||
| kind: Policy | ||||
| metadata: | ||||
| name: default | ||||
| namespace: serving-tests-sidecar-enabled | ||||
| spec: | ||||
| origins: | ||||
| - jwt: | ||||
| issuer: testing@secure.istio.io | ||||
| jwksUri: https://raw.githubusercontent.com/istio/istio/release-1.4/security/tools/jwt/samples/jwks.json | ||||
| triggerRules: | ||||
| - excludedPaths: | ||||
| - prefix: /metrics | ||||
| - prefix: /_internal/knative/activator/probe | ||||
| principalBinding: USE_ORIGIN | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| // +build e2e | ||
|
|
||
| /* | ||
| Copyright 2018 The Knative Authors | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package e2e | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| pkgTest "knative.dev/pkg/test" | ||
| "knative.dev/pkg/test/logstream" | ||
| "knative.dev/serving/test" | ||
| v1a1test "knative.dev/serving/test/v1alpha1" | ||
| ) | ||
|
|
||
| //This test checks if the activator can probe | ||
| //the service when istio end user auth policy is | ||
| //applied on the service. | ||
| //This test needs istio side car injected and | ||
| //istio policy check enabled. If both are not | ||
| //enabled the test will pass | ||
| //policy is present test/config/auth/policy.yaml | ||
|
itsmurugappan marked this conversation as resolved.
Outdated
|
||
| //apply policy before running this test | ||
| func TestProbeWhitelist(t *testing.T) { | ||
| t.Parallel() | ||
| cancel := logstream.Start(t) | ||
| defer cancel() | ||
|
|
||
| clients := SetupSideCarEnabledNamespace(t) | ||
|
|
||
| names := test.ResourceNames{ | ||
| Service: test.ObjectNameForTest(t), | ||
| Image: "helloworld", | ||
| } | ||
|
|
||
| test.CleanupOnInterrupt(func() { test.TearDown(clients, names) }) | ||
| defer test.TearDown(clients, names) | ||
|
|
||
| t.Log("Creating a new Service") | ||
| resources, httpsTransportOption, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, test.ServingFlags.Https) | ||
| if err != nil { | ||
| t.Fatalf("Failed to create initial Service: %v: %v", names.Service, err) | ||
| } | ||
|
|
||
| url := resources.Route.Status.URL.URL() | ||
| var opt interface{} | ||
| if test.ServingFlags.Https { | ||
| url.Scheme = "https" | ||
| if httpsTransportOption == nil { | ||
| t.Fatalf("Https transport option is nil") | ||
|
itsmurugappan marked this conversation as resolved.
Outdated
|
||
| } | ||
| opt = *httpsTransportOption | ||
| } | ||
| if _, err := pkgTest.WaitForEndpointState( | ||
| clients.KubeClient, | ||
| t.Logf, | ||
| url, | ||
| v1a1test.RetryingRouteInconsistency(pkgTest.MatchesAllOf(pkgTest.MatchesBody(test.UnauthorizedText))), | ||
|
itsmurugappan marked this conversation as resolved.
Outdated
|
||
| "HelloWorldServesAuthFailed", | ||
| test.ServingFlags.ResolvableDomain, | ||
| opt); err != nil { | ||
| // check if side car is injected before reporting error | ||
| _, err = getContainer(clients.KubeClient, resources.Service.Name, "istio-proxy", resources.Service.Namespace) | ||
|
itsmurugappan marked this conversation as resolved.
Outdated
|
||
| if err != nil { | ||
| t.Log("side car not enabled, skipping test") | ||
|
itsmurugappan marked this conversation as resolved.
Outdated
|
||
| return | ||
| } | ||
| t.Fatalf("The endpoint %s for Route %s didn't serve the expected text %q: %v", url, names.Route, test.UnauthorizedText, err) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,6 +33,8 @@ const ( | |||||||
| // namespace tests in. | ||||||||
| AlternativeServingNamespace = "serving-tests-alt" | ||||||||
|
|
||||||||
| // side car injected ns | ||||||||
|
itsmurugappan marked this conversation as resolved.
Outdated
|
||||||||
| SideCarServingNamespace = "serving-tests-sidecar-enabled" | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Lines 433 to 435 in 28f2a24
So, it would be better to use either of the namespace. I wonder that we can merge your config into https://github.com/knative/serving/blob/master/test/config/mtls/policy.yaml. Then, we should change the directory name to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if i add the policy to serving-tests or serving-tests-alt, it would affect the other tests run on these ns as it would require token to call the service end point.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i have moved the files from mtls to security folder and made the changes in e2e-common.sh |
||||||||
| // Environment propagation conformance test objects | ||||||||
|
|
||||||||
| // ConformanceConfigMap is the name of the configmap to propagate env variables from | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some random path for activator to probe. It can be changed as @tcnghia has mentioned here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be constant here, which is fine.
It needs to be documented as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though it seems quite long for a random probe path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can follow up to extract this to a configurable option in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please fine an issue, so it's not forgotten