Skip to content

Commit

Permalink
Add test-cases for OpenAPI validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tellet authored and tellet committed Mar 13, 2020
1 parent 945bbc7 commit 2da6bf9
Show file tree
Hide file tree
Showing 24 changed files with 818 additions and 7 deletions.
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
spec:
host: virtual-server.example.com
routes:
- path: "/canned-response"
action:
return:
code: "301"
type: 100
body: True
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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"
errorPages:
- codes: 308
redirect:
code: "101"
url: False
action:
pass: backend1
- path: "/backend2"
errorPages:
- codes: 502
return:
code: "100"
type: 0
body: False
headers:
- name: True
value: False
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server
spec:
host: virtual-server.example.com
routes:
- path: "/custom-redirect"
action:
redirect:
code: 304
url: "http://example.com"
- path: "/default-redirect"
action:
redirect:
code: "code"
url: 100
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServerRoute
metadata:
name: backends
spec:
host: virtual-server-route.example.com
subroutes:
- path: "/backends/canned-response"
action:
return:
code: "301"
type: 100
body: True
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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"
errorPages:
- codes: 308
redirect:
code: "101"
url: False
action:
pass: backend1
- path: "/backends/backend3"
errorPages:
- codes: 502
return:
code: "100"
type: 0
body: False
headers:
- name: True
value: False
action:
pass: backend3
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServerRoute
metadata:
name: backends
spec:
host: virtual-server-route.example.com
subroutes:
- path: "/backends/custom-redirect"
action:
redirect:
code: 304
url: "http://example.com"
- path: "/backends/default-redirect"
action:
redirect:
code: "code"
url: 100
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServerRoute
metadata:
name: backend2
spec:
host: virtual-server-route.example.com
upstreams:
- name: backend2
service: backend2-svc
port: 80
sessionCookie:
name: True
path: 100
expires: False
domain: 0
httpOnly: "yes"
secure: "no"
healthCheck:
enable: "yes"
path: 200
interval: 1.5
jitter: 2.0
fails: "one"
passes: "one"
port: "80"
connect-timeout: False
read-timeout: 100
send-timeout: 200
headers:
- name: 100
value: 100
statusMatch: 100
slow-start: True
queue:
size: "one"
timeout: 1
subroutes:
- path: "/backend2"
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServerRoute
metadata:
name: backend2
spec:
host: virtual-server-route.example.com
upstreams:
- name: backend2
service: backend2-svc
port: 80
lb-method: False
max-fails: "10"
fail-timeout: 20
connect-timeout: 1.5
read-timeout: 2.0
send-timeout: 3.0
keepalive: "one"
max-conns: "two"
next-upstream: 100
next-upstream-timeout: False
next-upstream-tries: True
client-max-body-size: 10
buffers:
number: "1"
size: 10
buffer-size: 10
buffering: 20
tls: "yes"
subroutes:
- path: "/backend2"
action:
pass: backend2
14 changes: 14 additions & 0 deletions tests/data/virtual-server-route/route-single-invalid-openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServerRoute
metadata:
name: backend2
spec:
host: virtual-server-route.example.com
upstreams:
- name: backend2
service: backend2-svc
port: 80
subroutes:
- path: "/backend2"
action:
pass: 22
26 changes: 26 additions & 0 deletions tests/data/virtual-server-tls-redirect/virtual-server-invalid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server-tls
spec:
host: virtual-server-tls.example.com
tls:
secret: True
redirect:
enable: "True"
code: "308"
basedOn: True
upstreams:
- name: backend2
service: backend2-svc
port: 80
- name: backend1
service: backend1-svc
port: 80
routes:
- path: "/backend1"
action:
pass: backend1
- path: "/backend2"
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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
sessionCookie:
name: True
path: 100
expires: False
domain: 0
httpOnly: "yes"
secure: "no"
healthCheck:
enable: "yes"
path: 200
interval: 1.5
jitter: 2.0
fails: "one"
passes: "one"
port: "80"
connect-timeout: False
read-timeout: 100
send-timeout: 200
headers:
- name: 100
value: 100
statusMatch: 100
slow-start: True
queue:
size: "one"
timeout: 1
- name: backend1
service: backend1-svc
port: 80
sessionCookie:
name: True
path: 100
expires: False
domain: 0
httpOnly: "yes"
secure: "no"
healthCheck:
enable: "yes"
path: 200
interval: 1.5
jitter: 2.0
fails: "one"
passes: "one"
port: "80"
connect-timeout: False
read-timeout: 100
send-timeout: 200
headers:
- name: 100
value: 100
statusMatch: 100
slow-start: True
queue:
size: "one"
timeout: 1
routes:
- path: "/backend1"
action:
pass: backend1
- path: "/backend2"
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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
lb-method: False
max-fails: "10"
fail-timeout: 20
connect-timeout: 1.5
read-timeout: 2.0
send-timeout: 3.0
keepalive: "one"
max-conns: "two"
next-upstream: 100
next-upstream-timeout: False
next-upstream-tries: True
client-max-body-size: 10
buffers:
number: "1"
size: 10
buffer-size: 10
buffering: 20
tls: "yes"
- name: backend1
service: backend1-svc
port: 80
lb-method: False
max-fails: "10"
fail-timeout: 20
connect-timeout: 1.5
read-timeout: 2.0
send-timeout: 3.0
keepalive: "one"
max-conns: "two"
next-upstream: 100
next-upstream-timeout: False
next-upstream-tries: True
client-max-body-size: 10
buffers:
number: "1"
size: 10
buffer-size: 10
buffering: "yes"
tls: "no"
routes:
- path: "/backend1"
action:
pass: backend1
- path: "/backend2"
action:
pass: backend2
Loading

0 comments on commit 2da6bf9

Please sign in to comment.