Skip to content

Commit 1138160

Browse files
committed
add e2e tests for tiered rate limits
1 parent 6efd4dc commit 1138160

18 files changed

+1369
-309
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: k8s.nginx.org/v1
2+
kind: Policy
3+
metadata:
4+
name: rate-limit-jwt-claim-sub-basic
5+
spec:
6+
rateLimit:
7+
rate: 1r/s
8+
key: ${jwt_claim_sub}
9+
zoneSize: 10M
10+
condition:
11+
jwt:
12+
match: Basic
13+
claim: user_details.level
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: k8s.nginx.org/v1
2+
kind: Policy
3+
metadata:
4+
name: rate-limit-jwt-claim-sub-basic
5+
spec:
6+
rateLimit:
7+
rate: 1r/s
8+
key: ${jwt_claim_sub}
9+
zoneSize: 10M
10+
condition:
11+
jwt:
12+
match: Basic
13+
claim: user_details.level
14+
default: true
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: k8s.nginx.org/v1
2+
kind: Policy
3+
metadata:
4+
name: rate-limit-jwt-claim-sub-bronze
5+
spec:
6+
rateLimit:
7+
rate: 5r/s
8+
key: ${jwt_claim_sub}
9+
zoneSize: 10M
10+
condition:
11+
jwt:
12+
match: Bronze
13+
claim: user_details.tier
14+
default: true
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: k8s.nginx.org/v1
2+
kind: Policy
3+
metadata:
4+
name: rate-limit-jwt-claim-sub-gold
5+
spec:
6+
rateLimit:
7+
rate: 15r/s
8+
key: ${jwt_claim_sub}
9+
zoneSize: 10M
10+
condition:
11+
jwt:
12+
match: Gold
13+
claim: user_details.tier
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: k8s.nginx.org/v1
2+
kind: Policy
3+
metadata:
4+
name: rate-limit-jwt-claim-sub-premium
5+
spec:
6+
rateLimit:
7+
rate: 5r/s
8+
key: ${jwt_claim_sub}
9+
zoneSize: 10M
10+
condition:
11+
jwt:
12+
match: Premium
13+
claim: user_details.level
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: k8s.nginx.org/v1
2+
kind: Policy
3+
metadata:
4+
name: rate-limit-jwt-claim-sub-premium
5+
spec:
6+
rateLimit:
7+
rate: 5r/s
8+
key: ${jwt_claim_sub}
9+
zoneSize: 10M
10+
condition:
11+
jwt:
12+
match: Premium
13+
claim: user_details.level
14+
default: true
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: k8s.nginx.org/v1
2+
kind: Policy
3+
metadata:
4+
name: rate-limit-jwt-claim-sub-silver
5+
spec:
6+
rateLimit:
7+
rate: 10r/s
8+
key: ${jwt_claim_sub}
9+
zoneSize: 10M
10+
condition:
11+
jwt:
12+
match: Silver
13+
claim: user_details.tier
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: k8s.nginx.org/v1
2+
kind: VirtualServerRoute
3+
metadata:
4+
name: backends
5+
spec:
6+
host: virtual-server-route.example.com
7+
upstreams:
8+
- name: backend1
9+
service: backend1-svc
10+
port: 80
11+
- name: backend3
12+
service: backend3-svc
13+
port: 80
14+
subroutes:
15+
- path: "/backends/backend1"
16+
policies:
17+
- name: rate-limit-jwt-claim-sub-basic
18+
- name: rate-limit-jwt-claim-sub-premium
19+
action:
20+
pass: backend1
21+
- path: "/backends/backend3"
22+
action:
23+
pass: backend3
24+
policies:
25+
- name: rate-limit-jwt-claim-sub-bronze
26+
- name: rate-limit-jwt-claim-sub-silver
27+
- name: rate-limit-jwt-claim-sub-gold
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: k8s.nginx.org/v1
2+
kind: VirtualServerRoute
3+
metadata:
4+
name: backends
5+
spec:
6+
host: virtual-server-route.example.com
7+
upstreams:
8+
- name: backend1
9+
service: backend1-svc
10+
port: 80
11+
- name: backend3
12+
service: backend3-svc
13+
port: 80
14+
subroutes:
15+
- path: "/backends/backend1"
16+
policies:
17+
- name: rate-limit-jwt-claim-sub-basic
18+
- name: rate-limit-jwt-claim-sub-premium
19+
action:
20+
pass: backend1
21+
- path: "/backends/backend3"
22+
action:
23+
pass: backend3
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: k8s.nginx.org/v1
2+
kind: VirtualServerRoute
3+
metadata:
4+
name: backends
5+
spec:
6+
host: virtual-server-route.example.com
7+
upstreams:
8+
- name: backend1
9+
service: backend1-svc
10+
port: 80
11+
- name: backend3
12+
service: backend3-svc
13+
port: 80
14+
subroutes:
15+
- path: "/backends/backend1"
16+
policies:
17+
- name: rate-limit-jwt-claim-sub-bronze
18+
- name: rate-limit-jwt-claim-sub-silver
19+
- name: rate-limit-jwt-claim-sub-gold
20+
action:
21+
pass: backend1
22+
- path: "/backends/backend3"
23+
action:
24+
pass: backend3

0 commit comments

Comments
 (0)