2019-06-17 18:11:22 -07:00
|
|
|
package testrunner
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
2019-08-29 18:48:58 -07:00
|
|
|
func Test_Mutate_EndPoint(t *testing.T) {
|
2019-10-14 14:10:34 -07:00
|
|
|
testScenario(t, "/test/scenarios/other/scenario_mutate_endpoint.yaml")
|
2019-08-29 18:48:58 -07:00
|
|
|
}
|
|
|
|
|
2020-01-07 10:33:28 -08:00
|
|
|
// func Test_Mutate_Validate_qos(t *testing.T) {
|
|
|
|
// testScenario(t, "/test/scenarios/other/scenario_mutate_validate_qos.yaml")
|
|
|
|
// }
|
2019-08-29 11:44:50 -07:00
|
|
|
|
2019-11-08 19:25:43 -08:00
|
|
|
func Test_disallow_root_user(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/disallow_root_user.yaml")
|
2019-09-09 10:56:19 -07:00
|
|
|
}
|
|
|
|
|
2019-11-08 20:04:42 -08:00
|
|
|
func Test_disallow_priviledged(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/disallow_priviledged.yaml")
|
2019-09-06 18:54:19 -07:00
|
|
|
}
|
|
|
|
|
2019-08-29 18:48:58 -07:00
|
|
|
func Test_validate_healthChecks(t *testing.T) {
|
2019-10-14 14:10:34 -07:00
|
|
|
testScenario(t, "/test/scenarios/other/scenario_validate_healthChecks.yaml")
|
2019-08-29 18:48:58 -07:00
|
|
|
}
|
|
|
|
|
2020-01-07 10:33:28 -08:00
|
|
|
//TODO: add generate
|
|
|
|
// func Test_add_networkPolicy(t *testing.T) {
|
|
|
|
// testScenario(t, "/test/scenarios/samples/best_practices/add_networkPolicy.yaml")
|
|
|
|
// }
|
2019-09-06 10:03:24 -07:00
|
|
|
|
|
|
|
// namespace is blank, not "default" as testrunner evaulates the policyengine, but the "default" is added by kubeapiserver
|
|
|
|
|
2019-11-10 17:54:38 -08:00
|
|
|
func Test_validate_disallow_latest_tag(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/disallow_latest_tag.yaml")
|
2019-09-06 10:03:24 -07:00
|
|
|
}
|
|
|
|
|
2019-10-09 18:35:07 -07:00
|
|
|
func Test_validate_require_image_tag_not_latest_pass(t *testing.T) {
|
2019-11-10 17:54:38 -08:00
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/disallow_latest_tag_pass.yaml")
|
2019-09-06 10:03:24 -07:00
|
|
|
}
|
|
|
|
|
2019-10-10 10:34:49 -07:00
|
|
|
func Test_validate_disallow_default_namespace(t *testing.T) {
|
2019-11-10 15:50:18 -08:00
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/disallow_default_namespace.yaml")
|
2019-09-09 14:33:55 -07:00
|
|
|
}
|
2019-09-09 15:06:54 -07:00
|
|
|
|
2019-09-09 16:08:15 -07:00
|
|
|
func Test_validate_host_network_port(t *testing.T) {
|
2019-11-10 12:53:48 -08:00
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/disallow_host_network_port.yaml")
|
2019-09-09 16:08:15 -07:00
|
|
|
}
|
2019-09-09 17:34:25 -07:00
|
|
|
|
2019-11-10 15:50:18 -08:00
|
|
|
func Test_validate_host_PID_IPC(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/disallow_host_pid_ipc.yaml")
|
2019-09-09 17:34:25 -07:00
|
|
|
}
|
2019-09-09 18:13:38 -07:00
|
|
|
|
2019-11-09 16:18:33 -08:00
|
|
|
func Test_validate_ro_rootfs(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/require_ro_rootfs.yaml")
|
2019-09-09 18:13:38 -07:00
|
|
|
}
|
2019-09-09 23:55:14 -07:00
|
|
|
|
2020-01-07 10:33:28 -08:00
|
|
|
//TODO: support generate
|
|
|
|
// func Test_add_ns_quota(t *testing.T) {
|
|
|
|
// testScenario(t, "test/scenarios/samples/best_practices/add_ns_quota.yaml")
|
|
|
|
// }
|
2019-09-10 11:57:33 -07:00
|
|
|
|
2019-09-16 14:16:54 -07:00
|
|
|
func Test_validate_disallow_default_serviceaccount(t *testing.T) {
|
2019-10-14 14:10:34 -07:00
|
|
|
testScenario(t, "test/scenarios/other/scenario_validate_disallow_default_serviceaccount.yaml")
|
2019-09-16 14:16:54 -07:00
|
|
|
}
|
2019-10-04 16:50:23 -07:00
|
|
|
|
2019-10-04 17:28:42 -07:00
|
|
|
func Test_validate_selinux_context(t *testing.T) {
|
2019-10-14 14:10:34 -07:00
|
|
|
testScenario(t, "test/scenarios/other/scenario_validate_selinux_context.yaml")
|
2019-10-04 17:28:42 -07:00
|
|
|
}
|
2019-10-04 17:48:57 -07:00
|
|
|
|
|
|
|
func Test_validate_proc_mount(t *testing.T) {
|
2019-10-14 14:10:34 -07:00
|
|
|
testScenario(t, "test/scenarios/other/scenario_validate_default_proc_mount.yaml")
|
2019-10-04 17:48:57 -07:00
|
|
|
}
|
2019-10-04 18:15:39 -07:00
|
|
|
|
2019-10-07 12:46:34 -07:00
|
|
|
func Test_validate_volume_whitelist(t *testing.T) {
|
2019-10-14 14:10:34 -07:00
|
|
|
testScenario(t, "test/scenarios/other/scenario_validate_volume_whiltelist.yaml")
|
2019-10-07 12:46:34 -07:00
|
|
|
}
|
2019-10-07 14:34:32 -07:00
|
|
|
|
2019-10-09 17:37:31 -07:00
|
|
|
func Test_require_pod_requests_limits(t *testing.T) {
|
2019-11-10 21:06:49 -08:00
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/require_pod_requests_limits.yaml")
|
2019-10-09 17:37:31 -07:00
|
|
|
}
|
2019-10-09 17:49:00 -07:00
|
|
|
|
|
|
|
func Test_require_probes(t *testing.T) {
|
2019-11-10 21:18:17 -08:00
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/require_probes.yaml")
|
2019-10-09 17:49:00 -07:00
|
|
|
}
|
2019-10-10 18:42:54 -07:00
|
|
|
|
2019-11-09 16:33:19 -08:00
|
|
|
func Test_validate_disallow_bind_mounts_fail(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/disallow_bind_mounts_fail.yaml")
|
2019-10-10 18:42:54 -07:00
|
|
|
}
|
|
|
|
|
2019-11-09 16:33:19 -08:00
|
|
|
func Test_validate_disallow_bind_mounts_pass(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/disallow_bind_mounts_pass.yaml")
|
2019-10-10 18:42:54 -07:00
|
|
|
}
|
2019-11-09 16:07:16 -08:00
|
|
|
|
2019-11-01 11:40:23 -07:00
|
|
|
func Test_validate_disallow_new_capabilities(t *testing.T) {
|
2019-11-09 16:07:16 -08:00
|
|
|
testScenario(t, "/test/scenarios/samples/best_practices/disallow_new_capabilities.yaml")
|
2019-11-01 11:40:23 -07:00
|
|
|
}
|
2019-11-01 13:31:08 -07:00
|
|
|
|
2019-11-11 18:51:21 -08:00
|
|
|
func Test_disallow_sysctls(t *testing.T) {
|
|
|
|
testScenario(t, "/test/scenarios/samples/best_practices/disallow_sysctls.yaml")
|
2019-11-11 17:17:09 -08:00
|
|
|
}
|
|
|
|
|
2019-11-11 18:51:21 -08:00
|
|
|
func Test_disallow_docker_sock_mount(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/disallow_docker_sock_mount.yaml")
|
2019-11-01 13:31:08 -07:00
|
|
|
}
|
2019-11-03 18:19:06 -08:00
|
|
|
|
2019-11-05 10:19:42 -08:00
|
|
|
func Test_validate_disallow_helm_tiller(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/scenario_validate_disallow_helm_tiller.yaml")
|
|
|
|
}
|
|
|
|
|
2019-11-08 19:02:49 -08:00
|
|
|
func Test_add_safe_to_evict(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/add_safe_to_evict.yaml")
|
2019-11-03 18:19:06 -08:00
|
|
|
}
|
2019-11-05 15:32:45 -08:00
|
|
|
|
|
|
|
func Test_add_safe_to_evict_annotation2(t *testing.T) {
|
2019-11-08 19:02:49 -08:00
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/add_safe_to_evict2.yaml")
|
2019-11-05 15:32:45 -08:00
|
|
|
}
|
2019-11-05 19:07:44 -08:00
|
|
|
|
2019-11-27 16:07:15 -08:00
|
|
|
func Test_add_safe_to_evict_annotation3(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/best_practices/add_safe_to_evict3.yaml")
|
|
|
|
}
|
|
|
|
|
2019-11-11 17:55:54 -08:00
|
|
|
func Test_validate_restrict_automount_sa_token_pass(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/more/restrict_automount_sa_token.yaml")
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_restrict_node_port(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/more/restrict_node_port.yaml")
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_validate_restrict_image_registries(t *testing.T) {
|
|
|
|
testScenario(t, "test/scenarios/samples/more/restrict_image_registries.yaml")
|
|
|
|
}
|
|
|
|
|
2019-11-05 19:07:44 -08:00
|
|
|
func Test_known_ingress(t *testing.T) {
|
2019-11-11 17:55:54 -08:00
|
|
|
testScenario(t, "test/scenarios/samples/more/restrict_ingress_classes.yaml")
|
2019-11-05 19:07:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
func Test_unknown_ingress(t *testing.T) {
|
2019-11-11 17:55:54 -08:00
|
|
|
testScenario(t, "test/scenarios/samples/more/unknown_ingress_class.yaml")
|
2019-11-05 19:07:44 -08:00
|
|
|
}
|