-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
210e735
add probe path for whitelisting
itsmurugappan dc01d9a
add e2e for probe whitelisting
itsmurugappan 71236b5
add e2e for probe whitelisting
itsmurugappan 24d4e54
add e2e for probe whitelisting
itsmurugappan 974a09f
add e2e for probe whitelisting
itsmurugappan 6ffd879
add e2e for probe whitelisting
itsmurugappan bd9ad84
add e2e for probe whitelisting
itsmurugappan ff40cb5
add e2e for probe whitelisting
itsmurugappan 170b37f
add e2e for probe whitelisting
itsmurugappan 7fbb6fe
add e2e for probe whitelisting
itsmurugappan def9ba5
add e2e for probe path whitelisting
itsmurugappan 36e59ba
add e2e for probe path whitelisting
itsmurugappan c847700
e2e for whitelist probe path
itsmurugappan d7c9b3b
e2e for whitelist probe path
itsmurugappan bb80418
e2e for probe whitelist test
itsmurugappan 2ea9a2b
e2e test for probe whitelisting
itsmurugappan 1864bb1
e2e test for probe whitelisting
itsmurugappan fe01449
e2e test for probe whitelisting
itsmurugappan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
File renamed without changes.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,93 @@ | ||
| // +build e2e | ||
|
|
||
| /* | ||
| Copyright 2020 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 ( | ||
| "net/http" | ||
| "testing" | ||
|
|
||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| 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. | ||
| //policy is present in test/config/security/policy.yaml | ||
| //apply policy before running this test | ||
| func TestProbeWhitelist(t *testing.T) { | ||
| t.Parallel() | ||
| cancel := logstream.Start(t) | ||
| defer cancel() | ||
|
|
||
| clients := SetupServingNamespaceforSecurityTesting(t) | ||
|
|
||
| names := test.ResourceNames{ | ||
| Service: test.ObjectNameForTest(t), | ||
| Image: "helloworld", | ||
| } | ||
|
|
||
| if test.ServingFlags.Https { | ||
| // Save the current Gateway to restore it after the test | ||
| oldGateway, err := clients.IstioClient.NetworkingV1alpha3().Gateways(v1a1test.Namespace).Get(v1a1test.GatewayName, metav1.GetOptions{}) | ||
| if err != nil { | ||
| t.Fatalf("Failed to get Gateway %s/%s", v1a1test.Namespace, v1a1test.GatewayName) | ||
| } | ||
| test.CleanupOnInterrupt(func() { v1a1test.RestoreGateway(t, clients, *oldGateway) }) | ||
| defer v1a1test.RestoreGateway(t, clients, *oldGateway) | ||
| } | ||
|
|
||
| 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") | ||
| } | ||
| opt = *httpsTransportOption | ||
| } | ||
| if _, err := pkgTest.WaitForEndpointState( | ||
| clients.KubeClient, | ||
| t.Logf, | ||
| url, | ||
| v1a1test.RetryingRouteInconsistency(pkgTest.MatchesAllOf(pkgTest.IsOneOfStatusCodes(http.StatusUnauthorized))), | ||
| "HelloWorldServesAuthFailed", | ||
| test.ServingFlags.ResolvableDomain, | ||
| opt); err != nil { | ||
| // check if side car is injected before reporting error | ||
| if _, err := getContainer(clients.KubeClient, resources.Service.Name, "istio-proxy", resources.Service.Namespace); err != nil { | ||
| t.Skip("Side car not enabled, skipping test") | ||
| } | ||
| t.Fatalf("The endpoint %s for Route %s didn't serve the expected status %d: %v", url, names.Route, http.StatusUnauthorized, err) | ||
| } | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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