generated from keploy/template
-
Notifications
You must be signed in to change notification settings - Fork 30
Keploy Integration - Added sample Java application using JWT Token #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jaiakash
wants to merge
9
commits into
keploy:main
Choose a base branch
from
jaiakash:sample-jwt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6d7f1ca
git: to new branch
jaiakash 65407cf
fix: readme file and token in header instead of body
jaiakash c73adcd
docs: update the docs for header
jaiakash 7f71580
fix: jwt verfication, add: error mssg, docs:docker instllation
jaiakash e3afa9d
docs: docker optional and mvn clean
jaiakash 1f224fc
feat: update employee manager (#77)
PranshuSrivastava 3aaa63e
feat: add spring-mysql-redis to samples java (#78)
Hermione2408 fd2af46
fix: readme steps
jaiakash ca282d9
Merge branch 'keploy:main' into sample-jwt
jaiakash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,33 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
This file contains hidden or 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,19 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
wrapperVersion=3.3.2 | ||
distributionType=only-script | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip |
This file contains hidden or 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,20 @@ | ||
# Use an official OpenJDK runtime as a parent image | ||
FROM openjdk:22-bookworm | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app | ||
|
||
# Install Maven | ||
RUN apt-get update && apt-get install -y maven | ||
|
||
# Copy the current directory contents into the container at /app | ||
COPY . /app/ | ||
|
||
# Run mvn clean install | ||
RUN mvn clean install | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 8080 | ||
|
||
# Run the application when the container launches | ||
CMD ["/usr/share/maven/bin/mvn", "spring-boot:run"] |
This file contains hidden or 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,112 @@ | ||
# Keploy Sample Java - JWT Token Verification and Spring Boot | ||
|
||
This repository contains a sample project that demonstrates the integration of Keploy with JWT (JSON Web Token) authentication in a Spring Boot application. | ||
|
||
## Prerequisites | ||
|
||
Before getting started, ensure you have the following installed: | ||
|
||
- Latest version of JDK | ||
- [Keploy](https://keploy.io/docs/server/installation/) | ||
- [Docker](https://docs.docker.com/engine/install/) (if you want to run the application in Docker) | ||
- Postman for testing APIs | ||
|
||
## Getting Started | ||
|
||
To get started, clone the repository: | ||
|
||
```bash | ||
git clone https://github.com/jaiakash/samples-java.git | ||
cd samples-java/spring-boot-jwt | ||
``` | ||
|
||
## Native Usage | ||
|
||
To run the application locally, follow these steps: | ||
|
||
1. Build the application: | ||
|
||
```bash | ||
mvn clean install | ||
``` | ||
|
||
2. Run the application: | ||
|
||
```bash | ||
java -jar target/spring-boot-jwt.jar | ||
``` | ||
|
||
## Running with Docker | ||
|
||
To run the application with Docker, follow these steps: | ||
|
||
1. Build the Docker image: | ||
|
||
```bash | ||
docker build -t spring-boot-jwt . | ||
``` | ||
|
||
2. Run the Docker container: | ||
|
||
```bash | ||
docker run -p 8080:8080 spring-boot-jwt | ||
``` | ||
|
||
The application will be accessible at `http://localhost:8080`. | ||
|
||
## Integration with Keploy | ||
jaiakash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### RECORD Mode | ||
|
||
1. To run the application, use: | ||
|
||
#### Native Usage | ||
|
||
```bash | ||
keploy record -c "java -jar target/spring-boot-jwt.jar" | ||
``` | ||
|
||
#### Docker Usage | ||
|
||
```bash | ||
keploy record -c "docker run -p 8080:8080 spring-boot-jwt" | ||
``` | ||
|
||
2. To generate test cases, make API calls using Postman or `curl`: | ||
|
||
- Login | ||
|
||
```bash | ||
curl --location --request POST 'http://localhost:8080/users/login' \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the native case removed ..? These should be the headings Prerequisites
we dont need API Endpoints/ Running with Docker section |
||
--header 'Content-Type: application/json' \ | ||
--data-raw '{ | ||
"username": "[email protected]", | ||
"password": "password" | ||
}' | ||
``` | ||
|
||
- Verify | ||
|
||
```bash | ||
curl --location --request POST 'http://localhost:8080/users/tokenVerification' \ | ||
jaiakash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
--header 'Authorization: Bearer <your_jwt_token_here>' | ||
``` | ||
|
||
### TEST Mode | ||
|
||
To test the application, start Keploy in test mode. In the root directory, run the following command: | ||
|
||
#### Native Usage | ||
|
||
```bash | ||
keploy test -c "java -jar target/spring-boot-jwt.jar" --delay 30 | ||
``` | ||
|
||
#### Docker Usage | ||
|
||
```bash | ||
keploy test -c "docker run -p 8080:8080 spring-boot-jwt" --delay 30 | ||
``` | ||
|
||
This command will run the tests and generate the report in the `Keploy/reports` directory in the current working directory. | ||
|
This file contains hidden or 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,44 @@ | ||
path: "" | ||
appId: 0 | ||
appName: "" | ||
command: ./mvnw spring-boot:run | ||
port: 0 | ||
dnsPort: 26789 | ||
proxyPort: 16789 | ||
debug: false | ||
disableTele: false | ||
jaiakash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
disableANSI: false | ||
containerName: "" | ||
networkName: "" | ||
buildDelay: 30 | ||
test: | ||
selectedTests: {} | ||
globalNoise: | ||
global: | ||
body: {"token": ["*"]} | ||
test-sets: {} | ||
delay: 5 | ||
apiTimeout: 5 | ||
skipCoverage: false | ||
coverageReportPath: "" | ||
ignoreOrdering: true | ||
mongoPassword: default@123 | ||
language: "" | ||
removeUnusedMocks: false | ||
fallBackOnMiss: false | ||
jacocoAgentPath: "" | ||
basePath: "" | ||
mocking: true | ||
ignoredTests: {} | ||
record: | ||
filters: [] | ||
recordTimer: 0s | ||
configPath: "" | ||
bypassRules: [] | ||
generateGithubActions: true | ||
keployContainer: keploy-v2 | ||
keployNetwork: keploy-network | ||
cmdType: native | ||
inCi: false | ||
|
||
# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.