-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Zahari Dichev <[email protected]>
- Loading branch information
1 parent
a535967
commit 742c0ab
Showing
3 changed files
with
62 additions
and
4 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
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,53 @@ | ||
use linkerd_policy_controller_k8s_api as k8s; | ||
use linkerd_policy_test::{ | ||
await_condition, create, create_ready_pod, curl, endpoints_ready, update, web, with_temp_ns, | ||
Check warning on line 3 in policy-test/tests/e2e_egress_network.rs
|
||
LinkerdInject, | ||
}; | ||
|
||
#[tokio::test(flavor = "current_thread")] | ||
async fn default_traffic_policy() { | ||
with_temp_ns(|client, ns| async move { | ||
let mut egress_net = create( | ||
&client, | ||
k8s::policy::EgressNetwork { | ||
metadata: k8s::ObjectMeta { | ||
namespace: Some(ns.clone()), | ||
name: Some("all-egress".to_string()), | ||
..Default::default() | ||
}, | ||
spec: k8s::policy::EgressNetworkSpec { | ||
networks: None, | ||
traffic_policy: k8s::policy::TrafficPolicy::Allow, | ||
}, | ||
status: None, | ||
}, | ||
) | ||
.await; | ||
|
||
let curl = curl::Runner::init(&client, &ns).await; | ||
|
||
let allowed = curl | ||
.run( | ||
"curl-allowed", | ||
"http://httpbin.org/get", | ||
LinkerdInject::Enabled, | ||
) | ||
.await; | ||
let allowed_status = allowed.http_status_code().await; | ||
assert_eq!(allowed_status, 200, "request must be allowed"); | ||
|
||
egress_net.spec.traffic_policy = k8s::policy::TrafficPolicy::Deny; | ||
update(&client, egress_net).await; | ||
|
||
let not_allowed = curl | ||
.run( | ||
"curl-not-allowed", | ||
"http://httpbin.org/get", | ||
LinkerdInject::Enabled, | ||
) | ||
.await; | ||
let not_allowed_status = not_allowed.http_status_code().await; | ||
assert_eq!(not_allowed_status, 403, "request must be blocked"); | ||
}) | ||
.await; | ||
} |