@@ -4,11 +4,11 @@ This repository contains a sample project that demonstrates the integration of K
44
55## Prerequisites
66
7- Before getting started, make sure you have the following installed:
7+ Before getting started, ensure you have the following installed:
88
99- Latest version of JDK
10- - Install [ Keploy] ( https://keploy.io/docs/server/installation/ )
11- - Install [ Docker] ( https://docs.docker.com/engine/install/ ) (if you want to run application in docker).
10+ - [ Keploy] ( https://keploy.io/docs/server/installation/ )
11+ - [ Docker] ( https://docs.docker.com/engine/install/ ) (if you want to run the application in Docker)
1212- Postman for testing APIs
1313
1414## Getting Started
@@ -17,54 +17,23 @@ To get started, clone the repository:
1717
1818``` bash
1919git clone https://github.com/jaiakash/samples-java.git
20- cd spring-boot-jwt
20+ cd samples-java/ spring-boot-jwt
2121```
2222
23- ## API Endpoints
23+ ## Native Usage
2424
25- The following API endpoints are available :
25+ To run the application locally, follow these steps :
2626
27- #### Login
27+ 1 . Build the application:
2828
29- - POST ` /users/login `
30-
31- Authenticate a user and receive a JWT token.
32-
33- Request Body:
34-
35- ``` json
36- {
37- "username" : " your_username" ,
38- "password" : " your_password"
39- }
40- ```
41-
42- Response:
43-
44- ``` json
45- {
46- "token" : " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
47- }
48- ```
49-
50- #### Token Verification
51-
52- - POST ` /users/tokenVerification `
53-
54- Verify the validity of a JWT token.
55-
56- Request Header:
57-
58- ``` json
59- Authorization: Bearer <your_jwt_token_here>
29+ ``` bash
30+ mvn clean install
6031 ```
6132
62- Response :
33+ 2 . Run the application :
6334
64- ``` json
65- {
66- "isValid" : true
67- }
35+ ``` bash
36+ java -jar target/spring-boot-jwt.jar
6837 ```
6938
7039## Running with Docker
@@ -73,38 +42,46 @@ To run the application with Docker, follow these steps:
7342
74431 . Build the Docker image:
7544
76- ``` bash
77- docker build -t spring-boot-jwt .
78- ```
45+ ``` bash
46+ docker build -t spring-boot-jwt .
47+ ```
7948
80492 . Run the Docker container:
8150
82- ``` bash
83- docker run -p 8080:8080 spring-boot-jwt
84- ```
51+ ``` bash
52+ docker run -p 8080:8080 spring-boot-jwt
53+ ```
8554
8655The application will be accessible at ` http://localhost:8080 ` .
8756
8857## Integration with Keploy
8958
90- #### RECORD Mode
59+ ### RECORD Mode
60+
61+ 1 . To run the application, use:
62+
63+ #### Native Usage
9164
92- 1 . To run the application, run
65+ ``` bash
66+ keploy record -c " java -jar target/spring-boot-jwt.jar"
67+ ```
9368
94- ``` bash
95- keploy record -c " docker run -p 8080:8080 spring-boot-jwt"
96- ```
69+ #### Docker Usage
9770
98- 2 . To generate testcases, you can make API calls using Postman or ` curl ` :
71+ ``` bash
72+ keploy record -c " docker run -p 8080:8080 spring-boot-jwt"
73+ ```
74+
75+ 2 . To generate test cases, make API calls using Postman or ` curl ` :
9976
10077- Login
10178
10279 ``` bash
10380 curl --location --request POST ' http://localhost:8080/users/login' \
10481 --header ' Content-Type: application/json' \
10582 --data-raw ' {
106- 107- "password": "password"
83+ 84+ "password": "password"
10885 }'
10986 ```
11087
@@ -115,12 +92,21 @@ The application will be accessible at `http://localhost:8080`.
11592 --header ' Authorization: Bearer <your_jwt_token_here>'
11693 ```
11794
118- #### TEST mode
95+ ### TEST Mode
11996
12097To test the application, start Keploy in test mode. In the root directory, run the following command:
12198
99+ #### Native Usage
100+
101+ ``` bash
102+ keploy test -c " java -jar target/spring-boot-jwt.jar" --delay 30
103+ ```
104+
105+ #### Docker Usage
106+
122107``` bash
123108keploy test -c " docker run -p 8080:8080 spring-boot-jwt" --delay 30
124109```
125110
126111This command will run the tests and generate the report in the ` Keploy/reports ` directory in the current working directory.
112+
0 commit comments