-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update random demo to the Faker Extension (#104)
* Update random demo to the Faker Extension * Fix Pretty rendering * Cleanup integration test * Update test/integration-tests/src/test/java/org/wiremock/docker/it/samples/RandomSampleTest.java
- Loading branch information
1 parent
81ac084
commit 4862fe5
Showing
10 changed files
with
89 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
FROM wiremock/wiremock | ||
FROM wiremock/wiremock:3.3.1-1 | ||
|
||
COPY stubs /home/wiremock | ||
|
||
ADD https://repo1.maven.org/maven2/com/opentable/wiremock-body-transformer/1.1.3/wiremock-body-transformer-1.1.3.jar /var/wiremock/extensions/ | ||
ADD https://repo1.maven.org/maven2/org/wiremock/extensions/wiremock-faker-extension-standalone/0.1.1/wiremock-faker-extension-standalone-0.1.1.jar /var/wiremock/extensions/ | ||
# TODO: Checksum Validation | ||
|
||
CMD ["--extensions", "com.opentable.extension.BodyTransformer"] | ||
CMD ["--global-response-templating", "--extensions", "org.wiremock.RandomExtension"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
# Sample - Random Response Field | ||
|
||
> **WARNING:** This sample uses the [WireMock Body Transformer](https://github.com/opentable/wiremock-body-transformer) extension. | ||
> This extension is currently archived and not supported. | ||
> No stability guaranteed provided. | ||
> Use the sample with caution | ||
We use WireMock Faker extension in this demo: | ||
|
||
To run: | ||
|
||
```shell | ||
docker build -t wiremock/random-data-demo . | ||
docker run --rm - p 8080:8080 wiremock/random-data-demo | ||
``` | ||
|
||
Then you can use the following endpoints: | ||
|
||
- '/user' - random user ID | ||
- '/user?pretty=true' - random user id with fancy layout | ||
- '/users.csv' - generate a CSV file with a random number of users |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "{{ random 'Name.first_name' }}", | ||
"surname": "{{ random 'Name.last_name' }}", | ||
"country": "{{ random 'Address.country' }}", | ||
"city": "{{ random 'Address.city' }}", | ||
"favorite_tool": "WireMock" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ID, First Name, Last Name, Country, City, Favorite Tool, | ||
{{#each (range 0 (randomInt lower=1 upper=20)) as |index|}}{{index}}, {{ random 'Name.first_name' }}, {{ random 'Name.last_name' }}, {{ random 'Address.country' }}, {{ random 'Address.city' }}, WireMock,{{/each}} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"mappings": [ | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"urlPath": "/user", | ||
"queryParameters" : { | ||
"pretty" : { | ||
"absent" : true | ||
} | ||
} | ||
}, | ||
"response": { | ||
"status": 200, | ||
"headers": { | ||
"Content-Type": "application/json" | ||
}, | ||
"jsonBody": { | ||
"name": "{{ random 'Name.first_name' }}", | ||
"surname": "{{ random 'Name.last_name' }}", | ||
"country": "{{ random 'Address.country' }}", | ||
"city": "{{ random 'Address.city' }}", | ||
"favorite_tool": "WireMock" | ||
} | ||
} | ||
}, | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"urlPath": "/user", | ||
"queryParameters" : { | ||
"pretty" : { | ||
"equalTo" : "true" | ||
} | ||
} | ||
}, | ||
"response": { | ||
"status": 200, | ||
"headers": { | ||
"Content-Type": "application/json" | ||
}, | ||
"bodyFileName": "user.json" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"url": "/users" | ||
}, | ||
"response": { | ||
"status": 200, | ||
"headers": { | ||
"Content-Type": "text/csv" | ||
}, | ||
"bodyFileName": "users.csv.template" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters