-
Notifications
You must be signed in to change notification settings - Fork 13
/
test-stub-transformer.sh
executable file
·41 lines (33 loc) · 1.19 KB
/
test-stub-transformer.sh
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
#!/bin/bash
set -e
source test-helpers.sh
PROXY_BASE_URL="https://wiremock.org"
WIREMOCK_BASE_URL=http://localhost:8080
launchWiremock
echo -e "done\n\nCreating proxy mapping"
curl -s -d '{
"request": { "urlPattern": ".*" },
"response": {
"proxyBaseUrl": "'${PROXY_BASE_URL}'"
}
}' http://localhost:8080/__admin/mappings > /dev/null
echo -e "done\n\nMaking request"
TEST_TOKEN='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.XbPfbIHMI6arZ3Y922BhjWgQzWXcXNrz0ogtVhfEd2o'
curl -s -H "Authorization: Bearer ${TEST_TOKEN}" "${WIREMOCK_BASE_URL}/robots.txt?foo=bar" > /dev/null
REQUEST_JSON='{
"outputFormat": "full",
"persist": false,
"transformers": ["jwt-stub-mapping-transformer"],
"transformerParameters": {
"payloadFields": ["iat", "user"]
},
"captureHeaders": {
"Host": { "caseInsensitive": true },
"Authorization": { "caseInsensitive": true }
},
"extractBodyCriteria": {
"textSizeThreshold": "2000"
}
}'
echo -e "done\n\nCalling snapshot API with '${REQUEST_JSON}'"
curl -X POST -d "${REQUEST_JSON}" "${WIREMOCK_BASE_URL}/__admin/recordings/snapshot"