-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (150 loc) · 5.96 KB
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Test Docker Image
on:
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
actions: read
security-events: write
env:
REGISTRY: ghcr.io
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: lowercase github.repository
run: |
echo "IMAGE_NAME=`echo ${{ env.REGISTRY }}/${{ github.repository }}:${{ github.sha }} | tr '[:upper:]' '[:lower:]'`" >> ${GITHUB_ENV}
- uses: docker/build-push-action@v6
with:
tags: "${{ env.IMAGE_NAME }}"
platforms: linux/amd64
-
name: Scan for vulnerabilities
uses: crazy-max/ghaction-container-scan@v3
id: scan
env:
TRIVY_DISABLE_VEX_NOTICE: true
with:
image: ${{ env.IMAGE_NAME }}
annotations: true
severity_threshold: HIGH
dockerfile: ./Dockerfile
-
name: Upload SARIF file
if: ${{ steps.scan.outputs.sarif != '' }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
# cookie strategy
- name: Run Docker Image with Cookie Strategy
run: |
docker run --name statista_proxy -d -p80:80 \
-e STRATEGY=COOKIE \
-e OLD_DOMAIN=haproxy.com:443 -e NEW_DOMAIN=apache.org:443 \
-e COOKIE_STRATEGY_NAME="my_app_routing=new" \
"${{ env.IMAGE_NAME }}"
sleep 2
docker ps -a
docker logs statista_proxy
- name: Test Docker Image with Cookie Strategy without cookie
run: |
curl -Is localhost:80 | grep -i -e "x-proxy-flow: route-to-legacy"
- name: Test Docker Image with Cookie Strategy with cookie
run: |
curl -Is --cookie "my_app_routing=new" localhost:80 | grep -i -e "x-proxy-flow: route-to-new"
- name: Stop the Cookie Strategy Docker Image
if: success() || failure()
run: docker rm -f statista_proxy
# percentage strategy
- name: Run Docker Image with Percentage Strategy
run: |
docker run --name statista_proxy -d -p80:80 \
-e STRATEGY=PERCENTAGE \
-e OLD_DOMAIN=haproxy.com:443 -e NEW_DOMAIN=apache.org:443 \
-e PERCENTAGE_NEW=50 -e PERCENTAGE_OLD=50 \
-e COOKIE_PERCENTAGE_NAME=my_app \
"${{ env.IMAGE_NAME }}"
sleep 2
docker ps -a
docker logs statista_proxy
- name: Test Docker Image with Percentage Strategy backend selection
run: |
curl -Is localhost:80 | grep -i -e "x-proxy-flow: route-to-percentage"
- name: Test Docker Image with Percentage Strategy with sticky cookie on old domain
run: |
curl -Is localhost:80 --cookie "my_app=old_domain" | grep -i -e "server: Apache"
- name: Test Docker Image with Percentage Strategy with sticky cookie on new domain
run: |
curl -Is localhost:80 --cookie "my_app=new_domain" | grep -i -e "x-served-by: cache-"
- name: Test Docker Image with Percentage Strategy with round robin
# sadly we dont know which server serves us first, so we have to check both
run: |
curl -Is localhost:80 | grep -i -e "server:" -e "x-served-by:" -e "set-cookie: my_app=new_domain; path=/" -e "set-cookie: my_app=old_domain; path=/"
curl -Is localhost:80 | grep -i -e "server:" -e "x-served-by:" -e "set-cookie: my_app=new_domain; path=/" -e "set-cookie: my_app=old_domain; path=/"
- name: Stop the Percentage Strategy Docker Image
if: success() || failure()
run: docker rm -f statista_proxy
# variable validation
- name: Run Docker Image with Invalid new Percentage
run: |
set +e
docker run \
-e STRATEGY=PERCENTAGE \
-e OLD_DOMAIN=haproxy.com:443 -e NEW_DOMAIN=apache.org:443 \
-e PERCENTAGE_NEW=foo -e PERCENTAGE_OLD=50 \
-e COOKIE_PERCENTAGE_NAME=my_app \
"${{ env.IMAGE_NAME }}"
if [[ $? == 1 ]]; then exit 0; else exit 1; fi
- name: Run Docker Image with Invalid old Percentage
run: |
set +e
docker run \
-e STRATEGY=PERCENTAGE \
-e OLD_DOMAIN=haproxy.com:443 -e NEW_DOMAIN=apache.org:443 \
-e PERCENTAGE_NEW=50 -e PERCENTAGE_OLD=foo \
-e COOKIE_PERCENTAGE_NAME=my_app \
"${{ env.IMAGE_NAME }}"
if [[ $? == 1 ]]; then exit 0; else exit 1; fi
- name: Run Docker Image with Invalid old domain
run: |
set +e
docker run \
-e STRATEGY=PERCENTAGE \
-e NEW_DOMAIN=apache.org:443 \
-e COOKIE_PERCENTAGE_NAME=my_app \
"${{ env.IMAGE_NAME }}"
if [[ $? == 1 ]]; then exit 0; else exit 1; fi
- name: Run Docker Image with Invalid new domain
run: |
set +e
docker run \
-e STRATEGY=PERCENTAGE \
-e OLD_DOMAIN=haproxy.com:443 -e NEW_DOMAIN=apache.org:lol \
-e COOKIE_PERCENTAGE_NAME=my_app \
"${{ env.IMAGE_NAME }}"
if [[ $? == 1 ]]; then exit 0; else exit 1; fi
- name: Run Docker Image with Invalid server count
run: |
set +e
docker run \
-e STRATEGY=PERCENTAGE \
-e OLD_DOMAIN=haproxy.com:443 -e NEW_DOMAIN=apache.org:443 \
-e COOKIE_PERCENTAGE_NAME=my_app \
-e SERVER_COUNT=foo
"${{ env.IMAGE_NAME }}"
if [[ $? == 1 ]]; then exit 0; else exit 1; fi
- name: Run Docker Image with Invalid DNS Resolver
run: |
set +e
docker run \
-e STRATEGY=PERCENTAGE \
-e OLD_DOMAIN=haproxy.com:443 -e NEW_DOMAIN=apache.org:443 \
-e COOKIE_PERCENTAGE_NAME=my_app \
-e DNS_RESOLVER=foo
"${{ env.IMAGE_NAME }}"
if [[ $? == 1 ]]; then exit 0; else exit 1; fi