diff --git a/src/components/QuickStartFilter.js b/src/components/QuickStartFilter.js index 8e86dfe54..68b036259 100644 --- a/src/components/QuickStartFilter.js +++ b/src/components/QuickStartFilter.js @@ -6,6 +6,8 @@ import {FaJava, FaLaptopCode, FaDocker, FaPython, FaCheck, FaArrowRight, FaArrow import {TbBrandCSharp} from "react-icons/tb"; import {IoLogoJavascript} from "react-icons/io5"; import {useColorMode} from "@docusaurus/theme-common"; +import {SiPerl} from "react-icons/si"; + export default function QuickstartFilter({defaultLanguage = null}) { const {colorMode} = useColorMode(); @@ -28,6 +30,7 @@ export default function QuickstartFilter({defaultLanguage = null}) { {name: "Java", icon: , color: "#007396"}, {name: "JS/TS", icon: , color: "#F7DF1E"}, {name: "C#", icon: , color: "#512BD4"}, + {name: "Perl", icon: , color: "#39457E"}, ]; const servers = [ diff --git a/src/components/QuickStartList.js b/src/components/QuickStartList.js index 17f9e6e03..6e389bc9a 100644 --- a/src/components/QuickStartList.js +++ b/src/components/QuickStartList.js @@ -395,6 +395,24 @@ const quickstarts = [ "A sample app to demonstrate Keploy integration capabilities using TypeScript and Nhost.", link: "/docs/quickstart/samples-typescript/#running-the-app-using-docker", }, + + // Perl List + { + title: "Perl + MongoDB", + language: "Perl", + server: "Local", + description: + "A sample URL Shortener app to demonstrate Keploy integration capabilities using Perl and MongoDB.", + link: "/docs/quickstart/perl-mongo/#running-app-locally-on-linuxwsl-", + }, + { + title: "Perl + MongoDB", + language: "Perl", + server: "Docker", + description: + "A sample URL Shortener app to demonstrate Keploy integration capabilities using Perl and MongoDB.", + link: "/docs/quickstart/perl-mongo/#running-app-using-docker-compose-", + }, ]; export default quickstarts; diff --git a/static/img/oss/perl-mongo-1.png b/static/img/oss/perl-mongo-1.png new file mode 100644 index 000000000..605ea28f0 Binary files /dev/null and b/static/img/oss/perl-mongo-1.png differ diff --git a/static/img/oss/perl-mongo-2.png b/static/img/oss/perl-mongo-2.png new file mode 100644 index 000000000..e8442bd03 Binary files /dev/null and b/static/img/oss/perl-mongo-2.png differ diff --git a/versioned_docs/version-4.0.0/quickstart/perl-mongo.md b/versioned_docs/version-4.0.0/quickstart/perl-mongo.md new file mode 100644 index 000000000..5fc24b42d --- /dev/null +++ b/versioned_docs/version-4.0.0/quickstart/perl-mongo.md @@ -0,0 +1,311 @@ +--- +id: perl-mongo +title: Sample Perl-MongoDB URL Shortener App +sidebar_label: Perl + MongoDB +description: The following sample app showcases how to use the Perl framework and the Keploy Platform. + +tags: + - perl + - quickstart + - samples + - examples + - tutorial + - perl-framework + - mongodb +keyword: + - Perl Framework + - MongoDB + - API Test generator + - Auto case generation +--- + +import Link from '@docusaurus/Link' +import InstallReminder from '@site/src/components/InstallReminder'; +import SectionDivider from '@site/src/components/SectionDivider'; + +## How to run the sample application Using Docker Compose ๐Ÿณ + +๐Ÿช„ In this guide, you will set up a Perl-based URL Shortener using MongoDB and learn how Keploy enables automated API testing through record and replay modes. ๐ŸŽข + + + +### Get Started! ๐ŸŽฌ + +Clone the repository and move to relevant folder + +```bash +git clone https://github.com/Akshat005Chaudhary/keploy-perl-mongodb-quickstart.git +cd keploy-perl-mongodb-quickstart +``` + +We will be using Docker compose to run the application as well as Mongo on Docker container. + +### Lights, Camera, Record! ๐ŸŽฅ + +Fire up the application and mongoDB instance with Keploy. Keep an eye on the two key flags: +`-c`: Command to run the app (e.g., `docker compose up`). + +`--container-name`: The container name in the `docker-compose.yml` for traffic interception. + +```bash +keploy record -c "docker compose up" --container-name=perl-app +``` + +![alt text](/img/oss/perl-mongo-1.png) + +๐Ÿ”ฅ Challenge time! Generate some test cases. How? Just **make some API calls**. Postman, Hoppscotch or even curl - take your pick! + +### Let's generate the testcases. + +Make API Calls using Postman or cURL command. Keploy with capture those calls to generate the test-suites containing testcases and data mocks. + +**1. POST /shorten** + +```bash +curl -X POST http://localhost:5000/shorten \ + -H "Content-Type: application/json" \ + -d '{"url":"https://keploy.io"}' +``` + +Here's a peek of what you get: + +```bash +{ + "code": "QWERTY", + "shortUrl": "http://localhost:5000QWERTY" +} +``` + +๐ŸŽ‰ Woohoo! With a simple API call, you've crafted a test case with a mock! Dive into the Keploy directory and feast your eyes on the newly minted `test-1.yml` and `mocks.yml` + +_Time to perform more API magic!_ +Follow the breadcrumbs... or Make more API Calls + +**2. Redirect Call** + +Suppose the received code is `QWERTY` + +```bash +curl -v http://localhost:5000/QWERTY +``` + +This is return 302 status code and redirect to the original url if code is correct. + +```bash +HTTP/1.1 302 Found +Location: https://keploy.io +``` + +**3. Check Stats** +```bash +curl http://localhost:5000/stats/QWERTY +``` + +This will return the stats of the short url. + +```bash +{ + "clicks": 1, + "code": "QWERTY", + "createdAt": "2026-01-30T06:47:03Z", + "originalUrl": "https://keploy.io" +} +``` + +**4. Negative Case** +```bash +curl http://localhost:5000/XXXXXX +``` + +This is give error: + +```bash +{ + "error": "Short URL code not found" +} +``` + +And once you are done, you can stop the recording and give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the **keploy** directory and you'll discover your handiwork in `tests` directory and `mocks.yml`. + +Want to see if everything works as expected? + +### Run Tests + +Time to put things to the test ๐Ÿงช + +```bash +keploy test -c "docker compose up" --container-name=perl-app --delay 10 +``` + +![alt text](/img/oss/perl-mongo-2.png) + +> The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking. + +### Wrapping it up ๐ŸŽ‰ + +Congrats on the journey so far! You've seen Keploy's power, flexed your coding muscles, and had a bit of fun too! Now, go out there and keep exploring, innovating, and creating! Remember, with the right tools and a sprinkle of fun, anything's possible.๐Ÿ˜Š๐Ÿš€ + +Happy coding! โœจ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ปโœจ + + + +## Running App Locally on Linux/WSL/macOS ๐Ÿง + +๐Ÿช„ In this guide, you will set up a Perl-based URL Shortener using MongoDB and learn how Keploy enables automated API testing through record and replay modes. ๐ŸŽข + + + +### Get Started! ๐ŸŽฌ + +Clone the repository and move to relevant folder + +```bash +git clone https://github.com/Akshat005Chaudhary/keploy-perl-mongodb-quickstart.git +cd keploy-perl-mongodb-quickstart +``` + +Make sure you have Perl installed ๐Ÿช, Docker set up ๐Ÿณ, and Keploy installed ๐Ÿฐ before proceeding. + +We'll be running our sample application right on Linux, but just to make things a tad more thrilling, we'll have the database (MongoDB) chill on Docker. Ready? Let's get the party started!๐ŸŽ‰ + +## Install cpanm + +Ubuntu: +```bash +sudo apt update +sudo apt install cpanminus -y +``` +MacOS: +```bash +brew install cpanminus +``` +Windows: +```bash +cpan App::cpanminus +``` + +## Install Dependencies + +```bash +cpanm --installdeps . +``` + +## Start the MongoDB container + +```bash +docker compose up -d mongo +``` + +## Confirm Server behavior + +```bash +perl app.pl daemon -l http://localhost:5000 +``` + +Should say: + +```bash +Web application available at http://localhost:5000 +``` + +### ๐Ÿ“ผ Roll the Tape - Recording Time! + +Ready, set, record! Here's how: + +```bash +keploy record -c "perl app.pl daemon -l http://localhost:5000" +``` + +![alt text](/img/oss/perl-mongo-1.png) + +Keep an eye out for the `-c `flag! It's the command charm to run the app. + +Alright, magician! With the app alive and kicking, let's weave some test cases. The spell? Making some API calls! Postman, Hoppscotch, or the classic curl - pick your wand. + +### Let's generate the testcases. + +Make API Calls using Postman or cURL command. Keploy with capture those calls to generate the test-suites containing testcases and data mocks. + +**1. POST /shorten** + +```bash +curl -X POST http://localhost:5000/shorten \ + -H "Content-Type: application/json" \ + -d '{"url":"https://keploy.io"}' +``` + +Here's a peek of what you get: + +```bash +{ + "code": "QWERTY", + "shortUrl": "http://localhost:5000QWERTY" +} +``` + +๐ŸŽ‰ Woohoo! With a simple API call, you've crafted a test case with a mock! Dive into the Keploy directory and feast your eyes on the newly minted `test-1.yml` and `mocks.yml` + +_Time to perform more API magic!_ +Follow the breadcrumbs... or Make more API Calls + +**2. Redirect Call** + +Suppose the received code is `QWERTY` + +```bash +curl -v http://localhost:5000/QWERTY +``` + +This is return 302 status code and redirect to the original url if code is correct. + +```bash +HTTP/1.1 302 Found +Location: https://keploy.io +``` + +**3. Check Stats** +```bash +curl http://localhost:5000/stats/QWERTY +``` + +This will return the stats of the short url. + +```bash +{ + "clicks": 1, + "code": "QWERTY", + "createdAt": "2026-01-30T06:47:03Z", + "originalUrl": "https://keploy.io" +} +``` + +**4. Negative Case** +```bash +curl http://localhost:5000/XXXXXX +``` + +This is give error: + +```bash +{ + "error": "Short URL code not found" +} +``` + +And once you are done, you can stop the recording and give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the **keploy** directory and you'll discover your handiwork in `tests` directory and `mocks.yml`. + +Want to see if everything works as expected? + +### Run Tests + +Time to put things to the test ๐Ÿงช + +```bash +keploy test -c "perl app.pl daemon -l http://localhost:5000" +``` + +![alt text](/img/oss/perl-mongo-2.png) + +### Wrapping it up ๐ŸŽ‰ + +Congrats on the journey so far! You've seen Keploy's power, flexed your coding muscles, and had a bit of fun too! Now, go out there and keep exploring, innovating, and creating! Remember, with the right tools and a sprinkle of fun, anything's possible.๐Ÿ˜Š๐Ÿš€ diff --git a/versioned_sidebars/version-4.0.0-sidebars.json b/versioned_sidebars/version-4.0.0-sidebars.json index 5ab6d0a00..c382d486a 100644 --- a/versioned_sidebars/version-4.0.0-sidebars.json +++ b/versioned_sidebars/version-4.0.0-sidebars.json @@ -117,6 +117,15 @@ "items": [ "quickstart/samples-csharp" ] + }, + { + "type": "category", + "label": "Perl", + "collapsible": true, + "collapsed": true, + "items": [ + "quickstart/perl-mongo" + ] } ] }, @@ -129,6 +138,26 @@ "ci-cd/jenkins" ] }, + { + "type": "category", + "label": "Test Coverage Integration", + "link": { + "type": "doc", + "id": "quickstart/code-coverage" + }, + "items": [ + "server/sdk-installation/go" + ] + }, + { + "type": "category", + "label": "CI/CD Integration", + "items": [ + "ci-cd/github", + "ci-cd/gitlab", + "ci-cd/jenkins" + ] + }, { "type": "category", "label": "Test Coverage Integration",