@@ -4,11 +4,11 @@ This repository contains a sample project that demonstrates the integration of K
4
4
5
5
## Prerequisites
6
6
7
- Before getting started, make sure you have the following installed:
7
+ Before getting started, ensure you have the following installed:
8
8
9
9
- 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)
12
12
- Postman for testing APIs
13
13
14
14
## Getting Started
@@ -17,54 +17,23 @@ To get started, clone the repository:
17
17
18
18
``` bash
19
19
git clone https://github.com/jaiakash/samples-java.git
20
- cd spring-boot-jwt
20
+ cd samples-java/ spring-boot-jwt
21
21
```
22
22
23
- ## API Endpoints
23
+ ## Native Usage
24
24
25
- The following API endpoints are available :
25
+ To run the application locally, follow these steps :
26
26
27
- #### Login
27
+ 1 . Build the application:
28
28
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
60
31
```
61
32
62
- Response :
33
+ 2 . Run the application :
63
34
64
- ``` json
65
- {
66
- "isValid" : true
67
- }
35
+ ``` bash
36
+ java -jar target/spring-boot-jwt.jar
68
37
```
69
38
70
39
## Running with Docker
@@ -73,38 +42,46 @@ To run the application with Docker, follow these steps:
73
42
74
43
1 . Build the Docker image:
75
44
76
- ``` bash
77
- docker build -t spring-boot-jwt .
78
- ```
45
+ ``` bash
46
+ docker build -t spring-boot-jwt .
47
+ ```
79
48
80
49
2 . Run the Docker container:
81
50
82
- ``` bash
83
- docker run -p 8080:8080 spring-boot-jwt
84
- ```
51
+ ``` bash
52
+ docker run -p 8080:8080 spring-boot-jwt
53
+ ```
85
54
86
55
The application will be accessible at ` http://localhost:8080 ` .
87
56
88
57
## Integration with Keploy
89
58
90
- #### RECORD Mode
59
+ ### RECORD Mode
60
+
61
+ 1 . To run the application, use:
62
+
63
+ #### Native Usage
91
64
92
- 1 . To run the application, run
65
+ ``` bash
66
+ keploy record -c " java -jar target/spring-boot-jwt.jar"
67
+ ```
93
68
94
- ``` bash
95
- keploy record -c " docker run -p 8080:8080 spring-boot-jwt"
96
- ```
69
+ #### Docker Usage
97
70
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 ` :
99
76
100
77
- Login
101
78
102
79
``` bash
103
80
curl --location --request POST ' http://localhost:8080/users/login' \
104
81
--header ' Content-Type: application/json' \
105
82
--data-raw ' {
106
-
107
- "password": "password"
83
+
84
+ "password": "password"
108
85
}'
109
86
```
110
87
@@ -115,12 +92,21 @@ The application will be accessible at `http://localhost:8080`.
115
92
--header ' Authorization: Bearer <your_jwt_token_here>'
116
93
```
117
94
118
- #### TEST mode
95
+ ### TEST Mode
119
96
120
97
To test the application, start Keploy in test mode. In the root directory, run the following command:
121
98
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
+
122
107
``` bash
123
108
keploy test -c " docker run -p 8080:8080 spring-boot-jwt" --delay 30
124
109
```
125
110
126
111
This command will run the tests and generate the report in the ` Keploy/reports ` directory in the current working directory.
112
+
0 commit comments