Skip to content

Commit

Permalink
Add tests for access-control using policies in vs and vsr (#1101)
Browse files Browse the repository at this point in the history
* update policy tests with scenarios for routes and sub-routes for vs and vsr respectively
  • Loading branch information
vepatel authored Aug 19, 2020
1 parent 31b80f3 commit aa6e36e
Show file tree
Hide file tree
Showing 20 changed files with 711 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server
spec:
host: virtual-server.example.com
upstreams:
- name: backend2
service: backend2-svc
port: 80
- name: backend1
service: backend1-svc
port: 80
routes:
- path: "/backend1"
policies:
- name: allow-policy
action:
pass: backend1
- path: "/backend2"
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server
spec:
host: virtual-server.example.com
upstreams:
- name: backend2
service: backend2-svc
port: 80
- name: backend1
service: backend1-svc
port: 80
routes:
- path: "/backend1"
policies:
- name: deny-policy
action:
pass: backend1
- path: "/backend2"
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server
spec:
host: virtual-server.example.com
upstreams:
- name: backend2
service: backend2-svc
port: 80
- name: backend1
service: backend1-svc
port: 80
routes:
- path: "/backend1"
policies:
- name: invalid-policy
action:
pass: backend1
- path: "/backend2"
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server
spec:
host: virtual-server.example.com
upstreams:
- name: backend2
service: backend2-svc
port: 80
- name: backend1
service: backend1-svc
port: 80
routes:
- path: "/backend1"
policies:
- name: allow-policy
- name: deny-policy
action:
pass: backend1
- path: "/backend2"
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server
spec:
host: virtual-server.example.com
policies:
- name: deny-policy
upstreams:
- name: backend2
service: backend2-svc
port: 80
- name: backend1
service: backend1-svc
port: 80
routes:
- path: "/backend1"
policies:
- name: allow-policy
action:
pass: backend1
- path: "/backend2"
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServerRoute
metadata:
name: backends
spec:
host: virtual-server-route.example.com
upstreams:
- name: backend1
service: backend1-svc
port: 80
- name: backend3
service: backend3-svc
port: 80
subroutes:
- path: "/backends/backend1"
policies:
- name: allow-policy
action:
pass: backend1
- path: "/backends/backend3"
action:
pass: backend3
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServerRoute
metadata:
name: backends
spec:
host: virtual-server-route.example.com
upstreams:
- name: backend1
service: backend1-svc
port: 80
- name: backend3
service: backend3-svc
port: 80
subroutes:
- path: "/backends/backend1"
policies:
- name: deny-policy
action:
pass: backend1
- path: "/backends/backend3"
action:
pass: backend3
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServerRoute
metadata:
name: backends
spec:
host: virtual-server-route.example.com
upstreams:
- name: backend1
service: backend1-svc
port: 80
- name: backend3
service: backend3-svc
port: 80
subroutes:
- path: "/backends/backend1"
policies:
- name: invalid-policy
action:
pass: backend1
- path: "/backends/backend3"
action:
pass: backend3
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServerRoute
metadata:
name: backends
spec:
host: virtual-server-route.example.com
upstreams:
- name: backend1
service: backend1-svc
port: 80
- name: backend3
service: backend3-svc
port: 80
subroutes:
- path: "/backends/backend1"
policies:
- name: deny-policy
- name: allow-policy
action:
pass: backend1
- path: "/backends/backend3"
action:
pass: backend3
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server-route
spec:
host: virtual-server-route.example.com
routes:
- path: "/backends"
policies:
- name: deny-policy
route: backends
- path: "/backend2"
route: backend2-namespace/backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server-route
spec:
host: virtual-server-route.example.com
policies:
- name: deny-policy
routes:
- path: "/backends"
route: backends
- path: "/backend2"
route: backend2-namespace/backend2
Loading

0 comments on commit aa6e36e

Please sign in to comment.