Skip to content

Commit

Permalink
docs: made changes according to comments
Browse files Browse the repository at this point in the history
Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com>
  • Loading branch information
PranshuSrivastava committed Feb 12, 2024
1 parent cdf9466 commit 4a0908e
Show file tree
Hide file tree
Showing 17 changed files with 4,314 additions and 1,320 deletions.
29 changes: 18 additions & 11 deletions spring-petclinic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
This is a petclinic app where you can record testcases and mocks by interacting with the UI, and then test them using Keploy.
This project has two parts - the frontend and backend, since Keploy is a backend testing platform, we need to start the backend part of the project using Keploy and run the frontend as it is.

First, you need to install Keploy. For that you can use the command below:

```
curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh
```

## Setup the frontend

```
Expand All @@ -20,20 +26,15 @@ npm i
```
npm run start
```
## Spin up the database

```
docker run -e POSTGRES_USER=petclinic -e POSTGRES_PASSWORD=petclinic -e POSTGRES_DB=petclinic -p 5432:5432 --net keploy-network --name mypostgres postgres:15.2
```

You can start the backend using Keploy in 2 ways:
- [Using Keploy's binary](#binary-guide)
- [Using Keploy's docker image](#docker-guide)

But first, you need to install Keploy. For that you can use the command below:
Lets's move to the backend directory and get started.

```
curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh
cd samples-java/spring-petclinic/spring-petclinic-rest
```

# Instructions For Starting Using Binary <a name="binary-guide"></a>
Expand All @@ -46,16 +47,17 @@ Prerequisites For Binary:
## Setup the backend

```
cd samples-java/spring-petclinic/spring-petclinic-rest
mvn clean install -Dmaven.test.skip=true
```

You also need to update the postgresql properties, go to
## Spin up the database

```
spring-petclinic/spring-petclinic-rest/src/main/resources/application-postgresql.properties
docker run -e POSTGRES_USER=petclinic -e POSTGRES_PASSWORD=petclinic -e POSTGRES_DB=petclinic -p 5432:5432 --name mypostgres postgres:15.2
```

You also need to update the postgresql properties, go to
`spring-petclinic/spring-petclinic-rest/src/main/resources/application-postgresql.properties`
and change

```
Expand All @@ -67,6 +69,11 @@ to
```
spring.datasource.url=jdbc:postgresql://localhost:5432/petclinic
```
and then build the jar again using

```
mvn clean install -Dmaven.test.skip=true
```

## Recording the testcases with Keploy

Expand Down Expand Up @@ -99,4 +106,4 @@ keploy test -c "docker compose up" --containerName javaApp --buildDelay 50s --de
Here `delay` is the time it takes for your application to get started, after which Keploy will start running the testcases. If your application takes longer than 10s to get started, you can change the `delay` accordingly.
`buildDelay` is the time that it takes for the image to get built. This is useful when you are building the docker image from your docker compose file itself.

Hope this helps you out, if you still have any questions, reach out to us on our [Slack](https://join.slack.com/t/keploy/shared_invite/zt-12rfbvc01-o54cOG0X1G6eVJTuI_orSA)
Hope this helps you out, if you still have any questions, reach out to us on our [Slack](https://join.slack.com/t/keploy/shared_invite/zt-12rfbvc01-o54cOG0X1G6eVJTuI_orSA)
2,070 changes: 1,054 additions & 1,016 deletions spring-petclinic/spring-petclinic-rest/keploy/test-set-0/mocks.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,26 @@ spec:
method: GET
proto_major: 1
proto_minor: 1
url: http://localhost:9967/petclinic/api/pettypes
url: http://localhost:9966/petclinic/api/pettypes
header:
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Host: localhost:9967
Origin: http://localhost:59555
Referer: http://localhost:59555/
Sec-Ch-Ua: '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"'
Host: localhost:9966
Origin: http://localhost:4200
Referer: http://localhost:4200/
Sec-Ch-Ua: '"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"'
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: '"macOS"'
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-site
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
body: ""
body_type: ""
timestamp: 2023-12-09T06:29:56.173072949Z
timestamp: 2024-02-12T16:54:21.054666137+05:30
host: ""
resp:
status_code: 404
header:
Expand All @@ -34,7 +35,7 @@ spec:
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: keep-alive
Content-Length: "0"
Date: Sat, 09 Dec 2023 06:29:56 GMT
Date: Mon, 12 Feb 2024 11:24:21 GMT
Expires: "0"
Keep-Alive: timeout=60
Pragma: no-cache
Expand All @@ -47,27 +48,27 @@ spec:
status_message: ""
proto_major: 0
proto_minor: 0
timestamp: 2023-12-09T06:29:58.310490877Z
timestamp: 2024-02-12T16:54:23.272606779+05:30
objects: []
assertions:
noise:
header.Access-Control-Expose-Headers: []
header.Date: []
created: 1702103398
created: 1707737063
curl: |
curl --request GET \
--url http://localhost:9967/petclinic/api/pettypes \
--header 'Sec-Ch-Ua-Mobile: ?0' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Sec-Fetch-Site: same-site' \
--url http://localhost:9966/petclinic/api/pettypes \
--header 'Referer: http://localhost:4200/' \
--header 'Accept-Language: en-US,en;q=0.9' \
--header 'Sec-Ch-Ua-Platform: "macOS"' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Origin: http://localhost:59555' \
--header 'Sec-Ch-Ua: "Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"' \
--header 'Host: localhost:9966' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' \
--header 'Connection: keep-alive' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
--header 'Host: localhost:9967' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Ch-Ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
--header 'Referer: http://localhost:59555/' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Ch-Ua-Mobile: ?0' \
--header 'Origin: http://localhost:4200' \
--header 'Sec-Fetch-Site: same-site' \
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@ name: test-10
spec:
metadata: {}
req:
method: PUT
method: POST
proto_major: 1
proto_minor: 1
url: http://localhost:9967/petclinic/api/pettypes/1
url: http://localhost:9966/petclinic/api/vets
header:
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Length: "22"
Content-Length: "70"
Content-Type: application/json
Host: localhost:9967
Origin: http://localhost:59555
Referer: http://localhost:59555/
Sec-Ch-Ua: '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"'
Host: localhost:9966
Origin: http://localhost:4200
Referer: http://localhost:4200/
Sec-Ch-Ua: '"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"'
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: '"macOS"'
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-site
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
body: '{"id":1,"name":"Cats"}'
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
body: '{"id":null,"firstName":"Alice ","lastName":"Hopkins","specialties":[]}'
body_type: ""
timestamp: 2023-12-09T06:32:02.104894269Z
timestamp: 2024-02-12T16:55:00.533630021+05:30
host: ""
resp:
status_code: 204
status_code: 400
header:
Access-Control-Allow-Origin: '*'
Access-Control-Expose-Headers: errors, content-type
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: keep-alive
Content-Type: application/json
Date: Sat, 09 Dec 2023 06:32:02 GMT
Content-Length: "0"
Date: Mon, 12 Feb 2024 11:25:00 GMT
Errors: '[{"objectName":"vetDto","fieldName":"firstName","fieldValue":"Alice ","errorMessage":"must match \"^[a-zA-Z]*$\""}]'
Expires: "0"
Keep-Alive: timeout=60
Pragma: no-cache
Vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers
X-Content-Type-Options: nosniff
Expand All @@ -49,29 +49,29 @@ spec:
status_message: ""
proto_major: 0
proto_minor: 0
timestamp: 2023-12-09T06:32:02.135805046Z
timestamp: 2024-02-12T16:55:03.593634538+05:30
objects: []
assertions:
noise:
header.Access-Control-Expose-Headers: []
header.Date: []
created: 1702103522
created: 1707737103
curl: |-
curl --request PUT \
--url http://localhost:9967/petclinic/api/pettypes/1 \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
--header 'Sec-Ch-Ua-Mobile: ?0' \
curl --request POST \
--url http://localhost:9966/petclinic/api/vets \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' \
--header 'Content-Type: application/json' \
--header 'Host: localhost:9967' \
--header 'Origin: http://localhost:59555' \
--header 'Accept-Language: en-US,en;q=0.9' \
--header 'Connection: keep-alive' \
--header 'Referer: http://localhost:59555/' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Sec-Fetch-Site: same-site' \
--header 'Sec-Ch-Ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Host: localhost:9966' \
--header 'Referer: http://localhost:4200/' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Sec-Ch-Ua-Platform: "macOS"' \
--data '{"id":1,"name":"Cats"}'
--header 'Sec-Ch-Ua: "Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"' \
--header 'Sec-Ch-Ua-Mobile: ?0' \
--header 'Origin: http://localhost:4200' \
--header 'Accept-Language: en-US,en;q=0.9' \
--header 'Connection: keep-alive' \
--header 'Sec-Fetch-Site: same-site' \
--data '{"id":null,"firstName":"Alice ","lastName":"Hopkins","specialties":[]}'
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,77 @@ name: test-11
spec:
metadata: {}
req:
method: GET
method: POST
proto_major: 1
proto_minor: 1
url: http://localhost:9967/petclinic/api/pettypes
url: http://localhost:9966/petclinic/api/owners
header:
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Host: localhost:9967
Origin: http://localhost:59555
Referer: http://localhost:59555/
Sec-Ch-Ua: '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"'
Content-Length: "155"
Content-Type: application/json
Host: localhost:9966
Origin: http://localhost:4200
Referer: http://localhost:4200/
Sec-Ch-Ua: '"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"'
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: '"macOS"'
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-site
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
body: ""
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
body: '{"id":null,"firstName":"Joe","lastName":"Hopkins","address":"24th Main Street, Something Street","city":"Los Angeles, California","telephone":"9090812030"}'
body_type: ""
timestamp: 2023-12-09T06:32:02.135472827Z
timestamp: 2024-02-12T16:55:50.028129439+05:30
host: ""
resp:
status_code: 200
status_code: 201
header:
Access-Control-Allow-Origin: '*'
Access-Control-Expose-Headers: errors, content-type
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: keep-alive
Content-Type: application/json
Date: Sat, 09 Dec 2023 06:32:02 GMT
Date: Mon, 12 Feb 2024 11:25:50 GMT
Expires: "0"
Keep-Alive: timeout=60
Location: /api/owners/2
Pragma: no-cache
Vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Xss-Protection: "0"
body: '[{"name":"Cats","id":1}]'
body: '{"firstName":"Joe","lastName":"Hopkins","address":"24th Main Street, Something Street","city":"Los Angeles, California","telephone":"9090812030","id":2,"pets":[]}'
body_type: ""
status_message: ""
proto_major: 0
proto_minor: 0
timestamp: 2023-12-09T06:32:05.472305151Z
timestamp: 2024-02-12T16:55:50.095389844+05:30
objects: []
assertions:
noise:
body.telephone: []
header.Access-Control-Expose-Headers: []
header.Date: []
created: 1702103525
curl: |
curl --request GET \
--url http://localhost:9967/petclinic/api/pettypes \
--header 'Sec-Ch-Ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
--header 'Referer: http://localhost:59555/' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Sec-Ch-Ua-Platform: "macOS"' \
created: 1707737150
curl: |-
curl --request POST \
--url http://localhost:9966/petclinic/api/owners \
--header 'Origin: http://localhost:4200' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Sec-Fetch-Site: same-site' \
--header 'Sec-Ch-Ua-Mobile: ?0' \
--header 'Origin: http://localhost:59555' \
--header 'Sec-Fetch-Mode: cors' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' \
--header 'Connection: keep-alive' \
--header 'Accept-Language: en-US,en;q=0.9' \
--header 'Host: localhost:9967' \
--header 'Host: localhost:9966' \
--header 'Accept: application/json, text/plain, */*' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
--header 'Referer: http://localhost:4200/' \
--header 'Sec-Ch-Ua-Mobile: ?0' \
--header 'Sec-Fetch-Site: same-site' \
--header 'Sec-Ch-Ua-Platform: "macOS"' \
--header 'Sec-Ch-Ua: "Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Accept-Language: en-US,en;q=0.9' \
--header 'Content-Type: application/json' \
--data '{"id":null,"firstName":"Joe","lastName":"Hopkins","address":"24th Main Street, Something Street","city":"Los Angeles, California","telephone":"9090812030"}'
Loading

0 comments on commit 4a0908e

Please sign in to comment.