diff --git a/.github/License-Apache_2.0-blue.svg b/.github/License-Apache_2.0-blue.svg new file mode 100644 index 0000000..ca466ca --- /dev/null +++ b/.github/License-Apache_2.0-blue.svg @@ -0,0 +1 @@ +License: Apache 2.0LicenseApache 2.0 \ No newline at end of file diff --git a/.github/slack.svg b/.github/slack.svg new file mode 100644 index 0000000..6cb641a --- /dev/null +++ b/.github/slack.svg @@ -0,0 +1,20 @@ + + slack + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index d99979a..f14f414 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,23 @@ -

Keploy x Python Sample Applications

+

Keploy Python Sample Applications

- - -

+ -This repo contains the samples for [Keploy's](https://keploy.io) Python-based Application. Please feel free to contribute if you'd like submit a sample for another use-case or library. + + ->**Note** :- Issue Creation is disabled on this Repository, please visit [here](https://github.com/keploy/keploy/issues/new/choose) to submit Issue. + + +

+This repo contains the samples for [Keploy's](https://keploy.io) integration with Python-based Application. Please feel free to contribute if you'd like submit a sample for another use-case or library. -## Sample Apps with Keploy +> **Note** :- Issue Creation is disabled on this Repository, please visit [here](https://github.com/keploy/keploy/issues/new/choose) to submit Issue. -1. [Flask-Mongo](https://github.com/keploy/samples-python/tree/main/flask-mongo) - This application is a simple student management API built using Python's Flask framework and MongoDB for data storage. It allows you to perform basic CRUD (Create, Read, Update, Delete) operations on student records. The API supports CORS (Cross-Origin Resource Sharing) to facilitate cross-domain requests. +## Python Sample Apps with Keploy + +1. [Flask-Mongo](https://github.com/keploy/samples-python/tree/main/flask-mongo) - This application is a simple task management API built using Python's Flask framework and MongoDB for data storage. It allows you to perform basic CRUD (Create, Read, Update, Delete) operations on student records. The API supports CORS (Cross-Origin Resource Sharing) to facilitate cross-domain requests. 2. [Django-Postgres](https://github.com/keploy/samples-python/tree/main/django-postgres) - This is an application to perform basic CRUD (Create, Read, Update, Delete) operations on user records built using Python's Django framework and PostgreSQL for data storage. @@ -21,14 +25,17 @@ This repo contains the samples for [Keploy's](https://keploy.io) Python-based Ap 4. [FastAPI-Twilio](https://github.com/keploy/samples-python/tree/main/fastapi-twilio) - This application is a SMS sending API built using Python's FastAPI and Twilio for their SMS sharing service. +5. [Flask-Redis](https://github.com/keploy/samples-python/tree/main/flask-redis) - This Flask-based application provides a book management system utilizing Redis for caching and storage. It supports adding, retrieving, updating, and deleting book records, with optimized search functionality and cache management for improved performance. The API endpoints ensure efficient data handling and quick access to book information. + ## Community Support ❤️ -We'd love to collaborate with you to make Keploy great. To get started: -* [Slack](https://join.slack.com/t/keploy/shared_invite/zt-12rfbvc01-o54cOG0X1G6eVJTuI_orSA) - Discussions with the community and the team. -* [GitHub](https://github.com/keploy/keploy/issues) - For bug reports and feature requests. +### 🤔 Questions? + +Reach out to us. We're here to help! + +[![Slack](https://img.shields.io/badge/Slack-4A154B?style=for-the-badge&logo=slack&logoColor=white)](https://join.slack.com/t/keploy/shared_invite/zt-357qqm9b5-PbZRVu3Yt2rJIa6ofrwWNg) +[![LinkedIn](https://img.shields.io/badge/linkedin-%230077B5.svg?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/company/keploy/) +[![YouTube](https://img.shields.io/badge/YouTube-%23FF0000.svg?style=for-the-badge&logo=YouTube&logoColor=white)](https://www.youtube.com/channel/UC6OTg7F4o0WkmNtSoob34lg) +[![Twitter](https://img.shields.io/badge/Twitter-%231DA1F2.svg?style=for-the-badge&logo=Twitter&logoColor=white)](https://twitter.com/Keployio) -[![Generic badge](https://img.shields.io/badge/Slack-teal.svg?style=for-the-badge)](https://join.slack.com/t/keploy/shared_invite/zt-12rfbvc01-o54cOG0X1G6eVJTuI_orSA) -[![Generic badge](https://img.shields.io/badge/LinkedIn-blue.svg?style=for-the-badge)](https://www.linkedin.com/company/keploy/) -[![Generic badge](https://img.shields.io/badge/Youtube-teal.svg?style=for-the-badge)](https://www.youtube.com/channel/UC6OTg7F4o0WkmNtSoob34lg) -[![Generic badge](https://img.shields.io/badge/Twitter-blue.svg?style=for-the-badge)](https://twitter.com/Keployio) -[![Generic badge](https://img.shields.io/badge/Documentation-teal.svg?style=for-the-badge)](https://keploy.io/docs/) +### 💖 Let's Build Together! diff --git a/django-mongo/README.md b/django-mongo/README.md new file mode 100644 index 0000000..ea2afb3 --- /dev/null +++ b/django-mongo/README.md @@ -0,0 +1,92 @@ +# Inventory Management Application + +## Overview + +A simple Django + MongoDB inventory management application using mongoengine and Django REST Framework to test Keploy integration capabilities using Django and MongoDB. +The endpoints available will be: + +1. `GET /api/items/` - List all items +2. `POST /api/items/` - Create a new item +3. `GET /api/items//` - Retrieve an item by ID +4. `PUT /api/items//` - Update an item by ID +5. `DELETE /api/items//` - Delete an item by ID + +## Requirements + +- Python 3.x +- Django +- mongoengine +- djangorestframework + +## Setup Instructions + +1. Clone the repository and navigate to project directory. + ```bash + git clone https://github.com/keploy/samples-python.git + cd samples-python/django-mongo/django_mongo + ``` +2. Install Keploy. + ```bash + curl --silent -O -L https://keploy.io/install.sh && source install.sh + ``` +3. Start MongoDB instance. + ```bash + docker pull mongo + docker run --name mongodb -d -p 27017:27017 -v mongo_data:/data/db -e MONGO_INITDB_ROOT_USERNAME= -e MONGO_INITDB_ROOT_PASSWORD= mongo + ``` +4. Set up Django appllication. + ```bash + python3 -m virtualenv venv + source venv/bin/activate + pip3 install -r requirements.txt + ``` +5. Capture the testcases. + ```bash + keploy record -c "python3 manage.py runserver" + ``` +6. Generate testcases by making API calls. + ```bash + # List items + # GET /api/items/ + curl -X GET http://localhost:8000/api/items/ + ``` + ```bash + # Create Item + # POST /api/items/ + curl -X POST http://localhost:8000/api/items/ \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Gadget C", + "quantity": 200, + "description": "A versatile gadget with numerous features." + }' + ``` + ```bash + # Retrieve Item + # GET /api/items// + curl -X GET http://localhost:8000/api/items// + ``` + ```bash + # Update Item + # PUT /api/items// + curl -X PUT http://localhost:8000/api/items/6142d21e122bda15f6f87b1d/ \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Updated Widget A", + "quantity": 120, + "description": "An updated description for Widget A." + }' + ``` + ```bash + # Delete Item + # DELETE /api/items// + curl -X DELETE http://localhost:8000/api/items// + ``` + Replace `` with the actual ID of the item you want to retrieve, update, or delete. + +## Run the testcases + +Shut down MongoDB, Keploy doesn't need it during tests. +```bash +keploy test -c "python3 manage.py runserver" --delay 10 +``` \ No newline at end of file diff --git a/django-mongo/django_mongo/django_mongo/__init__.py b/django-mongo/django_mongo/django_mongo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django-mongo/django_mongo/django_mongo/asgi.py b/django-mongo/django_mongo/django_mongo/asgi.py new file mode 100644 index 0000000..0f6b170 --- /dev/null +++ b/django-mongo/django_mongo/django_mongo/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for django_mongo project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_mongo.settings') + +application = get_asgi_application() diff --git a/django-mongo/django_mongo/django_mongo/settings.py b/django-mongo/django_mongo/django_mongo/settings.py new file mode 100644 index 0000000..3ade7c6 --- /dev/null +++ b/django-mongo/django_mongo/django_mongo/settings.py @@ -0,0 +1,148 @@ +""" +Django settings for django_mongo project. + +Generated by 'django-admin startproject' using Django 5.1.2. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.1/ref/settings/ +""" + +from pathlib import Path +import mongoengine + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-3g@-x5(3t(i(p^qnu9lz3hk1u1yobrvwz($5^ucvnn0a6b$%ob' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'rest_framework', + 'inventory', +] + +REST_FRAMEWORK = { + 'DEFAULT_PERMISSION_CLASSES': [ + 'rest_framework.permissions.AllowAny', + ], +} + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'django_mongo.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'django_mongo.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases + +# DATABASES = { +# 'default': { +# 'ENGINE': 'django.db.backends.sqlite3', +# 'NAME': BASE_DIR / 'db.sqlite3', +# } +# } + + +# Password validation +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.1/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +# MongoDB configuration +MONGO_DB_NAME = 'inventory_db' +MONGO_USER = 'admin' +MONGO_PASSWORD = 'admin' +MONGO_HOST = 'localhost' +MONGO_PORT = 27017 + +# Connect to MongoDB +mongoengine.connect( + db=MONGO_DB_NAME, + username=MONGO_USER, + password=MONGO_PASSWORD, + host=MONGO_HOST, + port=MONGO_PORT +) \ No newline at end of file diff --git a/django-mongo/django_mongo/django_mongo/urls.py b/django-mongo/django_mongo/django_mongo/urls.py new file mode 100644 index 0000000..81af1ac --- /dev/null +++ b/django-mongo/django_mongo/django_mongo/urls.py @@ -0,0 +1,23 @@ +""" +URL configuration for django_mongo project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('api/', include('inventory.urls')), +] diff --git a/django-mongo/django_mongo/django_mongo/wsgi.py b/django-mongo/django_mongo/django_mongo/wsgi.py new file mode 100644 index 0000000..a13bfdb --- /dev/null +++ b/django-mongo/django_mongo/django_mongo/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for django_mongo project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_mongo.settings') + +application = get_wsgi_application() diff --git a/django-mongo/django_mongo/inventory/__init__.py b/django-mongo/django_mongo/inventory/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django-mongo/django_mongo/inventory/admin.py b/django-mongo/django_mongo/inventory/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/django-mongo/django_mongo/inventory/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/django-mongo/django_mongo/inventory/apps.py b/django-mongo/django_mongo/inventory/apps.py new file mode 100644 index 0000000..905749f --- /dev/null +++ b/django-mongo/django_mongo/inventory/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class InventoryConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'inventory' diff --git a/django-mongo/django_mongo/inventory/migrations/__init__.py b/django-mongo/django_mongo/inventory/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django-mongo/django_mongo/inventory/models.py b/django-mongo/django_mongo/inventory/models.py new file mode 100644 index 0000000..02dd773 --- /dev/null +++ b/django-mongo/django_mongo/inventory/models.py @@ -0,0 +1,7 @@ +from django.db import models +from mongoengine import Document, StringField, IntField + +class Item(Document): + name = StringField(required=True) + quantity = IntField(required=True) + description = StringField() \ No newline at end of file diff --git a/django-mongo/django_mongo/inventory/serializers.py b/django-mongo/django_mongo/inventory/serializers.py new file mode 100644 index 0000000..a178995 --- /dev/null +++ b/django-mongo/django_mongo/inventory/serializers.py @@ -0,0 +1,18 @@ +from rest_framework import serializers +from .models import Item + +class ItemSerializer(serializers.Serializer): + id = serializers.CharField(read_only=True) + name = serializers.CharField(required=True) + quantity = serializers.IntegerField(required=True) + description = serializers.CharField(required=False) + + def create(self, validated_data): + return Item(**validated_data).save() + + def update(self, instance, validated_data): + instance.name = validated_data.get('name', instance.name) + instance.quantity = validated_data.get('quantity', instance.quantity) + instance.description = validated_data.get('description', instance.description) + instance.save() + return instance diff --git a/django-mongo/django_mongo/inventory/tests.py b/django-mongo/django_mongo/inventory/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/django-mongo/django_mongo/inventory/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/django-mongo/django_mongo/inventory/urls.py b/django-mongo/django_mongo/inventory/urls.py new file mode 100644 index 0000000..f35e225 --- /dev/null +++ b/django-mongo/django_mongo/inventory/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from .views import ItemViewSet + +urlpatterns = [ + path('items/', ItemViewSet.as_view({'get': 'list', 'post': 'create'})), + path('items//', ItemViewSet.as_view({'get': 'retrieve', 'put': 'update', 'delete': 'destroy'})), +] \ No newline at end of file diff --git a/django-mongo/django_mongo/inventory/views.py b/django-mongo/django_mongo/inventory/views.py new file mode 100644 index 0000000..6974df7 --- /dev/null +++ b/django-mongo/django_mongo/inventory/views.py @@ -0,0 +1,49 @@ +from django.shortcuts import render +from rest_framework import viewsets +from rest_framework.response import Response +from rest_framework import status +from .models import Item +from .serializers import ItemSerializer + +class ItemViewSet(viewsets.ViewSet): + + def list(self, request): + items = Item.objects.all() + serializer = ItemSerializer(items, many=True) + return Response(serializer.data) + + def create(self, request): + serializer = ItemSerializer(data=request.data) + if serializer.is_valid(): + item = Item(**serializer.validated_data) + item.save() + return Response(serializer.data, status=status.HTTP_201_CREATED) + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + + def retrieve(self, request, pk=None): + try: + item = Item.objects.get(id=pk) + serializer = ItemSerializer(item) + return Response(serializer.data) + except Item.DoesNotExist: + return Response(status=status.HTTP_404_NOT_FOUND) + + def update(self, request, pk=None): + try: + item = Item.objects.get(id=pk) + serializer = ItemSerializer(item, data=request.data) + if serializer.is_valid(): + updated_item = serializer.save() # This will call the update method + return Response(ItemSerializer(updated_item).data) # Serialize the updated item + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + except Item.DoesNotExist: + return Response(status=status.HTTP_404_NOT_FOUND) + + + def destroy(self, request, pk=None): + try: + item = Item.objects.get(id=pk) + item.delete() + return Response(status=status.HTTP_204_NO_CONTENT) + except Item.DoesNotExist: + return Response(status=status.HTTP_404_NOT_FOUND) \ No newline at end of file diff --git a/django-mongo/django_mongo/keploy.yml b/django-mongo/django_mongo/keploy.yml new file mode 100755 index 0000000..481f26f --- /dev/null +++ b/django-mongo/django_mongo/keploy.yml @@ -0,0 +1,61 @@ +path: "" +appId: 0 +appName: django_mongo +command: python3 manage.py runserver +templatize: + testSets: [] +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: "" +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + test-sets: {} + delay: 5 + host: "" + port: 0 + apiTimeout: 5 + skipCoverage: false + coverageReportPath: "" + ignoreOrdering: true + mongoPassword: default@123 + language: "" + removeUnusedMocks: false + fallBackOnMiss: false + jacocoAgentPath: "" + basePath: "" + mocking: true + ignoredTests: {} + disableLineCoverage: false + disableMockUpload: true + useLocalMock: false + updateTemplate: false +record: + filters: [] + recordTimer: 0s +configPath: "" +bypassRules: [] +generateGithubActions: false +keployContainer: keploy-v2 +keployNetwork: keploy-network +cmdType: native +contract: + services: [] + tests: [] + path: "" + download: false + generate: false + driven: consumer + mappings: + servicesMapping: {} + self: "" +inCi: false + +# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file. diff --git a/django-mongo/django_mongo/keploy/test-set-0/mocks.yaml b/django-mongo/django_mongo/keploy/test-set-0/mocks.yaml new file mode 100755 index 0000000..50d9642 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/mocks.yaml @@ -0,0 +1,490 @@ +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-0 +spec: + metadata: + operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo|c|MongoEngine","version": "4.10.1|0.29.1"},"os": {"type": "Linux","name": "Linux","architecture": "x86_64","version": "6.5.0-1025-azure"},"platform": "CPython 3.12.1.final.0","env": {"container": {"runtime": "docker"}}}}, returnFieldsSelector: }' + type: config + requests: + - header: + length: 332 + requestId: 1804289383 + responseTo: 0 + Opcode: 2004 + message: + flags: 0 + collection_name: admin.$cmd + number_to_skip: 0 + number_to_return: -1 + query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo|c|MongoEngine","version":"4.10.1|0.29.1"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"6.5.0-1025-azure"},"platform":"CPython 3.12.1.final.0","env":{"container":{"runtime":"docker"}}}}' + return_fields_selector: "" + responses: + - header: + length: 329 + requestId: 125 + responseTo: 1804289383 + Opcode: 1 + message: + response_flags: 8 + cursor_id: 0 + starting_from: 0 + number_returned: 1 + documents: + - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1729364654276"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"20"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}' + read_delay: 640736 + created: 1729364654 + reqTimestampMock: 2024-10-19T19:04:14.276667841Z + resTimestampMock: 2024-10-19T19:04:14.277439441Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-1 +spec: + metadata: + operation: '{ OpMsg flags: 65536, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 134 + requestId: 846930886 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 65536 + sections: + - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }' + checksum: 0 + read_delay: 1789950 + responses: + - header: + length: 313 + requestId: 129 + responseTo: 846930886 + Opcode: 2013 + message: + flagBits: 2 + sections: + - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1729364664289"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"20"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 10010192973 + created: 1729364664 + reqTimestampMock: 2024-10-19T19:04:14.279291948Z + resTimestampMock: 2024-10-19T19:04:24.289653646Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-2 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 52 + requestId: 1714636915 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }' + checksum: 0 + read_delay: 10002211829 + responses: + - header: + length: 313 + requestId: 130 + responseTo: 1714636915 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1729364664291"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"21"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 238677 + created: 1729364664 + reqTimestampMock: 2024-10-19T19:04:24.291808444Z + resTimestampMock: 2024-10-19T19:04:24.292168839Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-3 +spec: + metadata: + operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo|c|MongoEngine","version": "4.10.1|0.29.1"},"os": {"type": "Linux","name": "Linux","architecture": "x86_64","version": "6.5.0-1025-azure"},"platform": "CPython 3.12.1.final.0","env": {"container": {"runtime": "docker"}}},"compression": [],"saslSupportedMechs": "admin.admin","speculativeAuthenticate": {"saslStart": {"$numberInt":"1"},"mechanism": "SCRAM-SHA-256","payload": {"$binary":{"base64":"biwsbj1hZG1pbixyPUlTVGRlTDJER25EeUd0MTMyM3dlbWo0d3BOTWZJRmhpalB6bThiUTk3ck09","subType":"00"}},"autoAuthorize": {"$numberInt":"1"},"options": {"skipEmptyExchange": true},"db": "admin"}}, returnFieldsSelector: }' + type: config + requests: + - header: + length: 598 + requestId: 1957747793 + responseTo: 0 + Opcode: 2004 + message: + flags: 0 + collection_name: admin.$cmd + number_to_skip: 0 + number_to_return: -1 + query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo|c|MongoEngine","version":"4.10.1|0.29.1"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"6.5.0-1025-azure"},"platform":"CPython 3.12.1.final.0","env":{"container":{"runtime":"docker"}}},"compression":[],"saslSupportedMechs":"admin.admin","speculativeAuthenticate":{"saslStart":{"$numberInt":"1"},"mechanism":"SCRAM-SHA-256","payload":{"$binary":{"base64":"biwsbj1hZG1pbixyPUlTVGRlTDJER25EeUd0MTMyM3dlbWo0d3BOTWZJRmhpalB6bThiUTk3ck09","subType":"00"}},"autoAuthorize":{"$numberInt":"1"},"options":{"skipEmptyExchange":true},"db":"admin"}}' + return_fields_selector: "" + responses: + - header: + length: 594 + requestId: 133 + responseTo: 1957747793 + Opcode: 1 + message: + response_flags: 8 + cursor_id: 0 + starting_from: 0 + number_returned: 1 + documents: + - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1729364666167"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"24"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"saslSupportedMechs":["SCRAM-SHA-256","SCRAM-SHA-1"],"speculativeAuthenticate":{"conversationId":{"$numberInt":"1"},"done":false,"payload":{"$binary":{"base64":"cj1JU1RkZUwyREduRHlHdDEzMjN3ZW1qNHdwTk1mSUZoaWpQem04YlE5N3JNPS9lU1YzSWZBb3ZIemlUWXFJVHAwbWx5ZjgySzdydlZFLHM9OUtUMFQ5b0YrUlQzV0dFWmZTb3gzNXNZYng2d2RlZVNEeXpHWWc9PSxpPTE1MDAw","subType":"00"}}},"ok":{"$numberDouble":"1.0"}}' + read_delay: 802600 + created: 1729364666 + reqTimestampMock: 2024-10-19T19:04:26.166927988Z + resTimestampMock: 2024-10-19T19:04:26.167862404Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-4 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"saslContinue":{"$numberInt":"1"},"conversationId":{"$numberInt":"1"},"payload":{"$binary":{"base64":"Yz1iaXdzLHI9SVNUZGVMMkRHbkR5R3QxMzIzd2VtajR3cE5NZklGaGlqUHptOGJROTdyTT0vZVNWM0lmQW92SHppVFlxSVRwMG1seWY4Mks3cnZWRSxwPXlERG1PYzA1ZWdwaEpaallKZTY2MnEyWGs3SHNKS1VDaU1vVVV6SW5VTVk9","subType":"00"}},"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 225 + requestId: 424238335 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"saslContinue":{"$numberInt":"1"},"conversationId":{"$numberInt":"1"},"payload":{"$binary":{"base64":"Yz1iaXdzLHI9SVNUZGVMMkRHbkR5R3QxMzIzd2VtajR3cE5NZklGaGlqUHptOGJROTdyTT0vZVNWM0lmQW92SHppVFlxSVRwMG1seWY4Mks3cnZWRSxwPXlERG1PYzA1ZWdwaEpaallKZTY2MnEyWGs3SHNKS1VDaU1vVVV6SW5VTVk9","subType":"00"}},"$db":"admin"} }' + checksum: 0 + read_delay: 5086782 + responses: + - header: + length: 125 + requestId: 134 + responseTo: 424238335 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"conversationId":{"$numberInt":"1"},"done":true,"payload":{"$binary":{"base64":"dj1VUzhRbi8wbTErM1JoS2tNNmZRaHFqK2lRdGxIaUtXendmL3VKZXgwSVZRPQ==","subType":"00"}},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 304558 + created: 1729364666 + reqTimestampMock: 2024-10-19T19:04:26.173006844Z + resTimestampMock: 2024-10-19T19:04:26.173411679Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-5 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"item","filter":{},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }], checksum: 0 }' + requests: + - header: + length: 112 + requestId: 719885386 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"item","filter":{},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + checksum: 0 + read_delay: 572687 + responses: + - header: + length: 224 + requestId: 135 + responseTo: 719885386 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"6713ff286b75650a56907678"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."}],"id":{"$numberLong":"0"},"ns":"inventory_db.item"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 492359 + created: 1729364666 + reqTimestampMock: 2024-10-19T19:04:26.174063774Z + resTimestampMock: 2024-10-19T19:04:26.174647202Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-6 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 65 + requestId: 1957747793 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }' + checksum: 0 + read_delay: 10001778949 + responses: + - header: + length: 314 + requestId: 136 + responseTo: 1957747793 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1729364674294"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"21"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 370160 + created: 1729364674 + reqTimestampMock: 2024-10-19T19:04:34.294047203Z + resTimestampMock: 2024-10-19T19:04:34.294532769Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-7 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }, { SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"671402e72887cb944c43b8ba"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."} ] }], checksum: 0 }' + requests: + - header: + length: 241 + requestId: 1350490027 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"insert":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + - '{ SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"671402e72887cb944c43b8ba"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."} ] }' + checksum: 0 + read_delay: 45695442201 + responses: + - header: + length: 45 + requestId: 157 + responseTo: 1350490027 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 498127 + created: 1729364711 + reqTimestampMock: 2024-10-19T19:05:11.870212614Z + resTimestampMock: 2024-10-19T19:05:11.870816598Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-8 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }], checksum: 0 }' + requests: + - header: + length: 140 + requestId: 1365180540 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + checksum: 0 + read_delay: 39270780350 + responses: + - header: + length: 224 + requestId: 174 + responseTo: 1365180540 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"6713ff286b75650a56907678"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."}],"id":{"$numberLong":"0"},"ns":"inventory_db.item"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 407362 + created: 1729364751 + reqTimestampMock: 2024-10-19T19:05:51.141679843Z + resTimestampMock: 2024-10-19T19:05:51.142418243Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-9 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }], checksum: 0 }' + requests: + - header: + length: 140 + requestId: 233665123 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + checksum: 0 + read_delay: 99571750729 + responses: + - header: + length: 224 + requestId: 215 + responseTo: 233665123 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"6713ff286b75650a56907678"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."}],"id":{"$numberLong":"0"},"ns":"inventory_db.item"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 421459 + created: 1729364850 + reqTimestampMock: 2024-10-19T19:07:30.714254912Z + resTimestampMock: 2024-10-19T19:07:30.714797717Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-10 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"update":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }, { SectionSingle identifier: updates , msgs: [ {"q":{"_id":{"$oid":"6713ff286b75650a56907678"}},"u":{"$set":{"name":"Updated Widget A","quantity":{"$numberInt":"120"},"description":"An updated description for Widget A."}},"multi":false,"upsert":true} ] }], checksum: 0 }' + requests: + - header: + length: 285 + requestId: 2145174067 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"update":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + - '{ SectionSingle identifier: updates , msgs: [ {"q":{"_id":{"$oid":"6713ff286b75650a56907678"}},"u":{"$set":{"name":"Updated Widget A","quantity":{"$numberInt":"120"},"description":"An updated description for Widget A."}},"multi":false,"upsert":true} ] }' + checksum: 0 + read_delay: 1179499 + responses: + - header: + length: 60 + requestId: 216 + responseTo: 2145174067 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"nModified":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 511395 + created: 1729364850 + reqTimestampMock: 2024-10-19T19:07:30.716062926Z + resTimestampMock: 2024-10-19T19:07:30.716661092Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-11 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }], checksum: 0 }' + requests: + - header: + length: 140 + requestId: 1369133069 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + checksum: 0 + read_delay: 49267790804 + responses: + - header: + length: 226 + requestId: 237 + responseTo: 1369133069 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"6713ff286b75650a56907678"},"name":"Updated Widget A","quantity":{"$numberInt":"120"},"description":"An updated description for Widget A."}],"id":{"$numberLong":"0"},"ns":"inventory_db.item"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 458793 + created: 1729364899 + reqTimestampMock: 2024-10-19T19:08:19.984540733Z + resTimestampMock: 2024-10-19T19:08:19.98511404Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-12 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"delete":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }, { SectionSingle identifier: deletes , msgs: [ {"q":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"0"}} ] }], checksum: 0 }' + requests: + - header: + length: 165 + requestId: 1125898167 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"delete":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + - '{ SectionSingle identifier: deletes , msgs: [ {"q":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"0"}} ] }' + checksum: 0 + read_delay: 750270 + responses: + - header: + length: 45 + requestId: 238 + responseTo: 1125898167 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 377687 + created: 1729364899 + reqTimestampMock: 2024-10-19T19:08:19.985934962Z + resTimestampMock: 2024-10-19T19:08:19.986405462Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-13 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"item","filter":{},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }], checksum: 0 }' + requests: + - header: + length: 112 + requestId: 2089018456 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"item","filter":{},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + checksum: 0 + read_delay: 8085196300 + responses: + - header: + length: 224 + requestId: 243 + responseTo: 2089018456 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"671402e72887cb944c43b8ba"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."}],"id":{"$numberLong":"0"},"ns":"inventory_db.item"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 486370 + created: 1729364908 + reqTimestampMock: 2024-10-19T19:08:28.071683686Z + resTimestampMock: 2024-10-19T19:08:28.072290581Z diff --git a/django-mongo/django_mongo/keploy/test-set-0/tests/test-1.yaml b/django-mongo/django_mongo/keploy/test-set-0/tests/test-1.yaml new file mode 100755 index 0000000..47b6d72 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/tests/test-1.yaml @@ -0,0 +1,44 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/api/items/ + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/7.68.0 + body: "" + timestamp: 2024-10-19T19:04:26.158535156Z + resp: + status_code: 200 + header: + Allow: GET, POST, HEAD, OPTIONS + Content-Length: "127" + Content-Type: application/json + Date: Sat, 19 Oct 2024 19:04:26 GMT + Referrer-Policy: same-origin + Server: WSGIServer/0.2 CPython/3.12.1 + Vary: Accept, Cookie + X-Content-Type-Options: nosniff + X-Frame-Options: DENY + body: '[{"id":"6713ff286b75650a56907678","name":"Gadget C","quantity":200,"description":"A versatile gadget with numerous features."}]' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-19T19:04:28.257078042Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1729364668 +curl: | + curl --request GET \ + --url http://localhost:8000/api/items/ \ + --header 'Accept: */*' \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/7.68.0' \ diff --git a/django-mongo/django_mongo/keploy/test-set-0/tests/test-2.yaml b/django-mongo/django_mongo/keploy/test-set-0/tests/test-2.yaml new file mode 100755 index 0000000..3c83896 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/tests/test-2.yaml @@ -0,0 +1,53 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-2 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/api/items/ + header: + Accept: '*/*' + Content-Length: "113" + Content-Type: application/json + Host: localhost:8000 + User-Agent: curl/7.68.0 + body: |- + { + "name": "Gadget C", + "quantity": 200, + "description": "A versatile gadget with numerous features." + } + timestamp: 2024-10-19T19:05:11.862316346Z + resp: + status_code: 201 + header: + Allow: GET, POST, HEAD, OPTIONS + Content-Length: "93" + Content-Type: application/json + Date: Sat, 19 Oct 2024 19:05:11 GMT + Referrer-Policy: same-origin + Server: WSGIServer/0.2 CPython/3.12.1 + Vary: Accept, Cookie + X-Content-Type-Options: nosniff + X-Frame-Options: DENY + body: '{"name":"Gadget C","quantity":200,"description":"A versatile gadget with numerous features."}' + status_message: Created + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-19T19:05:13.966578004Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1729364713 +curl: |- + curl --request POST \ + --url http://localhost:8000/api/items/ \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/7.68.0' \ + --header 'Accept: */*' \ + --data "{\n \"name\": \"Gadget C\",\n \"quantity\": 200,\n \"description\": \"A versatile gadget with numerous features.\"\n }" diff --git a/django-mongo/django_mongo/keploy/test-set-0/tests/test-3.yaml b/django-mongo/django_mongo/keploy/test-set-0/tests/test-3.yaml new file mode 100755 index 0000000..f9ef6f5 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/tests/test-3.yaml @@ -0,0 +1,44 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-3 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/api/items/6713ff286b75650a56907678/ + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/7.68.0 + body: "" + timestamp: 2024-10-19T19:05:51.140167751Z + resp: + status_code: 200 + header: + Allow: GET, PUT, DELETE, HEAD, OPTIONS + Content-Length: "125" + Content-Type: application/json + Date: Sat, 19 Oct 2024 19:05:51 GMT + Referrer-Policy: same-origin + Server: WSGIServer/0.2 CPython/3.12.1 + Vary: Accept, Cookie + X-Content-Type-Options: nosniff + X-Frame-Options: DENY + body: '{"id":"6713ff286b75650a56907678","name":"Gadget C","quantity":200,"description":"A versatile gadget with numerous features."}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-19T19:05:53.163490949Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1729364753 +curl: | + curl --request GET \ + --url http://localhost:8000/api/items/6713ff286b75650a56907678/ \ + --header 'User-Agent: curl/7.68.0' \ + --header 'Accept: */*' \ + --header 'Host: localhost:8000' \ diff --git a/django-mongo/django_mongo/keploy/test-set-0/tests/test-4.yaml b/django-mongo/django_mongo/keploy/test-set-0/tests/test-4.yaml new file mode 100755 index 0000000..5b841a2 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/tests/test-4.yaml @@ -0,0 +1,48 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-4 +spec: + metadata: {} + req: + method: PUT + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/api/items/6713ff286b75650a56907678/ + header: + Accept: '*/*' + Content-Length: "110" + Content-Type: application/json + Host: localhost:8000 + User-Agent: curl/7.68.0 + body: '{ "name": "Updated Widget A", "quantity": 120, "description": "An updated description for Widget A."}' + timestamp: 2024-10-19T19:07:30.712800581Z + resp: + status_code: 200 + header: + Allow: GET, PUT, DELETE, HEAD, OPTIONS + Content-Length: "127" + Content-Type: application/json + Date: Sat, 19 Oct 2024 19:07:30 GMT + Referrer-Policy: same-origin + Server: WSGIServer/0.2 CPython/3.12.1 + Vary: Accept, Cookie + X-Content-Type-Options: nosniff + X-Frame-Options: DENY + body: '{"id":"6713ff286b75650a56907678","name":"Updated Widget A","quantity":120,"description":"An updated description for Widget A."}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-19T19:07:32.720391721Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1729364852 +curl: |- + curl --request PUT \ + --url http://localhost:8000/api/items/6713ff286b75650a56907678/ \ + --header 'Accept: */*' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/7.68.0' \ + --data "{ \"name\": \"Updated Widget A\", \"quantity\": 120, \"description\": \"An updated description for Widget A.\"}" diff --git a/django-mongo/django_mongo/keploy/test-set-0/tests/test-5.yaml b/django-mongo/django_mongo/keploy/test-set-0/tests/test-5.yaml new file mode 100755 index 0000000..8bd7999 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/tests/test-5.yaml @@ -0,0 +1,43 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-5 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/api/items/6713ff286b75650a56907678/ + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/7.68.0 + body: "" + timestamp: 2024-10-19T19:08:19.983000488Z + resp: + status_code: 204 + header: + Allow: GET, PUT, DELETE, HEAD, OPTIONS + Content-Length: "0" + Date: Sat, 19 Oct 2024 19:08:19 GMT + Referrer-Policy: same-origin + Server: WSGIServer/0.2 CPython/3.12.1 + Vary: Accept, Cookie + X-Content-Type-Options: nosniff + X-Frame-Options: DENY + body: "" + status_message: No Content + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-19T19:08:22.044354383Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1729364902 +curl: | + curl --request DELETE \ + --url http://localhost:8000/api/items/6713ff286b75650a56907678/ \ + --header 'User-Agent: curl/7.68.0' \ + --header 'Accept: */*' \ + --header 'Host: localhost:8000' \ diff --git a/django-mongo/django_mongo/manage.py b/django-mongo/django_mongo/manage.py new file mode 100755 index 0000000..f3fd315 --- /dev/null +++ b/django-mongo/django_mongo/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_mongo.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/django-mongo/django_mongo/products.json b/django-mongo/django_mongo/products.json new file mode 100644 index 0000000..1099bda --- /dev/null +++ b/django-mongo/django_mongo/products.json @@ -0,0 +1,32 @@ +[ + { + "name": "Widget A", + "quantity": 100, + "description": "A high-quality widget that serves many purposes." + }, + { + "name": "Widget B", + "quantity": 150, + "description": "An essential widget for every toolkit." + }, + { + "name": "Gadget C", + "quantity": 200, + "description": "A versatile gadget with numerous features." + }, + { + "name": "Gadget D", + "quantity": 50, + "description": "A compact gadget perfect for small spaces." + }, + { + "name": "Tool E", + "quantity": 75, + "description": "A durable tool designed for heavy use." + }, + { + "name": "Tool F", + "quantity": 120, + "description": "An ergonomic tool for comfortable handling." + } +] \ No newline at end of file diff --git a/django-mongo/django_mongo/requirements.txt b/django-mongo/django_mongo/requirements.txt new file mode 100644 index 0000000..cc08838 --- /dev/null +++ b/django-mongo/django_mongo/requirements.txt @@ -0,0 +1,3 @@ +Django>=3.2,<4.0 +djangorestframework>=3.12,<4.0 +mongoengine>=0.20,<1.0 \ No newline at end of file diff --git a/django-postgres/README.md b/django-postgres/README.md index 91161b4..1f04ac2 100644 --- a/django-postgres/README.md +++ b/django-postgres/README.md @@ -20,7 +20,7 @@ git clone https://github.com/keploy/samples-python.git && cd samples-python/djan Keploy can be installed on Linux directly and on Windows with the help of WSL. Based on your system architecture, install the keploy latest binary release ```bash - curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh + curl -O https://keploy.io/install.sh && source install.sh keploy ``` @@ -92,13 +92,13 @@ This will return all the data saved in the database. ### Make a GET request to get a specific data ```bash -curl --location 'http://127.0.0.1:8000/user/c793c752-ad95-4cff-8cbe-5715a1e8a76e/' +curl --location 'http://127.0.0.1:8000/user/' ``` ### Make a PUT request to update a specific data ```bash -curl --location --request PUT 'http://127.0.0.1:8000/user/efbe12df-3cae-4cbc-b045-dc74840aa82b/' \ +curl --location --request PUT 'http://127.0.0.1:8000/user/' \ --header 'Content-Type: application/json' \ --data-raw ' { "name": "Jane Smith", @@ -111,7 +111,7 @@ curl --location --request PUT 'http://127.0.0.1:8000/user/efbe12df-3cae-4cbc-b04 ### Make a DELETE request to delete a specific data ```bash -curl --location --request DELETE 'http://127.0.0.1:8000/user/ee2af3fc-0503-4a6a-a452-b7d8c87a085b/' +curl --location --request DELETE 'http://127.0.0.1:8000/user/' ``` Now both these API calls were captured as **editable** testcases and written to `keploy/tests` folder. The keploy directory would also have `mocks` file that contains all the outputs of postgres operations. diff --git a/django-postgres/django_postgres/application/__pycache__/__init__.cpython-311.pyc b/django-postgres/django_postgres/application/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..cc721f2 Binary files /dev/null and b/django-postgres/django_postgres/application/__pycache__/__init__.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/application/__pycache__/admin.cpython-311.pyc b/django-postgres/django_postgres/application/__pycache__/admin.cpython-311.pyc new file mode 100644 index 0000000..d3fbbfc Binary files /dev/null and b/django-postgres/django_postgres/application/__pycache__/admin.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/application/__pycache__/apps.cpython-311.pyc b/django-postgres/django_postgres/application/__pycache__/apps.cpython-311.pyc new file mode 100644 index 0000000..485ad77 Binary files /dev/null and b/django-postgres/django_postgres/application/__pycache__/apps.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/application/__pycache__/models.cpython-311.pyc b/django-postgres/django_postgres/application/__pycache__/models.cpython-311.pyc new file mode 100644 index 0000000..3fff588 Binary files /dev/null and b/django-postgres/django_postgres/application/__pycache__/models.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/application/__pycache__/serializers.cpython-311.pyc b/django-postgres/django_postgres/application/__pycache__/serializers.cpython-311.pyc new file mode 100644 index 0000000..9dde198 Binary files /dev/null and b/django-postgres/django_postgres/application/__pycache__/serializers.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/application/__pycache__/urls.cpython-311.pyc b/django-postgres/django_postgres/application/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000..3c1e8f8 Binary files /dev/null and b/django-postgres/django_postgres/application/__pycache__/urls.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/application/__pycache__/views.cpython-311.pyc b/django-postgres/django_postgres/application/__pycache__/views.cpython-311.pyc new file mode 100644 index 0000000..48caa6d Binary files /dev/null and b/django-postgres/django_postgres/application/__pycache__/views.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/application/migrations/__pycache__/0001_initial.cpython-311.pyc b/django-postgres/django_postgres/application/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 0000000..b9c2567 Binary files /dev/null and b/django-postgres/django_postgres/application/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/application/migrations/__pycache__/__init__.cpython-311.pyc b/django-postgres/django_postgres/application/migrations/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..f590a08 Binary files /dev/null and b/django-postgres/django_postgres/application/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/django_postgres/__pycache__/__init__.cpython-311.pyc b/django-postgres/django_postgres/django_postgres/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..191a991 Binary files /dev/null and b/django-postgres/django_postgres/django_postgres/__pycache__/__init__.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/django_postgres/__pycache__/settings.cpython-311.pyc b/django-postgres/django_postgres/django_postgres/__pycache__/settings.cpython-311.pyc new file mode 100644 index 0000000..64c167b Binary files /dev/null and b/django-postgres/django_postgres/django_postgres/__pycache__/settings.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/django_postgres/__pycache__/urls.cpython-311.pyc b/django-postgres/django_postgres/django_postgres/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000..ec505fa Binary files /dev/null and b/django-postgres/django_postgres/django_postgres/__pycache__/urls.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/django_postgres/__pycache__/wsgi.cpython-311.pyc b/django-postgres/django_postgres/django_postgres/__pycache__/wsgi.cpython-311.pyc new file mode 100644 index 0000000..a163e98 Binary files /dev/null and b/django-postgres/django_postgres/django_postgres/__pycache__/wsgi.cpython-311.pyc differ diff --git a/django-postgres/django_postgres/docker-compose.yml b/django-postgres/django_postgres/docker-compose.yml index d81491d..e5a43b7 100644 --- a/django-postgres/django_postgres/docker-compose.yml +++ b/django-postgres/django_postgres/docker-compose.yml @@ -8,7 +8,7 @@ services: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres ports: - - "6000:5432" # Map the PostgreSQL port to the host machine + - "5432:5432" # Map the PostgreSQL port to the host machine volumes: - ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql diff --git a/django-postgres/django_postgres/keploy/test-set-0/mocks.yaml b/django-postgres/django_postgres/keploy/test-set-0/mocks.yaml deleted file mode 100755 index 4187b07..0000000 --- a/django-postgres/django_postgres/keploy/test-set-0/mocks.yaml +++ /dev/null @@ -1,815 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAACATSFi8= - postgresresponses: - - origin: server - message: - - type: binary - data: Tg== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAAPQADAAB1c2VyAHBvc3RncmVzAGRhdGFiYXNlAHVzZXJzZGIAY2xpZW50X2VuY29kaW5nAFVURjgAAA== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAABcAAAAKU0NSQU0tU0hBLTI1NgAA ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAADZTQ1JBTS1TSEEtMjU2AAAAACBuLCxuPSxyPUlBcFVSNDdPS0IvTnRCN2NWNjY0TWVGdA== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAAFwAAAALcj1JQXBVUjQ3T0tCL050QjdjVjY2NE1lRnQ3Q0J1eUNHRDBUNWk0WXVLSWloUXl5cXkscz12Z0RnUnRhbndUS1QreGVxbEVQTGl3PT0saT00MDk2 ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAAGxjPWJpd3Mscj1JQXBVUjQ3T0tCL050QjdjVjY2NE1lRnQ3Q0J1eUNHRDBUNWk0WXVLSWloUXl5cXkscD1jMWxBdFhXd01MOFFlWmhLdTAwQzdaUzl2VjZHUFBicmpuNVM2cGtpMFIwPQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAADYAAAAMdj1EQzJBR2lsbmxqMTludkhySEVtY0toMVBHTXlINU5uYWNuZVNnN2l3WERJPVIAAAAIAAAAAFMAAAAXaW5faG90X3N0YW5kYnkAb2ZmAFMAAAAZaW50ZWdlcl9kYXRldGltZXMAb24AUwAAABVUaW1lWm9uZQBFdGMvVVRDAFMAAAAbSW50ZXJ2YWxTdHlsZQBwb3N0Z3JlcwBTAAAAFGlzX3N1cGVydXNlcgBvbgBTAAAAFmFwcGxpY2F0aW9uX25hbWUAAFMAAAAmZGVmYXVsdF90cmFuc2FjdGlvbl9yZWFkX29ubHkAb2ZmAFMAAAAac2NyYW1faXRlcmF0aW9ucwA0MDk2AFMAAAAXRGF0ZVN0eWxlAElTTywgTURZAFMAAAAjc3RhbmRhcmRfY29uZm9ybWluZ19zdHJpbmdzAG9uAFMAAAAjc2Vzc2lvbl9hdXRob3JpemF0aW9uAHBvc3RncmVzAFMAAAAZY2xpZW50X2VuY29kaW5nAFVURjgAUwAAADJzZXJ2ZXJfdmVyc2lvbgAxNi4wIChEZWJpYW4gMTYuMC0xLnBnZGcxMjArMSkAUwAAABlzZXJ2ZXJfZW5jb2RpbmcAVVRGOABLAAAADAAAAJ1G35ynWgAAAAVJ ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAADBTRUxFQ1Qgc2V0X2NvbmZpZygnVGltZVpvbmUnLCAnVVRDJywgZmFsc2UpAA== - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAACMAAXNldF9jb25maWcAAAAAAAAAAAAAGf///////wAARAAAAA0AAQAAAANVVENDAAAADVNFTEVDVCAxAFMAAAARVGltZVpvbmUAVVRDAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAAkcKICAgICAgICAgICAgU0VMRUNUCiAgICAgICAgICAgICAgICBjLnJlbG5hbWUsCiAgICAgICAgICAgICAgICBDQVNFCiAgICAgICAgICAgICAgICAgICAgV0hFTiBjLnJlbGlzcGFydGl0aW9uIFRIRU4gJ3AnCiAgICAgICAgICAgICAgICAgICAgV0hFTiBjLnJlbGtpbmQgSU4gKCdtJywgJ3YnKSBUSEVOICd2JwogICAgICAgICAgICAgICAgICAgIEVMU0UgJ3QnCiAgICAgICAgICAgICAgICBFTkQsCiAgICAgICAgICAgICAgICBvYmpfZGVzY3JpcHRpb24oYy5vaWQsICdwZ19jbGFzcycpCiAgICAgICAgICAgIEZST00gcGdfY2F0YWxvZy5wZ19jbGFzcyBjCiAgICAgICAgICAgIExFRlQgSk9JTiBwZ19jYXRhbG9nLnBnX25hbWVzcGFjZSBuIE9OIG4ub2lkID0gYy5yZWxuYW1lc3BhY2UKICAgICAgICAgICAgV0hFUkUgYy5yZWxraW5kIElOICgnZicsICdtJywgJ3AnLCAncicsICd2JykKICAgICAgICAgICAgICAgIEFORCBuLm5zcG5hbWUgTk9UIElOICgncGdfY2F0YWxvZycsICdwZ190b2FzdCcpCiAgICAgICAgICAgICAgICBBTkQgcGdfY2F0YWxvZy5wZ190YWJsZV9pc192aXNpYmxlKGMub2lkKQogICAgICAgIAA= - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAAFkAA3JlbG5hbWUAAAAE6wACAAAAEwBA/////wAAY2FzZQAAAAAAAAAAAAAZ////////AABvYmpfZGVzY3JpcHRpb24AAAAAAAAAAAAAGf///////wAARAAAACQAAwAAABFkamFuZ29fbWlncmF0aW9ucwAAAAF0/////0QAAAAmAAMAAAATZGphbmdvX2NvbnRlbnRfdHlwZQAAAAF0/////0QAAAAiAAMAAAAPYXV0aF9wZXJtaXNzaW9uAAAAAXT/////RAAAAB0AAwAAAAphdXRoX2dyb3VwAAAAAXT/////RAAAACkAAwAAABZhdXRoX2dyb3VwX3Blcm1pc3Npb25zAAAAAXT/////RAAAABwAAwAAAAlhdXRoX3VzZXIAAAABdP////9EAAAAIwADAAAAEGF1dGhfdXNlcl9ncm91cHMAAAABdP////9EAAAALQADAAAAGmF1dGhfdXNlcl91c2VyX3Blcm1pc3Npb25zAAAAAXT/////RAAAACMAAwAAABBkamFuZ29fYWRtaW5fbG9nAAAAAXT/////RAAAACEAAwAAAA5kamFuZ29fc2Vzc2lvbgAAAAF0/////0QAAAAjAAMAAAAQYXBwbGljYXRpb25fdXNlcgAAAAF0/////0MAAAAOU0VMRUNUIDExAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAACATSFi8= - postgresresponses: - - origin: server - message: - - type: binary - data: Tg== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAAPQADAAB1c2VyAHBvc3RncmVzAGRhdGFiYXNlAHVzZXJzZGIAY2xpZW50X2VuY29kaW5nAFVURjgAAA== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAABcAAAAKU0NSQU0tU0hBLTI1NgAA ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAADZTQ1JBTS1TSEEtMjU2AAAAACBuLCxuPSxyPXRGdGJZNUtJZmJmdnk1SjMvZXFKeG1TcQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAAFwAAAALcj10RnRiWTVLSWZiZnZ5NUozL2VxSnhtU3FtRmdjN0x3NXdpSjZURWJvdStqWDhrZloscz12Z0RnUnRhbndUS1QreGVxbEVQTGl3PT0saT00MDk2 ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAAGxjPWJpd3Mscj10RnRiWTVLSWZiZnZ5NUozL2VxSnhtU3FtRmdjN0x3NXdpSjZURWJvdStqWDhrZloscD1jVklKMGNYVFZxY0FySW1XOGdMT3FPZE9iUGFFTzJ6SEZXUlBDMnpGb240PQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAADYAAAAMdj1pR1h0SDVRY0h4a3V5aGpOS2hIU0phUHQ2NTZubjg4YzdjNUhXUnRBaXFjPVIAAAAIAAAAAFMAAAAXaW5faG90X3N0YW5kYnkAb2ZmAFMAAAAZaW50ZWdlcl9kYXRldGltZXMAb24AUwAAABVUaW1lWm9uZQBFdGMvVVRDAFMAAAAbSW50ZXJ2YWxTdHlsZQBwb3N0Z3JlcwBTAAAAFGlzX3N1cGVydXNlcgBvbgBTAAAAFmFwcGxpY2F0aW9uX25hbWUAAFMAAAAmZGVmYXVsdF90cmFuc2FjdGlvbl9yZWFkX29ubHkAb2ZmAFMAAAAac2NyYW1faXRlcmF0aW9ucwA0MDk2AFMAAAAXRGF0ZVN0eWxlAElTTywgTURZAFMAAAAjc3RhbmRhcmRfY29uZm9ybWluZ19zdHJpbmdzAG9uAFMAAAAjc2Vzc2lvbl9hdXRob3JpemF0aW9uAHBvc3RncmVzAFMAAAAZY2xpZW50X2VuY29kaW5nAFVURjgAUwAAADJzZXJ2ZXJfdmVyc2lvbgAxNi4wIChEZWJpYW4gMTYuMC0xLnBnZGcxMjArMSkAUwAAABlzZXJ2ZXJfZW5jb2RpbmcAVVRGOABLAAAADAAAAJ8NjGb5WgAAAAVJ ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAADBTRUxFQ1Qgc2V0X2NvbmZpZygnVGltZVpvbmUnLCAnVVRDJywgZmFsc2UpAA== - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAACMAAXNldF9jb25maWcAAAAAAAAAAAAAGf///////wAARAAAAA0AAQAAAANVVENDAAAADVNFTEVDVCAxAFMAAAARVGltZVpvbmUAVVRDAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAAM1JTlNFUlQgSU5UTyAiYXBwbGljYXRpb25fdXNlciIgKCJpZCIsICJuYW1lIiwgImVtYWlsIiwgInBhc3N3b3JkIiwgIndlYnNpdGUiKSBWQUxVRVMgKCdkNzhhNjI2MDAwNzc0ZjU4YjQ1Y2Y2OGIyODQzMDQwMCc6OnV1aWQsICdKYW5lIFNtaXRoJywgJ2phbmUuc21pdGhAZXhhbXBsZS5jb20nLCAnc21pdGg1NjcnLCAnd3d3LmphbmVzbWl0aC5jb20nKQA= - postgresresponses: - - origin: server - message: - - type: binary - data: QwAAAA9JTlNFUlQgMCAxAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAACATSFi8= - postgresresponses: - - origin: server - message: - - type: binary - data: Tg== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAAPQADAAB1c2VyAHBvc3RncmVzAGRhdGFiYXNlAHVzZXJzZGIAY2xpZW50X2VuY29kaW5nAFVURjgAAA== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAABcAAAAKU0NSQU0tU0hBLTI1NgAA ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAADZTQ1JBTS1TSEEtMjU2AAAAACBuLCxuPSxyPUxhQ1BpS0R4aUV1Qm1UdDlwRHIyZkxoRQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAAFwAAAALcj1MYUNQaUtEeGlFdUJtVHQ5cERyMmZMaEU4c1MzUVlwcTFFRXd5dnhmY1dQcDZCTmoscz12Z0RnUnRhbndUS1QreGVxbEVQTGl3PT0saT00MDk2 ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAAGxjPWJpd3Mscj1MYUNQaUtEeGlFdUJtVHQ5cERyMmZMaEU4c1MzUVlwcTFFRXd5dnhmY1dQcDZCTmoscD15TGRkTDRNdldQb3h5bVJXOFNiVi9vS00wQXhSa2IrVkRsQ01WQ0VtekVnPQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAADYAAAAMdj1QZUk1WE5YTzV4VG8rdVdyOWlvajBKQmFQcitwQktKOEV6eGduRGNqNk5VPVIAAAAIAAAAAFMAAAAXaW5faG90X3N0YW5kYnkAb2ZmAFMAAAAZaW50ZWdlcl9kYXRldGltZXMAb24AUwAAABVUaW1lWm9uZQBFdGMvVVRDAFMAAAAbSW50ZXJ2YWxTdHlsZQBwb3N0Z3JlcwBTAAAAFGlzX3N1cGVydXNlcgBvbgBTAAAAFmFwcGxpY2F0aW9uX25hbWUAAFMAAAAmZGVmYXVsdF90cmFuc2FjdGlvbl9yZWFkX29ubHkAb2ZmAFMAAAAac2NyYW1faXRlcmF0aW9ucwA0MDk2AFMAAAAXRGF0ZVN0eWxlAElTTywgTURZAFMAAAAjc3RhbmRhcmRfY29uZm9ybWluZ19zdHJpbmdzAG9uAFMAAAAjc2Vzc2lvbl9hdXRob3JpemF0aW9uAHBvc3RncmVzAFMAAAAZY2xpZW50X2VuY29kaW5nAFVURjgAUwAAADJzZXJ2ZXJfdmVyc2lvbgAxNi4wIChEZWJpYW4gMTYuMC0xLnBnZGcxMjArMSkAUwAAABlzZXJ2ZXJfZW5jb2RpbmcAVVRGOABLAAAADAAAAKHzPy7/WgAAAAVJ ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAADBTRUxFQ1Qgc2V0X2NvbmZpZygnVGltZVpvbmUnLCAnVVRDJywgZmFsc2UpAA== - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAACMAAXNldF9jb25maWcAAAAAAAAAAAAAGf///////wAARAAAAA0AAQAAAANVVENDAAAADVNFTEVDVCAxAFMAAAARVGltZVpvbmUAVVRDAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAAK9TRUxFQ1QgImFwcGxpY2F0aW9uX3VzZXIiLiJpZCIsICJhcHBsaWNhdGlvbl91c2VyIi4ibmFtZSIsICJhcHBsaWNhdGlvbl91c2VyIi4iZW1haWwiLCAiYXBwbGljYXRpb25fdXNlciIuInBhc3N3b3JkIiwgImFwcGxpY2F0aW9uX3VzZXIiLiJ3ZWJzaXRlIiBGUk9NICJhcHBsaWNhdGlvbl91c2VyIgA= - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAAH8ABWlkAAAAQJcAAQAAC4YAEP////8AAG5hbWUAAABAlwACAAAEE///AAAANgAAZW1haWwAAABAlwADAAAEE///AAABAgAAcGFzc3dvcmQAAABAlwAEAAAEE///AAAANgAAd2Vic2l0ZQAAAECXAAUAAAQT//8AAAA2AABEAAAAdwAFAAAAJGQ3OGE2MjYwLTAwNzctNGY1OC1iNDVjLWY2OGIyODQzMDQwMAAAAApKYW5lIFNtaXRoAAAAFmphbmUuc21pdGhAZXhhbXBsZS5jb20AAAAIc21pdGg1NjcAAAARd3d3LmphbmVzbWl0aC5jb21DAAAADVNFTEVDVCAxAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAACATSFi8= - postgresresponses: - - origin: server - message: - - type: binary - data: Tg== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAAPQADAAB1c2VyAHBvc3RncmVzAGRhdGFiYXNlAHVzZXJzZGIAY2xpZW50X2VuY29kaW5nAFVURjgAAA== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAABcAAAAKU0NSQU0tU0hBLTI1NgAA ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAADZTQ1JBTS1TSEEtMjU2AAAAACBuLCxuPSxyPUZaS0MxVXlLNWVsSWl5MEFIemNoQnVvVw== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAAFwAAAALcj1GWktDMVV5SzVlbElpeTBBSHpjaEJ1b1dWc25iVFMrT1Q3ZWdNanNKd0xVTnIvWmMscz12Z0RnUnRhbndUS1QreGVxbEVQTGl3PT0saT00MDk2 ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAAGxjPWJpd3Mscj1GWktDMVV5SzVlbElpeTBBSHpjaEJ1b1dWc25iVFMrT1Q3ZWdNanNKd0xVTnIvWmMscD1jN0hyUkpaZ3BPakhyMHV6TEhyT1VnUUptMTA4Q3ZXV1VCcWhvSHlJb2FjPQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAADYAAAAMdj15ZHdPanVhZzd1alRESXRXMDVyakZOSlhjaFF1MDVRY2JKWVJBYUgvVWI4PVIAAAAIAAAAAFMAAAAXaW5faG90X3N0YW5kYnkAb2ZmAFMAAAAZaW50ZWdlcl9kYXRldGltZXMAb24AUwAAABVUaW1lWm9uZQBFdGMvVVRDAFMAAAAbSW50ZXJ2YWxTdHlsZQBwb3N0Z3JlcwBTAAAAFGlzX3N1cGVydXNlcgBvbgBTAAAAFmFwcGxpY2F0aW9uX25hbWUAAFMAAAAmZGVmYXVsdF90cmFuc2FjdGlvbl9yZWFkX29ubHkAb2ZmAFMAAAAac2NyYW1faXRlcmF0aW9ucwA0MDk2AFMAAAAXRGF0ZVN0eWxlAElTTywgTURZAFMAAAAjc3RhbmRhcmRfY29uZm9ybWluZ19zdHJpbmdzAG9uAFMAAAAjc2Vzc2lvbl9hdXRob3JpemF0aW9uAHBvc3RncmVzAFMAAAAZY2xpZW50X2VuY29kaW5nAFVURjgAUwAAADJzZXJ2ZXJfdmVyc2lvbgAxNi4wIChEZWJpYW4gMTYuMC0xLnBnZGcxMjArMSkAUwAAABlzZXJ2ZXJfZW5jb2RpbmcAVVRGOABLAAAADAAAAKKaN39YWgAAAAVJ ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAADBTRUxFQ1Qgc2V0X2NvbmZpZygnVGltZVpvbmUnLCAnVVRDJywgZmFsc2UpAA== - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAACMAAXNldF9jb25maWcAAAAAAAAAAAAAGf///////wAARAAAAA0AAQAAAANVVENDAAAADVNFTEVDVCAxAFMAAAARVGltZVpvbmUAVVRDAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAAMZJTlNFUlQgSU5UTyAiYXBwbGljYXRpb25fdXNlciIgKCJpZCIsICJuYW1lIiwgImVtYWlsIiwgInBhc3N3b3JkIiwgIndlYnNpdGUiKSBWQUxVRVMgKCc5ZjkzMTY2ZDM4MzM0NGMyYjkwNmVkZWM5MDE0ZTBkNSc6OnV1aWQsICdKb2huIERvZScsICdqb2huLmRvZUBleGFtcGxlLmNvbScsICdqb2huNTY3JywgJ3d3dy5qb2huZG9lLmNvbScpAA== - postgresresponses: - - origin: server - message: - - type: binary - data: QwAAAA9JTlNFUlQgMCAxAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAACATSFi8= - postgresresponses: - - origin: server - message: - - type: binary - data: Tg== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAAPQADAAB1c2VyAHBvc3RncmVzAGRhdGFiYXNlAHVzZXJzZGIAY2xpZW50X2VuY29kaW5nAFVURjgAAA== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAABcAAAAKU0NSQU0tU0hBLTI1NgAA ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAADZTQ1JBTS1TSEEtMjU2AAAAACBuLCxuPSxyPXF5NzZMamhDbzUrUDllOG1CZmFPU0c0WQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAAFwAAAALcj1xeTc2TGpoQ281K1A5ZThtQmZhT1NHNFk3UnpZdzlhaDRuWkhoR2NXbnR3Ry9ic1cscz12Z0RnUnRhbndUS1QreGVxbEVQTGl3PT0saT00MDk2 ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAAGxjPWJpd3Mscj1xeTc2TGpoQ281K1A5ZThtQmZhT1NHNFk3UnpZdzlhaDRuWkhoR2NXbnR3Ry9ic1cscD1rbEp4UUVDcGlSb3N1YjBQT3FIRnVCanJxNlI5SDd0U2dnWlpYdUtsT1pZPQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAADYAAAAMdj1xdlJoMGVhWXRKRkcyU24vRUF0b1BsZWE2Qk50SGhud2x3ZEFTdW5JMTl3PVIAAAAIAAAAAFMAAAAXaW5faG90X3N0YW5kYnkAb2ZmAFMAAAAZaW50ZWdlcl9kYXRldGltZXMAb24AUwAAABVUaW1lWm9uZQBFdGMvVVRDAFMAAAAbSW50ZXJ2YWxTdHlsZQBwb3N0Z3JlcwBTAAAAFGlzX3N1cGVydXNlcgBvbgBTAAAAFmFwcGxpY2F0aW9uX25hbWUAAFMAAAAmZGVmYXVsdF90cmFuc2FjdGlvbl9yZWFkX29ubHkAb2ZmAFMAAAAac2NyYW1faXRlcmF0aW9ucwA0MDk2AFMAAAAXRGF0ZVN0eWxlAElTTywgTURZAFMAAAAjc3RhbmRhcmRfY29uZm9ybWluZ19zdHJpbmdzAG9uAFMAAAAjc2Vzc2lvbl9hdXRob3JpemF0aW9uAHBvc3RncmVzAFMAAAAZY2xpZW50X2VuY29kaW5nAFVURjgAUwAAADJzZXJ2ZXJfdmVyc2lvbgAxNi4wIChEZWJpYW4gMTYuMC0xLnBnZGcxMjArMSkAUwAAABlzZXJ2ZXJfZW5jb2RpbmcAVVRGOABLAAAADAAAAKW8DV8xWgAAAAVJ ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAADBTRUxFQ1Qgc2V0X2NvbmZpZygnVGltZVpvbmUnLCAnVVRDJywgZmFsc2UpAA== - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAACMAAXNldF9jb25maWcAAAAAAAAAAAAAGf///////wAARAAAAA0AAQAAAANVVENDAAAADVNFTEVDVCAxAFMAAAARVGltZVpvbmUAVVRDAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAAQFTRUxFQ1QgImFwcGxpY2F0aW9uX3VzZXIiLiJpZCIsICJhcHBsaWNhdGlvbl91c2VyIi4ibmFtZSIsICJhcHBsaWNhdGlvbl91c2VyIi4iZW1haWwiLCAiYXBwbGljYXRpb25fdXNlciIuInBhc3N3b3JkIiwgImFwcGxpY2F0aW9uX3VzZXIiLiJ3ZWJzaXRlIiBGUk9NICJhcHBsaWNhdGlvbl91c2VyIiBXSEVSRSAiYXBwbGljYXRpb25fdXNlciIuImlkIiA9ICdkNzhhNjI2MDAwNzc0ZjU4YjQ1Y2Y2OGIyODQzMDQwMCc6OnV1aWQgTElNSVQgMjEA - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAAH8ABWlkAAAAQJcAAQAAC4YAEP////8AAG5hbWUAAABAlwACAAAEE///AAAANgAAZW1haWwAAABAlwADAAAEE///AAABAgAAcGFzc3dvcmQAAABAlwAEAAAEE///AAAANgAAd2Vic2l0ZQAAAECXAAUAAAQT//8AAAA2AABEAAAAdwAFAAAAJGQ3OGE2MjYwLTAwNzctNGY1OC1iNDVjLWY2OGIyODQzMDQwMAAAAApKYW5lIFNtaXRoAAAAFmphbmUuc21pdGhAZXhhbXBsZS5jb20AAAAIc21pdGg1NjcAAAARd3d3LmphbmVzbWl0aC5jb21DAAAADVNFTEVDVCAxAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAACATSFi8= - postgresresponses: - - origin: server - message: - - type: binary - data: Tg== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAAPQADAAB1c2VyAHBvc3RncmVzAGRhdGFiYXNlAHVzZXJzZGIAY2xpZW50X2VuY29kaW5nAFVURjgAAA== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAABcAAAAKU0NSQU0tU0hBLTI1NgAA ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAADZTQ1JBTS1TSEEtMjU2AAAAACBuLCxuPSxyPVNybkowT2Foc0lZVjl5U0JkaUorMllaUg== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAAFwAAAALcj1Tcm5KME9haHNJWVY5eVNCZGlKKzJZWlIvMmErNGNQS3dkdjhRNHZmd0t0aVIyYzUscz12Z0RnUnRhbndUS1QreGVxbEVQTGl3PT0saT00MDk2 ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAAGxjPWJpd3Mscj1Tcm5KME9haHNJWVY5eVNCZGlKKzJZWlIvMmErNGNQS3dkdjhRNHZmd0t0aVIyYzUscD05K1dpRE1oelptMmpBR1lEanpvT0FuNE5MaE11REd0UlFzZTNFU0hRRGhRPQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAADYAAAAMdj1OcmdtVDJMMUQ1UHBsRlI4dyszQ1FzZWlua3RiRWRXL29VL01LZVRDcUs4PVIAAAAIAAAAAFMAAAAXaW5faG90X3N0YW5kYnkAb2ZmAFMAAAAZaW50ZWdlcl9kYXRldGltZXMAb24AUwAAABVUaW1lWm9uZQBFdGMvVVRDAFMAAAAbSW50ZXJ2YWxTdHlsZQBwb3N0Z3JlcwBTAAAAFGlzX3N1cGVydXNlcgBvbgBTAAAAFmFwcGxpY2F0aW9uX25hbWUAAFMAAAAmZGVmYXVsdF90cmFuc2FjdGlvbl9yZWFkX29ubHkAb2ZmAFMAAAAac2NyYW1faXRlcmF0aW9ucwA0MDk2AFMAAAAXRGF0ZVN0eWxlAElTTywgTURZAFMAAAAjc3RhbmRhcmRfY29uZm9ybWluZ19zdHJpbmdzAG9uAFMAAAAjc2Vzc2lvbl9hdXRob3JpemF0aW9uAHBvc3RncmVzAFMAAAAZY2xpZW50X2VuY29kaW5nAFVURjgAUwAAADJzZXJ2ZXJfdmVyc2lvbgAxNi4wIChEZWJpYW4gMTYuMC0xLnBnZGcxMjArMSkAUwAAABlzZXJ2ZXJfZW5jb2RpbmcAVVRGOABLAAAADAAAAKhZfv48WgAAAAVJ ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAADBTRUxFQ1Qgc2V0X2NvbmZpZygnVGltZVpvbmUnLCAnVVRDJywgZmFsc2UpAA== - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAACMAAXNldF9jb25maWcAAAAAAAAAAAAAGf///////wAARAAAAA0AAQAAAANVVENDAAAADVNFTEVDVCAxAFMAAAARVGltZVpvbmUAVVRDAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAAQFTRUxFQ1QgImFwcGxpY2F0aW9uX3VzZXIiLiJpZCIsICJhcHBsaWNhdGlvbl91c2VyIi4ibmFtZSIsICJhcHBsaWNhdGlvbl91c2VyIi4iZW1haWwiLCAiYXBwbGljYXRpb25fdXNlciIuInBhc3N3b3JkIiwgImFwcGxpY2F0aW9uX3VzZXIiLiJ3ZWJzaXRlIiBGUk9NICJhcHBsaWNhdGlvbl91c2VyIiBXSEVSRSAiYXBwbGljYXRpb25fdXNlciIuImlkIiA9ICdkNzhhNjI2MDAwNzc0ZjU4YjQ1Y2Y2OGIyODQzMDQwMCc6OnV1aWQgTElNSVQgMjEA - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAAH8ABWlkAAAAQJcAAQAAC4YAEP////8AAG5hbWUAAABAlwACAAAEE///AAAANgAAZW1haWwAAABAlwADAAAEE///AAABAgAAcGFzc3dvcmQAAABAlwAEAAAEE///AAAANgAAd2Vic2l0ZQAAAECXAAUAAAQT//8AAAA2AABEAAAAdwAFAAAAJGQ3OGE2MjYwLTAwNzctNGY1OC1iNDVjLWY2OGIyODQzMDQwMAAAAApKYW5lIFNtaXRoAAAAFmphbmUuc21pdGhAZXhhbXBsZS5jb20AAAAIc21pdGg1NjcAAAARd3d3LmphbmVzbWl0aC5jb21DAAAADVNFTEVDVCAxAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAAN9VUERBVEUgImFwcGxpY2F0aW9uX3VzZXIiIFNFVCAibmFtZSIgPSAnSmFuZSBTbWl0aCcsICJlbWFpbCIgPSAnc21pdGguamFuZUBleGFtcGxlLmNvbScsICJwYXNzd29yZCIgPSAnc21pdGg1NjcnLCAid2Vic2l0ZSIgPSAnd3d3LnNtaXRoamFuZS5jb20nIFdIRVJFICJhcHBsaWNhdGlvbl91c2VyIi4iaWQiID0gJ2Q3OGE2MjYwMDA3NzRmNThiNDVjZjY4YjI4NDMwNDAwJzo6dXVpZAA= - postgresresponses: - - origin: server - message: - - type: binary - data: QwAAAA1VUERBVEUgMQBaAAAABUk= ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAACATSFi8= - postgresresponses: - - origin: server - message: - - type: binary - data: Tg== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAAPQADAAB1c2VyAHBvc3RncmVzAGRhdGFiYXNlAHVzZXJzZGIAY2xpZW50X2VuY29kaW5nAFVURjgAAA== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAABcAAAAKU0NSQU0tU0hBLTI1NgAA ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAADZTQ1JBTS1TSEEtMjU2AAAAACBuLCxuPSxyPUJib2ZPZ21mbTN5b2tucXJibXBYTk1kTQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAAFwAAAALcj1CYm9mT2dtZm0zeW9rbnFyYm1wWE5NZE13VCtmbGhPR0dkdjZpU3VNUmNEQllpSUMscz12Z0RnUnRhbndUS1QreGVxbEVQTGl3PT0saT00MDk2 ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAAGxjPWJpd3Mscj1CYm9mT2dtZm0zeW9rbnFyYm1wWE5NZE13VCtmbGhPR0dkdjZpU3VNUmNEQllpSUMscD16dFRZVC94MkloekZ2MHhYOEtsWWwzeG9ueXJqV1F6N0phWi9SL0pRdUpBPQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAADYAAAAMdj1JcitoTGRLUThPaUVreGZuL0VSNUIwbElwQkE5R0kvMzUvLzEySW80VlRFPVIAAAAIAAAAAFMAAAAXaW5faG90X3N0YW5kYnkAb2ZmAFMAAAAZaW50ZWdlcl9kYXRldGltZXMAb24AUwAAABVUaW1lWm9uZQBFdGMvVVRDAFMAAAAbSW50ZXJ2YWxTdHlsZQBwb3N0Z3JlcwBTAAAAFGlzX3N1cGVydXNlcgBvbgBTAAAAFmFwcGxpY2F0aW9uX25hbWUAAFMAAAAmZGVmYXVsdF90cmFuc2FjdGlvbl9yZWFkX29ubHkAb2ZmAFMAAAAac2NyYW1faXRlcmF0aW9ucwA0MDk2AFMAAAAXRGF0ZVN0eWxlAElTTywgTURZAFMAAAAjc3RhbmRhcmRfY29uZm9ybWluZ19zdHJpbmdzAG9uAFMAAAAjc2Vzc2lvbl9hdXRob3JpemF0aW9uAHBvc3RncmVzAFMAAAAZY2xpZW50X2VuY29kaW5nAFVURjgAUwAAADJzZXJ2ZXJfdmVyc2lvbgAxNi4wIChEZWJpYW4gMTYuMC0xLnBnZGcxMjArMSkAUwAAABlzZXJ2ZXJfZW5jb2RpbmcAVVRGOABLAAAADAAAAKr8N1/xWgAAAAVJ ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAADBTRUxFQ1Qgc2V0X2NvbmZpZygnVGltZVpvbmUnLCAnVVRDJywgZmFsc2UpAA== - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAACMAAXNldF9jb25maWcAAAAAAAAAAAAAGf///////wAARAAAAA0AAQAAAANVVENDAAAADVNFTEVDVCAxAFMAAAARVGltZVpvbmUAVVRDAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAAQFTRUxFQ1QgImFwcGxpY2F0aW9uX3VzZXIiLiJpZCIsICJhcHBsaWNhdGlvbl91c2VyIi4ibmFtZSIsICJhcHBsaWNhdGlvbl91c2VyIi4iZW1haWwiLCAiYXBwbGljYXRpb25fdXNlciIuInBhc3N3b3JkIiwgImFwcGxpY2F0aW9uX3VzZXIiLiJ3ZWJzaXRlIiBGUk9NICJhcHBsaWNhdGlvbl91c2VyIiBXSEVSRSAiYXBwbGljYXRpb25fdXNlciIuImlkIiA9ICdkNzhhNjI2MDAwNzc0ZjU4YjQ1Y2Y2OGIyODQzMDQwMCc6OnV1aWQgTElNSVQgMjEA - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAAH8ABWlkAAAAQJcAAQAAC4YAEP////8AAG5hbWUAAABAlwACAAAEE///AAAANgAAZW1haWwAAABAlwADAAAEE///AAABAgAAcGFzc3dvcmQAAABAlwAEAAAEE///AAAANgAAd2Vic2l0ZQAAAECXAAUAAAQT//8AAAA2AABEAAAAdwAFAAAAJGQ3OGE2MjYwLTAwNzctNGY1OC1iNDVjLWY2OGIyODQzMDQwMAAAAApKYW5lIFNtaXRoAAAAFnNtaXRoLmphbmVAZXhhbXBsZS5jb20AAAAIc21pdGg1NjcAAAARd3d3LnNtaXRoamFuZS5jb21DAAAADVNFTEVDVCAxAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAAG9ERUxFVEUgRlJPTSAiYXBwbGljYXRpb25fdXNlciIgV0hFUkUgImFwcGxpY2F0aW9uX3VzZXIiLiJpZCIgSU4gKCdkNzhhNjI2MDAwNzc0ZjU4YjQ1Y2Y2OGIyODQzMDQwMCc6OnV1aWQpAA== - postgresresponses: - - origin: server - message: - - type: binary - data: QwAAAA1ERUxFVEUgMQBaAAAABUk= ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAACATSFi8= - postgresresponses: - - origin: server - message: - - type: binary - data: Tg== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: AAAAPQADAAB1c2VyAHBvc3RncmVzAGRhdGFiYXNlAHVzZXJzZGIAY2xpZW50X2VuY29kaW5nAFVURjgAAA== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAABcAAAAKU0NSQU0tU0hBLTI1NgAA ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAADZTQ1JBTS1TSEEtMjU2AAAAACBuLCxuPSxyPWRnZVIzY05KV1o0RWZ6NGgwWG0wc090bA== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAAFwAAAALcj1kZ2VSM2NOSldaNEVmejRoMFhtMHNPdGxTU3pBYnJBSVV4OG1DVWxPMWpUdXhKWWUscz12Z0RnUnRhbndUS1QreGVxbEVQTGl3PT0saT00MDk2 ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: cAAAAGxjPWJpd3Mscj1kZ2VSM2NOSldaNEVmejRoMFhtMHNPdGxTU3pBYnJBSVV4OG1DVWxPMWpUdXhKWWUscD1TYVIzMmxJS0xCdHJxRzdZWlYzTVZNUVNSODVqSkw3L1k2ZDg3V08rQmJBPQ== - postgresresponses: - - origin: server - message: - - type: binary - data: UgAAADYAAAAMdj1Gc0RuWnZTeWhLYW95Q1NLV0hGaEhYSFYyRUpSZm9Fd0o0K2UxV3c3YmRvPVIAAAAIAAAAAFMAAAAXaW5faG90X3N0YW5kYnkAb2ZmAFMAAAAZaW50ZWdlcl9kYXRldGltZXMAb24AUwAAABVUaW1lWm9uZQBFdGMvVVRDAFMAAAAbSW50ZXJ2YWxTdHlsZQBwb3N0Z3JlcwBTAAAAFGlzX3N1cGVydXNlcgBvbgBTAAAAFmFwcGxpY2F0aW9uX25hbWUAAFMAAAAmZGVmYXVsdF90cmFuc2FjdGlvbl9yZWFkX29ubHkAb2ZmAFMAAAAac2NyYW1faXRlcmF0aW9ucwA0MDk2AFMAAAAXRGF0ZVN0eWxlAElTTywgTURZAFMAAAAjc3RhbmRhcmRfY29uZm9ybWluZ19zdHJpbmdzAG9uAFMAAAAjc2Vzc2lvbl9hdXRob3JpemF0aW9uAHBvc3RncmVzAFMAAAAZY2xpZW50X2VuY29kaW5nAFVURjgAUwAAADJzZXJ2ZXJfdmVyc2lvbgAxNi4wIChEZWJpYW4gMTYuMC0xLnBnZGcxMjArMSkAUwAAABlzZXJ2ZXJfZW5jb2RpbmcAVVRGOABLAAAADAAAAKvDxr9LWgAAAAVJ ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAADBTRUxFQ1Qgc2V0X2NvbmZpZygnVGltZVpvbmUnLCAnVVRDJywgZmFsc2UpAA== - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAACMAAXNldF9jb25maWcAAAAAAAAAAAAAGf///////wAARAAAAA0AAQAAAANVVENDAAAADVNFTEVDVCAxAFMAAAARVGltZVpvbmUAVVRDAFoAAAAFSQ== ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAAK9TRUxFQ1QgImFwcGxpY2F0aW9uX3VzZXIiLiJpZCIsICJhcHBsaWNhdGlvbl91c2VyIi4ibmFtZSIsICJhcHBsaWNhdGlvbl91c2VyIi4iZW1haWwiLCAiYXBwbGljYXRpb25fdXNlciIuInBhc3N3b3JkIiwgImFwcGxpY2F0aW9uX3VzZXIiLiJ3ZWJzaXRlIiBGUk9NICJhcHBsaWNhdGlvbl91c2VyIgA= - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAAH8ABWlkAAAAQJcAAQAAC4YAEP////8AAG5hbWUAAABAlwACAAAEE///AAAANgAAZW1haWwAAABAlwADAAAEE///AAABAgAAcGFzc3dvcmQAAABAlwAEAAAEE///AAAANgAAd2Vic2l0ZQAAAECXAAUAAAQT//8AAAA2AABEAAAAcAAFAAAAJDlmOTMxNjZkLTM4MzMtNDRjMi1iOTA2LWVkZWM5MDE0ZTBkNQAAAAhKb2huIERvZQAAABRqb2huLmRvZUBleGFtcGxlLmNvbQAAAAdqb2huNTY3AAAAD3d3dy5qb2huZG9lLmNvbUMAAAANU0VMRUNUIDEAWgAAAAVJ ---- -version: api.keploy.io/v1beta2 -kind: Postgres -name: mocks -spec: - metadata: {} - postgresrequests: - - origin: client - message: - - type: binary - data: UQAAAJNTRUxFQ1QgImRqYW5nb19taWdyYXRpb25zIi4iaWQiLCAiZGphbmdvX21pZ3JhdGlvbnMiLiJhcHAiLCAiZGphbmdvX21pZ3JhdGlvbnMiLiJuYW1lIiwgImRqYW5nb19taWdyYXRpb25zIi4iYXBwbGllZCIgRlJPTSAiZGphbmdvX21pZ3JhdGlvbnMiAA== - postgresresponses: - - origin: server - message: - - type: binary - data: VAAAAGIABGlkAAAAQAYAAQAAABQACP////8AAGFwcAAAAEAGAAIAAAQT//8AAAEDAABuYW1lAAAAQAYAAwAABBP//wAAAQMAAGFwcGxpZWQAAABABgAEAAAEoAAI/////wAARAAAAEwABAAAAAExAAAADGNvbnRlbnR0eXBlcwAAAAwwMDAxX2luaXRpYWwAAAAdMjAyMy0wOS0yNyAyMDowMzo0NS43NDczOTQrMDBEAAAARAAEAAAAATIAAAAEYXV0aAAAAAwwMDAxX2luaXRpYWwAAAAdMjAyMy0wOS0yNyAyMDowMzo0NS44MzU2MzErMDBEAAAARQAEAAAAATMAAAAFYWRtaW4AAAAMMDAwMV9pbml0aWFsAAAAHTIwMjMtMDktMjcgMjA6MDM6NDUuODU3OTY5KzAwRAAAAFYABAAAAAE0AAAABWFkbWluAAAAHTAwMDJfbG9nZW50cnlfcmVtb3ZlX2F1dG9fYWRkAAAAHTIwMjMtMDktMjcgMjA6MDM6NDUuODY2OTc1KzAwRAAAAF4ABAAAAAE1AAAABWFkbWluAAAAJTAwMDNfbG9nZW50cnlfYWRkX2FjdGlvbl9mbGFnX2Nob2ljZXMAAAAdMjAyMy0wOS0yNyAyMDowMzo0NS44NzU3OTYrMDBEAAAAXQAEAAAAATYAAAAMY29udGVudHR5cGVzAAAAHTAwMDJfcmVtb3ZlX2NvbnRlbnRfdHlwZV9uYW1lAAAAHTIwMjMtMDktMjcgMjA6MDM6NDUuODk0MDAxKzAwRAAAAFwABAAAAAE3AAAABGF1dGgAAAAlMDAwMl9hbHRlcl9wZXJtaXNzaW9uX25hbWVfbWF4X2xlbmd0aAAAABwyMDIzLTA5LTI3IDIwOjAzOjQ1LjkwNTI4KzAwRAAAAFgABAAAAAE4AAAABGF1dGgAAAAgMDAwM19hbHRlcl91c2VyX2VtYWlsX21heF9sZW5ndGgAAAAdMjAyMy0wOS0yNyAyMDowMzo0NS45MTY0OTQrMDBEAAAAVQAEAAAAATkAAAAEYXV0aAAAAB0wMDA0X2FsdGVyX3VzZXJfdXNlcm5hbWVfb3B0cwAAAB0yMDIzLTA5LTI3IDIwOjAzOjQ1LjkyNTk5NiswMEQAAABXAAQAAAACMTAAAAAEYXV0aAAAAB8wMDA1X2FsdGVyX3VzZXJfbGFzdF9sb2dpbl9udWxsAAAAHDIwMjMtMDktMjcgMjA6MDM6NDUuOTM2NzErMDBEAAAAVwAEAAAAAjExAAAABGF1dGgAAAAeMDAwNl9yZXF1aXJlX2NvbnRlbnR0eXBlc18wMDAyAAAAHTIwMjMtMDktMjcgMjA6MDM6NDUuOTQyNTk2KzAwRAAAAGEABAAAAAIxMgAAAARhdXRoAAAAKDAwMDdfYWx0ZXJfdmFsaWRhdG9yc19hZGRfZXJyb3JfbWVzc2FnZXMAAAAdMjAyMy0wOS0yNyAyMDowMzo0NS45NTI0NjErMDBEAAAAWwAEAAAAAjEzAAAABGF1dGgAAAAjMDAwOF9hbHRlcl91c2VyX3VzZXJuYW1lX21heF9sZW5ndGgAAAAcMjAyMy0wOS0yNyAyMDowMzo0NS45Njg1OCswMEQAAABdAAQAAAACMTQAAAAEYXV0aAAAACQwMDA5X2FsdGVyX3VzZXJfbGFzdF9uYW1lX21heF9sZW5ndGgAAAAdMjAyMy0wOS0yNyAyMDowMzo0NS45ODEyNDIrMDBEAAAAWQAEAAAAAjE1AAAABGF1dGgAAAAgMDAxMF9hbHRlcl9ncm91cF9uYW1lX21heF9sZW5ndGgAAAAdMjAyMy0wOS0yNyAyMDowMzo0NS45OTM1MjUrMDBEAAAAVgAEAAAAAjE2AAAABGF1dGgAAAAdMDAxMV91cGRhdGVfcHJveHlfcGVybWlzc2lvbnMAAAAdMjAyMy0wOS0yNyAyMDowMzo0Ni4wMDkyOTErMDBEAAAAXgAEAAAAAjE3AAAABGF1dGgAAAAlMDAxMl9hbHRlcl91c2VyX2ZpcnN0X25hbWVfbWF4X2xlbmd0aAAAAB0yMDIzLTA5LTI3IDIwOjAzOjQ2LjAyMDk3MyswMEQAAABJAAQAAAACMTgAAAAIc2Vzc2lvbnMAAAAMMDAwMV9pbml0aWFsAAAAHTIwMjMtMDktMjcgMjA6MDM6NDYuMDQxNzg1KzAwRAAAAEwABAAAAAIxOQAAAAthcHBsaWNhdGlvbgAAAAwwMDAxX2luaXRpYWwAAAAdMjAyMy0wOS0yNyAyMDoxNzoxNS43Mzk5MjErMDBDAAAADlNFTEVDVCAxOQBaAAAABUk= diff --git a/django-postgres/django_postgres/keploy/test-set-0/tests/test-1.yaml b/django-postgres/django_postgres/keploy/test-set-0/tests/test-1.yaml deleted file mode 100755 index 4accde3..0000000 --- a/django-postgres/django_postgres/keploy/test-set-0/tests/test-1.yaml +++ /dev/null @@ -1,51 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Http -name: test-1 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "155" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: 4061c183-e97a-48dd-a92c-4bdfc14d5458 - User-Agent: PostmanRuntime/7.33.0 - body: |4- - { - "name": "Jane Smith", - "email": "jane.smith@example.com", - "password": "smith567", - "website": "www.janesmith.com" - } - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, OPTIONS, POST - Content-Length: "29" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:39:50 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '{"message": "User Created!!"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - objects: [] - assertions: - noise: - - header.Date - - header.Vary - created: 1695847194 diff --git a/django-postgres/django_postgres/keploy/test-set-0/tests/test-2.yaml b/django-postgres/django_postgres/keploy/test-set-0/tests/test-2.yaml deleted file mode 100755 index 3ef257c..0000000 --- a/django-postgres/django_postgres/keploy/test-set-0/tests/test-2.yaml +++ /dev/null @@ -1,43 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Http -name: test-2 -spec: - metadata: {} - req: - method: GET - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Host: 127.0.0.1:8000 - Postman-Token: e3c0f9f1-1d9d-4b2e-a123-0e5d53174f96 - User-Agent: PostmanRuntime/7.33.0 - body: "" - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, OPTIONS, POST - Content-Length: "152" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:40:05 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '[{"id":"d78a6260-0077-4f58-b45c-f68b28430400","name":"Jane Smith","email":"jane.smith@example.com","password":"smith567","website":"www.janesmith.com"}]' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - objects: [] - assertions: - noise: - - header.Date - - header.Vary - created: 1695847209 diff --git a/django-postgres/django_postgres/keploy/test-set-0/tests/test-3.yaml b/django-postgres/django_postgres/keploy/test-set-0/tests/test-3.yaml deleted file mode 100755 index 27d8d78..0000000 --- a/django-postgres/django_postgres/keploy/test-set-0/tests/test-3.yaml +++ /dev/null @@ -1,51 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Http -name: test-3 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "148" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: 88ded5d4-23f2-4dbe-9334-cc59f6756e6c - User-Agent: PostmanRuntime/7.33.0 - body: |4- - { - "name": "John Doe", - "email": "john.doe@example.com", - "password": "john567", - "website": "www.johndoe.com" - } - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, OPTIONS, POST - Content-Length: "29" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:40:16 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '{"message": "User Created!!"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - objects: [] - assertions: - noise: - - header.Vary - - header.Date - created: 1695847221 diff --git a/django-postgres/django_postgres/keploy/test-set-0/tests/test-4.yaml b/django-postgres/django_postgres/keploy/test-set-0/tests/test-4.yaml deleted file mode 100755 index 55c453c..0000000 --- a/django-postgres/django_postgres/keploy/test-set-0/tests/test-4.yaml +++ /dev/null @@ -1,43 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Http -name: test-4 -spec: - metadata: {} - req: - method: GET - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/d78a6260-0077-4f58-b45c-f68b28430400/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Host: 127.0.0.1:8000 - Postman-Token: eeea2e51-8485-4cb6-bcc0-f32066b978c4 - User-Agent: PostmanRuntime/7.33.0 - body: "" - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, PUT, OPTIONS, DELETE - Content-Length: "150" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:40:52 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '{"id":"d78a6260-0077-4f58-b45c-f68b28430400","name":"Jane Smith","email":"jane.smith@example.com","password":"smith567","website":"www.janesmith.com"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - objects: [] - assertions: - noise: - - header.Date - - header.Vary - created: 1695847256 diff --git a/django-postgres/django_postgres/keploy/test-set-0/tests/test-5.yaml b/django-postgres/django_postgres/keploy/test-set-0/tests/test-5.yaml deleted file mode 100755 index 8bf8ba5..0000000 --- a/django-postgres/django_postgres/keploy/test-set-0/tests/test-5.yaml +++ /dev/null @@ -1,51 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Http -name: test-5 -spec: - metadata: {} - req: - method: PUT - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/d78a6260-0077-4f58-b45c-f68b28430400/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "155" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: 053c8c61-7c7f-4486-afed-98a27c2ce093 - User-Agent: PostmanRuntime/7.33.0 - body: |4- - { - "name": "Jane Smith", - "email": "smith.jane@example.com", - "password": "smith567", - "website": "www.smithjane.com" - } - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, PUT, OPTIONS, DELETE - Content-Length: "29" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:41:25 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '{"message": "User Updated!!"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - objects: [] - assertions: - noise: - - header.Vary - - header.Date - created: 1695847289 diff --git a/django-postgres/django_postgres/keploy/test-set-0/tests/test-6.yaml b/django-postgres/django_postgres/keploy/test-set-0/tests/test-6.yaml deleted file mode 100755 index 188c8b1..0000000 --- a/django-postgres/django_postgres/keploy/test-set-0/tests/test-6.yaml +++ /dev/null @@ -1,43 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Http -name: test-6 -spec: - metadata: {} - req: - method: DELETE - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/d78a6260-0077-4f58-b45c-f68b28430400/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Host: 127.0.0.1:8000 - Postman-Token: 08c79295-29dc-4245-a31f-7910fbb0d102 - User-Agent: PostmanRuntime/7.33.0 - body: "" - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, PUT, OPTIONS, DELETE - Content-Length: "29" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:41:45 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '{"message": "User Deleted!!"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - objects: [] - assertions: - noise: - - header.Date - - header.Vary - created: 1695847309 diff --git a/django-postgres/django_postgres/keploy/test-set-0/tests/test-7.yaml b/django-postgres/django_postgres/keploy/test-set-0/tests/test-7.yaml deleted file mode 100755 index f0a0761..0000000 --- a/django-postgres/django_postgres/keploy/test-set-0/tests/test-7.yaml +++ /dev/null @@ -1,43 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Http -name: test-7 -spec: - metadata: {} - req: - method: GET - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Host: 127.0.0.1:8000 - Postman-Token: 2baf2443-5bb2-4133-a83b-ecd40cd4b3d6 - User-Agent: PostmanRuntime/7.33.0 - body: "" - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, OPTIONS, POST - Content-Length: "145" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:41:50 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '[{"id":"9f93166d-3833-44c2-b906-edec9014e0d5","name":"John Doe","email":"john.doe@example.com","password":"john567","website":"www.johndoe.com"}]' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - objects: [] - assertions: - noise: - - header.Vary - - header.Date - created: 1695847314 diff --git a/django-postgres/django_postgres/keploy/testReports/report-1.yaml b/django-postgres/django_postgres/keploy/testReports/report-1.yaml deleted file mode 100755 index dddc1fa..0000000 --- a/django-postgres/django_postgres/keploy/testReports/report-1.yaml +++ /dev/null @@ -1,1081 +0,0 @@ -version: api.keploy.io/v1beta1 -name: report-1 -status: FAILED -success: 4 -failure: 3 -total: 7 -tests: - - kind: Http - name: report-1 - status: PASSED - started: 1695847382 - completed: 1695847382 - test_case_path: /home/shashwat/test/django-postgresql/django_postgres/keploytest-set-0 - mock_path: "" - test_case_id: test-1 - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "155" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: 4061c183-e97a-48dd-a92c-4bdfc14d5458 - User-Agent: PostmanRuntime/7.33.0 - body: |4- - { - "name": "Jane Smith", - "email": "jane.smith@example.com", - "password": "smith567", - "website": "www.janesmith.com" - } - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, OPTIONS, POST - Content-Length: "29" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:39:50 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '{"message": "User Created!!"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - noise: - - header.Date - - header.Vary - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Date - value: - - Wed, 27 Sep 2023 20:39:50 GMT - actual: - key: Date - value: - - Wed, 27 Sep 2023 20:43:02 GMT - - normal: true - expected: - key: Referrer-Policy - value: - - same-origin - actual: - key: Referrer-Policy - value: - - same-origin - - normal: true - expected: - key: X-Content-Type-Options - value: - - nosniff - actual: - key: X-Content-Type-Options - value: - - nosniff - - normal: true - expected: - key: Allow - value: - - GET - - ' OPTIONS' - - ' POST' - actual: - key: Allow - value: - - GET - - ' OPTIONS' - - ' POST' - - normal: true - expected: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - actual: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - - normal: true - expected: - key: X-Frame-Options - value: - - DENY - actual: - key: X-Frame-Options - value: - - DENY - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Cross-Origin-Opener-Policy - value: - - same-origin - actual: - key: Cross-Origin-Opener-Policy - value: - - same-origin - - normal: true - expected: - key: Vary - value: - - Accept, Cookie - actual: - key: Vary - value: - - Accept, Cookie - - normal: true - expected: - key: Content-Length - value: - - "29" - actual: - key: Content-Length - value: - - "29" - body_result: - - normal: true - type: JSON - expected: '{"message": "User Created!!"}' - actual: '{"message": "User Created!!"}' - dep_result: [] - - kind: Http - name: report-1 - status: PASSED - started: 1695847382 - completed: 1695847382 - test_case_path: /home/shashwat/test/django-postgresql/django_postgres/keploytest-set-0 - mock_path: "" - test_case_id: test-2 - req: - method: GET - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Host: 127.0.0.1:8000 - Postman-Token: e3c0f9f1-1d9d-4b2e-a123-0e5d53174f96 - User-Agent: PostmanRuntime/7.33.0 - body: "" - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, OPTIONS, POST - Content-Length: "152" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:40:05 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '[{"id":"d78a6260-0077-4f58-b45c-f68b28430400","name":"Jane Smith","email":"jane.smith@example.com","password":"smith567","website":"www.janesmith.com"}]' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - noise: - - header.Date - - header.Vary - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Vary - value: - - Accept, Cookie - actual: - key: Vary - value: - - Accept, Cookie - - normal: true - expected: - key: Allow - value: - - GET - - ' OPTIONS' - - ' POST' - actual: - key: Allow - value: - - GET - - ' OPTIONS' - - ' POST' - - normal: true - expected: - key: Content-Length - value: - - "152" - actual: - key: Content-Length - value: - - "152" - - normal: true - expected: - key: Cross-Origin-Opener-Policy - value: - - same-origin - actual: - key: Cross-Origin-Opener-Policy - value: - - same-origin - - normal: true - expected: - key: Date - value: - - Wed, 27 Sep 2023 20:40:05 GMT - actual: - key: Date - value: - - Wed, 27 Sep 2023 20:43:02 GMT - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Referrer-Policy - value: - - same-origin - actual: - key: Referrer-Policy - value: - - same-origin - - normal: true - expected: - key: X-Frame-Options - value: - - DENY - actual: - key: X-Frame-Options - value: - - DENY - - normal: true - expected: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - actual: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - - normal: true - expected: - key: X-Content-Type-Options - value: - - nosniff - actual: - key: X-Content-Type-Options - value: - - nosniff - body_result: - - normal: true - type: JSON - expected: '[{"id":"d78a6260-0077-4f58-b45c-f68b28430400","name":"Jane Smith","email":"jane.smith@example.com","password":"smith567","website":"www.janesmith.com"}]' - actual: '[{"id":"d78a6260-0077-4f58-b45c-f68b28430400","name":"Jane Smith","email":"jane.smith@example.com","password":"smith567","website":"www.janesmith.com"}]' - dep_result: [] - - kind: Http - name: report-1 - status: PASSED - started: 1695847382 - completed: 1695847382 - test_case_path: /home/shashwat/test/django-postgresql/django_postgres/keploytest-set-0 - mock_path: "" - test_case_id: test-3 - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "148" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: 88ded5d4-23f2-4dbe-9334-cc59f6756e6c - User-Agent: PostmanRuntime/7.33.0 - body: |4- - { - "name": "John Doe", - "email": "john.doe@example.com", - "password": "john567", - "website": "www.johndoe.com" - } - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, OPTIONS, POST - Content-Length: "29" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:40:16 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '{"message": "User Created!!"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - noise: - - header.Vary - - header.Date - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Cross-Origin-Opener-Policy - value: - - same-origin - actual: - key: Cross-Origin-Opener-Policy - value: - - same-origin - - normal: true - expected: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - actual: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - - normal: true - expected: - key: Vary - value: - - Accept, Cookie - actual: - key: Vary - value: - - Accept, Cookie - - normal: true - expected: - key: Allow - value: - - GET - - ' OPTIONS' - - ' POST' - actual: - key: Allow - value: - - GET - - ' OPTIONS' - - ' POST' - - normal: true - expected: - key: Referrer-Policy - value: - - same-origin - actual: - key: Referrer-Policy - value: - - same-origin - - normal: true - expected: - key: Content-Length - value: - - "29" - actual: - key: Content-Length - value: - - "29" - - normal: true - expected: - key: Date - value: - - Wed, 27 Sep 2023 20:40:16 GMT - actual: - key: Date - value: - - Wed, 27 Sep 2023 20:43:02 GMT - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: X-Frame-Options - value: - - DENY - actual: - key: X-Frame-Options - value: - - DENY - - normal: true - expected: - key: X-Content-Type-Options - value: - - nosniff - actual: - key: X-Content-Type-Options - value: - - nosniff - body_result: - - normal: true - type: JSON - expected: '{"message": "User Created!!"}' - actual: '{"message": "User Created!!"}' - dep_result: [] - - kind: Http - name: report-1 - status: FAILED - started: 1695847382 - completed: 1695847382 - test_case_path: /home/shashwat/test/django-postgresql/django_postgres/keploytest-set-0 - mock_path: "" - test_case_id: test-4 - req: - method: GET - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/d78a6260-0077-4f58-b45c-f68b28430400/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Host: 127.0.0.1:8000 - Postman-Token: eeea2e51-8485-4cb6-bcc0-f32066b978c4 - User-Agent: PostmanRuntime/7.33.0 - body: "" - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, PUT, OPTIONS, DELETE - Content-Length: "150" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:40:52 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '{"id":"d78a6260-0077-4f58-b45c-f68b28430400","name":"Jane Smith","email":"jane.smith@example.com","password":"smith567","website":"www.janesmith.com"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - noise: - - header.Date - - header.Vary - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Content-Length - value: - - "150" - actual: - key: Content-Length - value: - - "150" - - normal: true - expected: - key: Vary - value: - - Accept, Cookie - actual: - key: Vary - value: - - Accept, Cookie - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Wed, 27 Sep 2023 20:40:52 GMT - actual: - key: Date - value: - - Wed, 27 Sep 2023 20:43:02 GMT - - normal: true - expected: - key: Referrer-Policy - value: - - same-origin - actual: - key: Referrer-Policy - value: - - same-origin - - normal: true - expected: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - actual: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - - normal: true - expected: - key: X-Frame-Options - value: - - DENY - actual: - key: X-Frame-Options - value: - - DENY - - normal: true - expected: - key: X-Content-Type-Options - value: - - nosniff - actual: - key: X-Content-Type-Options - value: - - nosniff - - normal: false - expected: - key: Allow - value: - - GET - - ' PUT' - - ' OPTIONS' - - ' DELETE' - actual: - key: Allow - value: - - GET - - ' OPTIONS' - - ' PUT' - - ' DELETE' - - normal: true - expected: - key: Cross-Origin-Opener-Policy - value: - - same-origin - actual: - key: Cross-Origin-Opener-Policy - value: - - same-origin - body_result: - - normal: true - type: JSON - expected: '{"id":"d78a6260-0077-4f58-b45c-f68b28430400","name":"Jane Smith","email":"jane.smith@example.com","password":"smith567","website":"www.janesmith.com"}' - actual: '{"id":"d78a6260-0077-4f58-b45c-f68b28430400","name":"Jane Smith","email":"jane.smith@example.com","password":"smith567","website":"www.janesmith.com"}' - dep_result: [] - - kind: Http - name: report-1 - status: FAILED - started: 1695847382 - completed: 1695847382 - test_case_path: /home/shashwat/test/django-postgresql/django_postgres/keploytest-set-0 - mock_path: "" - test_case_id: test-5 - req: - method: PUT - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/d78a6260-0077-4f58-b45c-f68b28430400/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "155" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: 053c8c61-7c7f-4486-afed-98a27c2ce093 - User-Agent: PostmanRuntime/7.33.0 - body: |4- - { - "name": "Jane Smith", - "email": "smith.jane@example.com", - "password": "smith567", - "website": "www.smithjane.com" - } - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, PUT, OPTIONS, DELETE - Content-Length: "29" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:41:25 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '{"message": "User Updated!!"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - noise: - - header.Vary - - header.Date - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: false - expected: - key: Allow - value: - - GET - - ' PUT' - - ' OPTIONS' - - ' DELETE' - actual: - key: Allow - value: - - GET - - ' OPTIONS' - - ' PUT' - - ' DELETE' - - normal: true - expected: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - actual: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - - normal: true - expected: - key: Date - value: - - Wed, 27 Sep 2023 20:41:25 GMT - actual: - key: Date - value: - - Wed, 27 Sep 2023 20:43:02 GMT - - normal: true - expected: - key: Vary - value: - - Accept, Cookie - actual: - key: Vary - value: - - Accept, Cookie - - normal: true - expected: - key: X-Frame-Options - value: - - DENY - actual: - key: X-Frame-Options - value: - - DENY - - normal: true - expected: - key: Referrer-Policy - value: - - same-origin - actual: - key: Referrer-Policy - value: - - same-origin - - normal: true - expected: - key: X-Content-Type-Options - value: - - nosniff - actual: - key: X-Content-Type-Options - value: - - nosniff - - normal: true - expected: - key: Content-Length - value: - - "29" - actual: - key: Content-Length - value: - - "29" - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Cross-Origin-Opener-Policy - value: - - same-origin - actual: - key: Cross-Origin-Opener-Policy - value: - - same-origin - body_result: - - normal: true - type: JSON - expected: '{"message": "User Updated!!"}' - actual: '{"message": "User Updated!!"}' - dep_result: [] - - kind: Http - name: report-1 - status: FAILED - started: 1695847382 - completed: 1695847383 - test_case_path: /home/shashwat/test/django-postgresql/django_postgres/keploytest-set-0 - mock_path: "" - test_case_id: test-6 - req: - method: DELETE - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/d78a6260-0077-4f58-b45c-f68b28430400/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Host: 127.0.0.1:8000 - Postman-Token: 08c79295-29dc-4245-a31f-7910fbb0d102 - User-Agent: PostmanRuntime/7.33.0 - body: "" - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, PUT, OPTIONS, DELETE - Content-Length: "29" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:41:45 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '{"message": "User Deleted!!"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - noise: - - header.Date - - header.Vary - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Referrer-Policy - value: - - same-origin - actual: - key: Referrer-Policy - value: - - same-origin - - normal: true - expected: - key: X-Frame-Options - value: - - DENY - actual: - key: X-Frame-Options - value: - - DENY - - normal: true - expected: - key: Cross-Origin-Opener-Policy - value: - - same-origin - actual: - key: Cross-Origin-Opener-Policy - value: - - same-origin - - normal: true - expected: - key: Date - value: - - Wed, 27 Sep 2023 20:41:45 GMT - actual: - key: Date - value: - - Wed, 27 Sep 2023 20:43:03 GMT - - normal: false - expected: - key: Allow - value: - - GET - - ' PUT' - - ' OPTIONS' - - ' DELETE' - actual: - key: Allow - value: - - GET - - ' OPTIONS' - - ' PUT' - - ' DELETE' - - normal: true - expected: - key: Content-Length - value: - - "29" - actual: - key: Content-Length - value: - - "29" - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Vary - value: - - Accept, Cookie - actual: - key: Vary - value: - - Accept, Cookie - - normal: true - expected: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - actual: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - - normal: true - expected: - key: X-Content-Type-Options - value: - - nosniff - actual: - key: X-Content-Type-Options - value: - - nosniff - body_result: - - normal: true - type: JSON - expected: '{"message": "User Deleted!!"}' - actual: '{"message": "User Deleted!!"}' - dep_result: [] - - kind: Http - name: report-1 - status: PASSED - started: 1695847383 - completed: 1695847383 - test_case_path: /home/shashwat/test/django-postgresql/django_postgres/keploytest-set-0 - mock_path: "" - test_case_id: test-7 - req: - method: GET - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/user/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Host: 127.0.0.1:8000 - Postman-Token: 2baf2443-5bb2-4133-a83b-ecd40cd4b3d6 - User-Agent: PostmanRuntime/7.33.0 - body: "" - body_type: "" - resp: - status_code: 200 - header: - Allow: GET, OPTIONS, POST - Content-Length: "145" - Content-Type: application/json - Cross-Origin-Opener-Policy: same-origin - Date: Wed, 27 Sep 2023 20:41:50 GMT - Referrer-Policy: same-origin - Server: WSGIServer/0.2 CPython/3.10.12 - Vary: Accept, Cookie - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - body: '[{"id":"9f93166d-3833-44c2-b906-edec9014e0d5","name":"John Doe","email":"john.doe@example.com","password":"john567","website":"www.johndoe.com"}]' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - noise: - - header.Vary - - header.Date - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: X-Content-Type-Options - value: - - nosniff - actual: - key: X-Content-Type-Options - value: - - nosniff - - normal: true - expected: - key: Allow - value: - - GET - - ' OPTIONS' - - ' POST' - actual: - key: Allow - value: - - GET - - ' OPTIONS' - - ' POST' - - normal: true - expected: - key: Content-Length - value: - - "145" - actual: - key: Content-Length - value: - - "145" - - normal: true - expected: - key: Referrer-Policy - value: - - same-origin - actual: - key: Referrer-Policy - value: - - same-origin - - normal: true - expected: - key: Vary - value: - - Accept, Cookie - actual: - key: Vary - value: - - Accept, Cookie - - normal: true - expected: - key: Date - value: - - Wed, 27 Sep 2023 20:41:50 GMT - actual: - key: Date - value: - - Wed, 27 Sep 2023 20:43:03 GMT - - normal: true - expected: - key: X-Frame-Options - value: - - DENY - actual: - key: X-Frame-Options - value: - - DENY - - normal: true - expected: - key: Cross-Origin-Opener-Policy - value: - - same-origin - actual: - key: Cross-Origin-Opener-Policy - value: - - same-origin - - normal: true - expected: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - actual: - key: Server - value: - - WSGIServer/0.2 CPython/3.10.12 - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - body_result: - - normal: true - type: JSON - expected: '[{"id":"9f93166d-3833-44c2-b906-edec9014e0d5","name":"John Doe","email":"john.doe@example.com","password":"john567","website":"www.johndoe.com"}]' - actual: '[{"id":"9f93166d-3833-44c2-b906-edec9014e0d5","name":"John Doe","email":"john.doe@example.com","password":"john567","website":"www.johndoe.com"}]' - dep_result: [] -test_set: test-set-0 diff --git a/django-postgres/django_postgres/requirements.txt b/django-postgres/django_postgres/requirements.txt index 5d51161..50399bc 100644 --- a/django-postgres/django_postgres/requirements.txt +++ b/django-postgres/django_postgres/requirements.txt @@ -6,3 +6,4 @@ psycopg2-binary==2.9.9 pytz==2023.3.post1 sqlparse==0.4.4 typing_extensions==4.9.0 +coverage==7.6.1 diff --git a/fastapi-postgres/Dockerfile b/fastapi-postgres/Dockerfile index dc51d4b..85a9796 100644 --- a/fastapi-postgres/Dockerfile +++ b/fastapi-postgres/Dockerfile @@ -1,6 +1,13 @@ # Use the official Python image as the base image FROM python:3.11.5-bullseye +# Install PostgreSQL client +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + postgresql-client \ + curl \ + netcat-traditional + # Set the working directory to /app WORKDIR /app @@ -20,11 +27,8 @@ COPY . . # POSTGRES_HOST=0.0.0.0 \ # POSTGRES_PORT=5432 -# Install PostgreSQL client -RUN apt-get update && apt-get install -y postgresql-client - # Expose port 80 for the FastAPI application EXPOSE 8000 # Start the FastAPI application -CMD ["uvicorn", "application.main:app", "--host", "0.0.0.0", "--port", "8000"] +CMD [ "/app/entrypoint.sh" ] diff --git a/fastapi-postgres/README.md b/fastapi-postgres/README.md index eca7442..56fd7e2 100644 --- a/fastapi-postgres/README.md +++ b/fastapi-postgres/README.md @@ -13,6 +13,7 @@ Make the following requests to the respective endpoints - ```bash git clone https://github.com/keploy/samples-python.git && cd samples-python/fastapi-postgres +pip3 install coverage pip3 install -r requirements.txt ``` @@ -21,24 +22,25 @@ pip3 install -r requirements.txt Keploy can be installed on Linux directly and on Windows with the help of WSL. Based on your system architecture, install the keploy latest binary release ```bash - curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh - keploy +curl -O -L https:///keploy.io/install.sh && source install.sh ``` ### Starting the PostgreSQL Instance ```bash # Start the application -docker-compose up -d +docker-compose up -d postgres ``` -> Note: Update the `SQLALCHEMY_DATABASE_URL` in the `database.py` file if you want to use a keploy with docker. +> **If we have setup our sample-app with docker, we need to update the container name to postgres on line 6, in `application/database.py`, from `postgresql://postgres:postgres@localhost:5432/studentdb` to `postgresql://postgres:postgres@postgres:5432/studentdb`.** + +> **Also, we need to update the container name to postgres on line 11, of `application/main.py`, from `postgresql://postgres:postgres@localhost:5432/studentdb` to `postgresql://postgres:postgres@postgres:5432/studentdb`.** ### Capture the Testcases -This command will start the recording of API calls using ebpf:- +This command will start the recording of API calls : -```shell +```sh sudo -E PATH=$PATH keploy record -c "uvicorn application.main:app --reload" ``` @@ -101,12 +103,19 @@ curl --location --request DELETE 'http://127.0.0.1:8000/students/1' Now all these API calls were captured as **editable** testcases and written to `keploy/tests` folder. The keploy directory would also have `mocks` file that contains all the outputs of postgres operations. +![keploy testcase](./img/testcases.png) + ## Run the Testcases Now let's run the application in test mode. ```shell -sudo -E PATH=$PATH keploy test -c "uvicorn application.main:app --reload" --delay 10 +sudo -E PATH=$PATH keploy test -c "python3 -m uvicorn application.main:app" --delay 10 ``` +We will get output something like below - + +![keploy testcase](./img/testrun.png) + +By making just 2 api call, we have generated a complete test suite for our application and acheived 72% coverage. -So, no need to setup fake database/apis like Postgres or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to Postgres 😄** +So, no need to setup fake database/apis like Postgres or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to Postgres 😄** diff --git a/fastapi-postgres/application/database.py b/fastapi-postgres/application/database.py index 8b00777..17e68c4 100644 --- a/fastapi-postgres/application/database.py +++ b/fastapi-postgres/application/database.py @@ -3,7 +3,7 @@ from sqlalchemy.orm import sessionmaker -SQLALCHEMY_DATABASE_URL = "postgresql://postgres:postgres@postgres:5432/studentdb" +SQLALCHEMY_DATABASE_URL = "postgresql://postgres:postgres@localhost:5432/studentdb" engine = create_engine(SQLALCHEMY_DATABASE_URL) SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) diff --git a/fastapi-postgres/application/main.py b/fastapi-postgres/application/main.py index 294ad02..c078fe2 100644 --- a/fastapi-postgres/application/main.py +++ b/fastapi-postgres/application/main.py @@ -1,14 +1,21 @@ from fastapi import Depends, FastAPI, HTTPException from sqlalchemy.orm import Session +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker +from sqlalchemy.ext.declarative import declarative_base +import asyncio from . import models, crud, schemas -from .database import SessionLocal, engine +# Database setup +SQLALCHEMY_DATABASE_URL = "postgresql://postgres:postgres@localhost:5432/studentdb" +engine = create_engine(SQLALCHEMY_DATABASE_URL) +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) +Base = declarative_base() models.Base.metadata.create_all(bind=engine) app = FastAPI() - # Dependency def get_db(): db = SessionLocal() @@ -17,7 +24,6 @@ def get_db(): finally: db.close() - @app.post('/students/', response_model=schemas.Student) def create_student(student: schemas.StudentCreate, db: Session = Depends(get_db)): db_student = crud.get_student_byEmail(db, student_email=student.email) @@ -26,7 +32,6 @@ def create_student(student: schemas.StudentCreate, db: Session = Depends(get_db) data = crud.create_student(db, student=student) return data - @app.get('/students/', response_model=list[schemas.Student]) def read_students(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)): students = crud.get_students(db, skip, limit) @@ -34,7 +39,6 @@ def read_students(skip: int = 0, limit: int = 100, db: Session = Depends(get_db) raise HTTPException(404, 'Data not found!!') return students - @app.get('/students/{student_id}', response_model=schemas.Student) def read_student(student_id: int, db: Session = Depends(get_db)): student = crud.get_student(db, student_id=student_id) @@ -42,7 +46,6 @@ def read_student(student_id: int, db: Session = Depends(get_db)): raise HTTPException(status_code=404, detail=f'Student with ID={student_id} not found!!') return student - @app.put('/students/{student_id}', response_model=schemas.Student) def update_student(student_id: int, student: schemas.StudentUpdate, db: Session = Depends(get_db)): student = crud.update_student(db, student=student, student_id=student_id) @@ -50,10 +53,18 @@ def update_student(student_id: int, student: schemas.StudentUpdate, db: Session raise HTTPException(status_code=404, detail=f'Student with ID={student_id} not found!!') return student - @app.delete('/students/{student_id}', response_model=schemas.Student) def delete_student(student_id: int, db: Session = Depends(get_db)): student = crud.delete_student(db, student_id=student_id) if student is None: raise HTTPException(status_code=404, detail=f'Student with ID={student_id} not found!!') return student + +# Graceful shutdown +@app.on_event("shutdown") +async def shutdown_event(): + # Example: Close the database connection pool + print("Shutting down...") + # Assuming SQLAlchemy engine has a dispose method to release resources + engine.dispose() + diff --git a/fastapi-postgres/application/test_crud.py b/fastapi-postgres/application/test_crud.py new file mode 100644 index 0000000..b33d4c8 --- /dev/null +++ b/fastapi-postgres/application/test_crud.py @@ -0,0 +1,55 @@ +import pytest +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker + +from .database import Base, SessionLocal +from . import crud, models, schemas + +# Create an in-memory SQLite database for testing +SQLALCHEMY_DATABASE_URL = "sqlite:///./test.db" +engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}) +TestingSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) + +# Create the database tables +Base.metadata.create_all(bind=engine) + +@pytest.fixture(scope="module") +def db_session(): + connection = engine.connect() + transaction = connection.begin() + session = TestingSessionLocal(bind=connection) + + yield session + + session.close() + transaction.rollback() + connection.close() + +def test_create_student(db_session): + student_in = schemas.StudentCreate(name="John Doe", email="john.doe@example.com", password="password", stream="Science") + student = crud.create_student(db_session, student_in) + assert student.name == "John Doe" + assert student.email == "john.doe@example.com" + +def test_get_student(db_session): + student_in = schemas.StudentCreate(name="Jane Doe", email="jane.doe@example.com", password="password", stream="Arts") + student = crud.create_student(db_session, student_in) + fetched_student = crud.get_student(db_session, student.id) + assert fetched_student.name == "Jane Doe" + assert fetched_student.email == "jane.doe@example.com" + +def test_update_student(db_session): + student_in = schemas.StudentCreate(name="Jim Beam", email="jim.beam@example.com", password="password", stream="Commerce") + student = crud.create_student(db_session, student_in) + student_update = schemas.StudentUpdate(name="Jim Updated", email="jim.updated@example.com", password="newpassword", stream="Commerce") + updated_student = crud.update_student(db_session, student_update, student.id) + assert updated_student.name == "Jim Updated" + assert updated_student.email == "jim.updated@example.com" + +def test_delete_student(db_session): + student_in = schemas.StudentCreate(name="Will Smith", email="will.smith@example.com", password="password", stream="Engineering") + student = crud.create_student(db_session, student_in) + deleted_student = crud.delete_student(db_session, student.id) + assert deleted_student is not None + assert deleted_student.name == "Will Smith" + assert crud.get_student(db_session, student.id) is None diff --git a/fastapi-postgres/docker-compose.yml b/fastapi-postgres/docker-compose.yml index 8ce911d..fd49830 100644 --- a/fastapi-postgres/docker-compose.yml +++ b/fastapi-postgres/docker-compose.yml @@ -1,8 +1,9 @@ -version: '3' +version: '3.9' services: postgres: image: postgres:latest + container_name: postgres environment: POSTGRES_DB: studentdb POSTGRES_USER: postgres @@ -13,7 +14,7 @@ services: - ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql networks: - keploy-network - + app: container_name: fastapi-app image: fastapi @@ -26,4 +27,8 @@ services: depends_on: - postgres networks: - - keploy-network \ No newline at end of file + - keploy-network + +networks: + keploy-network: + external: true diff --git a/fastapi-postgres/entrypoint.sh b/fastapi-postgres/entrypoint.sh new file mode 100755 index 0000000..0c46028 --- /dev/null +++ b/fastapi-postgres/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +until nc -z -v -w30 postgres 5432 +do + echo "Waiting for database connection..." + # wait for 5 seconds before check again + sleep 5 +done + +uvicorn application.main:app --host 0.0.0.0 --port 8000 diff --git a/fastapi-postgres/img/testcases.png b/fastapi-postgres/img/testcases.png new file mode 100644 index 0000000..1c4a2f0 Binary files /dev/null and b/fastapi-postgres/img/testcases.png differ diff --git a/fastapi-postgres/img/testrun.png b/fastapi-postgres/img/testrun.png new file mode 100644 index 0000000..11029fc Binary files /dev/null and b/fastapi-postgres/img/testrun.png differ diff --git a/fastapi-postgres/keploy.yml b/fastapi-postgres/keploy.yml new file mode 100755 index 0000000..d6e6628 --- /dev/null +++ b/fastapi-postgres/keploy.yml @@ -0,0 +1,43 @@ +path: "" +appId: 0 +appName: "" +command: uvicorn application.main:app --reload +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: "" +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + 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. diff --git a/fastapi-postgres/keploy/test-set-1/mocks.yaml b/fastapi-postgres/keploy/test-set-1/mocks.yaml deleted file mode 100755 index 86b47c1..0000000 --- a/fastapi-postgres/keploy/test-set-1/mocks.yaml +++ /dev/null @@ -1,1219 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-0 -spec: - metadata: - type: config - postgresrequests: - - identifier: StartupRequest - length: 8 - payload: AAAACATSFi8= - ssl_request: - is_ssl: true - auth_type: 0 - postgresresponses: - - payload: Tg== - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.216898875Z - restimestampmock: 2024-02-09T10:20:50.218562705Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-1 -spec: - metadata: - type: config - postgresrequests: - - identifier: StartupRequest - payload: AAAAKgADAAB1c2VyAHBvc3RncmVzAGRhdGFiYXNlAHN0dWRlbnRkYgAA - auth_type: 0 - postgresresponses: - - header: [R] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - authentication_sasl: - auth_mechanisms: - - SCRAM-SHA-256 - msg_type: 82 - auth_type: 10 - reqtimestampmock: 2024-02-09T10:20:50.232737784Z - restimestampmock: 2024-02-09T10:20:50.233296602Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-2 -spec: - metadata: - type: config - postgresrequests: - - header: [p] - identifier: ClientRequest - length: 8 - password_message: - password: SCRAM-SHA-256 - msg_type: 112 - auth_type: 0 - postgresresponses: - - header: [R] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - authentication_sasl_continue: {data: [114, 61, 68, 54, 118, 109, 56, 118, 117, 82, 116, 89, 111, 116, 75, 81, 75, 86, 74, 100, 55, 47, 85, 115, 107, 90, 70, 78, 88, 79, 112, 80, 88, 84, 67, 105, 103, 86, 51, 101, 73, 90, 48, 105, 119, 117, 65, 106, 111, 83, 44, 115, 61, 117, 110, 74, 50, 122, 68, 57, 75, 121, 76, 47, 109, 83, 114, 117, 111, 102, 121, 55, 112, 84, 81, 61, 61, 44, 105, 61, 52, 48, 57, 54]} - msg_type: 82 - auth_type: 11 - reqtimestampmock: 2024-02-09T10:20:50.234459113Z - restimestampmock: 2024-02-09T10:20:50.234488904Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-3 -spec: - metadata: - type: config - postgresrequests: - - header: [p] - identifier: ClientRequest - length: 8 - msg_type: 112 - auth_type: 0 - postgresresponses: - - header: [R, R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - authentication_sasl_final: {data: [118, 61, 118, 48, 53, 82, 117, 66, 89, 50, 52, 51, 72, 85, 67, 97, 116, 102, 83, 55, 67, 69, 70, 43, 72, 84, 106, 89, 90, 79, 118, 115, 115, 78, 48, 56, 116, 120, 99, 48, 103, 106, 105, 119, 85, 61]} - backend_key_data: - process_id: 34 - secret_key: 4065475156 - parameter_status: - - name: in_hot_standby - value: "off" - - name: integer_datetimes - value: "on" - - name: TimeZone - value: Etc/UTC - - name: IntervalStyle - value: postgres - - name: is_superuser - value: "on" - - name: application_name - value: "" - - name: default_transaction_read_only - value: "off" - - name: scram_iterations - value: "4096" - - name: DateStyle - value: ISO, MDY - - name: standard_conforming_strings - value: "on" - - name: session_authorization - value: postgres - - name: client_encoding - value: UTF8 - - name: server_version - value: 16.1 (Debian 16.1-1.pgdg120+1) - - name: server_encoding - value: UTF8 - - name: server_encoding - value: UTF8 - - name: server_encoding - value: UTF8 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.240419203Z - restimestampmock: 2024-02-09T10:20:50.24047866Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-4 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.241574547Z - restimestampmock: 2024-02-09T10:20:50.241651254Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-5 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAAHdTRUxFQ1QgdC5vaWQsIHR5cGFycmF5CkZST00gcGdfdHlwZSB0IEpPSU4gcGdfbmFtZXNwYWNlIG5zCiAgICBPTiB0eXBuYW1lc3BhY2UgPSBucy5vaWQKV0hFUkUgdHlwbmFtZSA9ICdoc3RvcmUnOwoA - query: - string: 'SELECT t.oid, typarray FROM pg_type t JOIN pg_namespace ns ON typnamespace = ns.oid WHERE typname = ''hstore''; ' - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 48 - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [111, 105, 100], table_oid: 1247, table_attribute_number: 1, data_type_oid: 26, data_type_size: 4, type_modifier: -1, format: 0}, {name: [116, 121, 112, 97, 114, 114, 97, 121], table_oid: 1247, table_attribute_number: 15, data_type_oid: 26, data_type_size: 4, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.243360791Z - restimestampmock: 2024-02-09T10:20:50.243385416Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-6 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: ROLLBACK - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 82 - - 79 - - 76 - - 76 - - 66 - - 65 - - 67 - - 75 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.244072772Z - restimestampmock: 2024-02-09T10:20:50.244098563Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-7 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.244693006Z - restimestampmock: 2024-02-09T10:20:50.244715338Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-8 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: select pg_catalog.version() - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAACAAAXZlcnNpb24AAAAAAAAAAAAAGf///////wAARAAAAIMAAQAAAHlQb3N0Z3JlU1FMIDE2LjEgKERlYmlhbiAxNi4xLTEucGdkZzEyMCsxKSBvbiBhYXJjaDY0LXVua25vd24tbGludXgtZ251LCBjb21waWxlZCBieSBnY2MgKERlYmlhbiAxMi4yLjAtMTQpIDEyLjIuMCwgNjQtYml0QwAAAA1TRUxFQ1QgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 49 - data_row: [{row_values: ['PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit']}, {row_values: ['PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit']}, {row_values: ['PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit']}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [118, 101, 114, 115, 105, 111, 110], table_oid: 0, table_attribute_number: 0, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.24516216Z - restimestampmock: 2024-02-09T10:20:50.245191367Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-9 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: select current_schema() - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAACcAAWN1cnJlbnRfc2NoZW1hAAAAAAAAAAAAABMAQP////8AAEQAAAAQAAEAAAAGcHVibGljQwAAAA1TRUxFQ1QgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 49 - data_row: [{row_values: [public]}, {row_values: [public]}, {row_values: [public]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [99, 117, 114, 114, 101, 110, 116, 95, 115, 99, 104, 101, 109, 97], table_oid: 0, table_attribute_number: 0, data_type_oid: 19, data_type_size: 64, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.246241214Z - restimestampmock: 2024-02-09T10:20:50.246281713Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-10 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: show transaction isolation level - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAAC4AAXRyYW5zYWN0aW9uX2lzb2xhdGlvbgAAAAAAAAAAAAAZ////////AABEAAAAGAABAAAADnJlYWQgY29tbWl0dGVkQwAAAAlTSE9XAFoAAAAFVA== - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 72 - - 79 - - 87 - data_row: [{row_values: [read committed]}, {row_values: [read committed]}, {row_values: [read committed]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [116, 114, 97, 110, 115, 97, 99, 116, 105, 111, 110, 95, 105, 115, 111, 108, 97, 116, 105, 111, 110], table_oid: 0, table_attribute_number: 0, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.247356559Z - restimestampmock: 2024-02-09T10:20:50.247387933Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-11 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: show standard_conforming_strings - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAADQAAXN0YW5kYXJkX2NvbmZvcm1pbmdfc3RyaW5ncwAAAAAAAAAAAAAZ////////AABEAAAADAABAAAAAm9uQwAAAAlTSE9XAFoAAAAFVA== - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 72 - - 79 - - 87 - data_row: [{row_values: ["on"]}, {row_values: ["on"]}, {row_values: ["on"]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [115, 116, 97, 110, 100, 97, 114, 100, 95, 99, 111, 110, 102, 111, 114, 109, 105, 110, 103, 95, 115, 116, 114, 105, 110, 103, 115], table_oid: 0, table_attribute_number: 0, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.248114456Z - restimestampmock: 2024-02-09T10:20:50.24815283Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-12 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: ROLLBACK - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 82 - - 79 - - 76 - - 76 - - 66 - - 65 - - 67 - - 75 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.248975766Z - restimestampmock: 2024-02-09T10:20:50.24899789Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-13 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.252045225Z - restimestampmock: 2024-02-09T10:20:50.252072266Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-14 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAAYdTRUxFQ1QgcGdfY2F0YWxvZy5wZ19jbGFzcy5yZWxuYW1lIApGUk9NIHBnX2NhdGFsb2cucGdfY2xhc3MgSk9JTiBwZ19jYXRhbG9nLnBnX25hbWVzcGFjZSBPTiBwZ19jYXRhbG9nLnBnX25hbWVzcGFjZS5vaWQgPSBwZ19jYXRhbG9nLnBnX2NsYXNzLnJlbG5hbWVzcGFjZSAKV0hFUkUgcGdfY2F0YWxvZy5wZ19jbGFzcy5yZWxuYW1lID0gJ3N0dWRlbnRzJyBBTkQgcGdfY2F0YWxvZy5wZ19jbGFzcy5yZWxraW5kID0gQU5ZIChBUlJBWVsncicsICdwJywgJ2YnLCAndicsICdtJ10pIEFORCBwZ19jYXRhbG9nLnBnX3RhYmxlX2lzX3Zpc2libGUocGdfY2F0YWxvZy5wZ19jbGFzcy5vaWQpIEFORCBwZ19jYXRhbG9nLnBnX25hbWVzcGFjZS5uc3BuYW1lICE9ICdwZ19jYXRhbG9nJwA= - query: - string: SELECT pg_catalog.pg_class.relname FROM pg_catalog.pg_class JOIN pg_catalog.pg_namespace ON pg_catalog.pg_namespace.oid = pg_catalog.pg_class.relnamespace WHERE pg_catalog.pg_class.relname = 'students' AND pg_catalog.pg_class.relkind = ANY (ARRAY['r', 'p', 'f', 'v', 'm']) AND pg_catalog.pg_table_is_visible(pg_catalog.pg_class.oid) AND pg_catalog.pg_namespace.nspname != 'pg_catalog' - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAACAAAXJlbG5hbWUAAAAE6wACAAAAEwBA/////wAARAAAABIAAQAAAAhzdHVkZW50c0MAAAANU0VMRUNUIDEAWgAAAAVU - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 49 - data_row: [{row_values: [students]}, {row_values: [students]}, {row_values: [students]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [114, 101, 108, 110, 97, 109, 101], table_oid: 1259, table_attribute_number: 2, data_type_oid: 19, data_type_size: 64, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.253162445Z - restimestampmock: 2024-02-09T10:20:50.253222319Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-15 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: COMMIT - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 67 - - 79 - - 77 - - 77 - - 73 - - 84 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.254107087Z - restimestampmock: 2024-02-09T10:20:50.25412767Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-16 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.542685552Z - restimestampmock: 2024-02-09T10:21:01.542714843Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-17 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAATBTRUxFQ1Qgc3R1ZGVudHMuIklEIiBBUyAic3R1ZGVudHNfSUQiLCBzdHVkZW50cy4iTmFtZSIgQVMgInN0dWRlbnRzX05hbWUiLCBzdHVkZW50cy4iRW1haWwiIEFTICJzdHVkZW50c19FbWFpbCIsIHN0dWRlbnRzLiJIYXNoZWQgUGFzc3dvcmQiIEFTICJzdHVkZW50c19IYXNoZWQgUGFzc3dvcmQiLCBzdHVkZW50cy4iU3ViamVjdCBTdHJlYW0iIEFTICJzdHVkZW50c19TdWJqZWN0IFN0cmVhbSIgCkZST00gc3R1ZGVudHMgCldIRVJFIHN0dWRlbnRzLiJFbWFpbCIgPSAnZXZhd2hpdGVAZXhhbXBsZS5jb20nIAogTElNSVQgMQA= - query: - string: SELECT students."ID" AS "students_ID", students."Name" AS "students_Name", students."Email" AS "students_Email", students."Hashed Password" AS "students_Hashed Password", students."Subject Stream" AS "students_Subject Stream" FROM students WHERE students."Email" = 'evawhite@example.com' LIMIT 1 - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 48 - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 78, 97, 109, 101], table_oid: 24577, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 69, 109, 97, 105, 108], table_oid: 24577, table_attribute_number: 3, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 72, 97, 115, 104, 101, 100, 32, 80, 97, 115, 115, 119, 111, 114, 100], table_oid: 24577, table_attribute_number: 4, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 83, 117, 98, 106, 101, 99, 116, 32, 83, 116, 114, 101, 97, 109], table_oid: 24577, table_attribute_number: 5, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.543969268Z - restimestampmock: 2024-02-09T10:21:01.544053057Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-18 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: INSERT INTO students ("Name", "Email", "Hashed Password", "Subject Stream") VALUES ('Eva White', 'evawhite@example.com', 'sfwbxijuf222', 'Mathematics') RETURNING students."ID" - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAABsAAUlEAAAAYAEAAQAAABcABP////8AAEQAAAALAAEAAAABMUMAAAAPSU5TRVJUIDAgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 73 - - 78 - - 83 - - 69 - - 82 - - 84 - - 32 - - 48 - - 32 - - 49 - data_row: [{row_values: ["1"]}, {row_values: ["1"]}, {row_values: ["1"]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.546426702Z - restimestampmock: 2024-02-09T10:21:01.546463701Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-19 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: COMMIT - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 67 - - 79 - - 77 - - 77 - - 73 - - 84 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.551006372Z - restimestampmock: 2024-02-09T10:21:01.55108062Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-20 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.552699118Z - restimestampmock: 2024-02-09T10:21:01.552721743Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-21 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAAJtTRUxFQ1Qgc3R1ZGVudHMuIklEIiwgc3R1ZGVudHMuIk5hbWUiLCBzdHVkZW50cy4iRW1haWwiLCBzdHVkZW50cy4iSGFzaGVkIFBhc3N3b3JkIiwgc3R1ZGVudHMuIlN1YmplY3QgU3RyZWFtIiAKRlJPTSBzdHVkZW50cyAKV0hFUkUgc3R1ZGVudHMuIklEIiA9IDEA - query: - string: SELECT students."ID", students."Name", students."Email", students."Hashed Password", students."Subject Stream" FROM students WHERE students."ID" = 1 - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAAI0ABUlEAAAAYAEAAQAAABcABP////8AAE5hbWUAAABgAQACAAAEE////////wAARW1haWwAAABgAQADAAAEE////////wAASGFzaGVkIFBhc3N3b3JkAAAAYAEABAAABBP///////8AAFN1YmplY3QgU3RyZWFtAAAAYAEABQAABBP///////8AAEQAAABPAAUAAAABMQAAAAlFdmEgV2hpdGUAAAAUZXZhd2hpdGVAZXhhbXBsZS5jb20AAAAMc2Z3YnhpanVmMjIyAAAAC01hdGhlbWF0aWNzQwAAAA1TRUxFQ1QgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 49 - data_row: [{row_values: ["1", Eva White, evawhite@example.com, sfwbxijuf222, Mathematics]}, {row_values: ["1", Eva White, evawhite@example.com, sfwbxijuf222, Mathematics]}, {row_values: ["1", Eva White, evawhite@example.com, sfwbxijuf222, Mathematics]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {name: [78, 97, 109, 101], table_oid: 24577, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [69, 109, 97, 105, 108], table_oid: 24577, table_attribute_number: 3, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [72, 97, 115, 104, 101, 100, 32, 80, 97, 115, 115, 119, 111, 114, 100], table_oid: 24577, table_attribute_number: 4, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [83, 117, 98, 106, 101, 99, 116, 32, 83, 116, 114, 101, 97, 109], table_oid: 24577, table_attribute_number: 5, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.553203147Z - restimestampmock: 2024-02-09T10:21:01.553236062Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-22 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: ROLLBACK - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 82 - - 79 - - 76 - - 76 - - 66 - - 65 - - 67 - - 75 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.556089153Z - restimestampmock: 2024-02-09T10:21:01.556110861Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-23 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.223148624Z - restimestampmock: 2024-02-09T10:21:11.223211164Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-24 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAAS9TRUxFQ1Qgc3R1ZGVudHMuIklEIiBBUyAic3R1ZGVudHNfSUQiLCBzdHVkZW50cy4iTmFtZSIgQVMgInN0dWRlbnRzX05hbWUiLCBzdHVkZW50cy4iRW1haWwiIEFTICJzdHVkZW50c19FbWFpbCIsIHN0dWRlbnRzLiJIYXNoZWQgUGFzc3dvcmQiIEFTICJzdHVkZW50c19IYXNoZWQgUGFzc3dvcmQiLCBzdHVkZW50cy4iU3ViamVjdCBTdHJlYW0iIEFTICJzdHVkZW50c19TdWJqZWN0IFN0cmVhbSIgCkZST00gc3R1ZGVudHMgCldIRVJFIHN0dWRlbnRzLiJFbWFpbCIgPSAnam9obmRvZUBleGFtcGxlLmNvbScgCiBMSU1JVCAxAA== - query: - string: SELECT students."ID" AS "students_ID", students."Name" AS "students_Name", students."Email" AS "students_Email", students."Hashed Password" AS "students_Hashed Password", students."Subject Stream" AS "students_Subject Stream" FROM students WHERE students."Email" = 'johndoe@example.com' LIMIT 1 - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 48 - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 78, 97, 109, 101], table_oid: 24577, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 69, 109, 97, 105, 108], table_oid: 24577, table_attribute_number: 3, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 72, 97, 115, 104, 101, 100, 32, 80, 97, 115, 115, 119, 111, 114, 100], table_oid: 24577, table_attribute_number: 4, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 83, 117, 98, 106, 101, 99, 116, 32, 83, 116, 114, 101, 97, 109], table_oid: 24577, table_attribute_number: 5, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.224563961Z - restimestampmock: 2024-02-09T10:21:11.224606043Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-25 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: INSERT INTO students ("Name", "Email", "Hashed Password", "Subject Stream") VALUES ('John Doe', 'johndoe@example.com', 'skpioepf234', 'Mathematics') RETURNING students."ID" - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAABsAAUlEAAAAYAEAAQAAABcABP////8AAEQAAAALAAEAAAABMkMAAAAPSU5TRVJUIDAgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 73 - - 78 - - 83 - - 69 - - 82 - - 84 - - 32 - - 48 - - 32 - - 49 - data_row: [{row_values: ["2"]}, {row_values: ["2"]}, {row_values: ["2"]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.226669655Z - restimestampmock: 2024-02-09T10:21:11.226748861Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-26 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: COMMIT - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 67 - - 79 - - 77 - - 77 - - 73 - - 84 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.232155218Z - restimestampmock: 2024-02-09T10:21:11.232190134Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-27 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.233212565Z - restimestampmock: 2024-02-09T10:21:11.233238147Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-28 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAAJtTRUxFQ1Qgc3R1ZGVudHMuIklEIiwgc3R1ZGVudHMuIk5hbWUiLCBzdHVkZW50cy4iRW1haWwiLCBzdHVkZW50cy4iSGFzaGVkIFBhc3N3b3JkIiwgc3R1ZGVudHMuIlN1YmplY3QgU3RyZWFtIiAKRlJPTSBzdHVkZW50cyAKV0hFUkUgc3R1ZGVudHMuIklEIiA9IDIA - query: - string: SELECT students."ID", students."Name", students."Email", students."Hashed Password", students."Subject Stream" FROM students WHERE students."ID" = 2 - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAAI0ABUlEAAAAYAEAAQAAABcABP////8AAE5hbWUAAABgAQACAAAEE////////wAARW1haWwAAABgAQADAAAEE////////wAASGFzaGVkIFBhc3N3b3JkAAAAYAEABAAABBP///////8AAFN1YmplY3QgU3RyZWFtAAAAYAEABQAABBP///////8AAEQAAABMAAUAAAABMgAAAAhKb2huIERvZQAAABNqb2huZG9lQGV4YW1wbGUuY29tAAAAC3NrcGlvZXBmMjM0AAAAC01hdGhlbWF0aWNzQwAAAA1TRUxFQ1QgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 49 - data_row: [{row_values: ["2", John Doe, johndoe@example.com, skpioepf234, Mathematics]}, {row_values: ["2", John Doe, johndoe@example.com, skpioepf234, Mathematics]}, {row_values: ["2", John Doe, johndoe@example.com, skpioepf234, Mathematics]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {name: [78, 97, 109, 101], table_oid: 24577, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [69, 109, 97, 105, 108], table_oid: 24577, table_attribute_number: 3, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [72, 97, 115, 104, 101, 100, 32, 80, 97, 115, 115, 119, 111, 114, 100], table_oid: 24577, table_attribute_number: 4, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [83, 117, 98, 106, 101, 99, 116, 32, 83, 116, 114, 101, 97, 109], table_oid: 24577, table_attribute_number: 5, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.233889547Z - restimestampmock: 2024-02-09T10:21:11.233922754Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-29 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: ROLLBACK - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 82 - - 79 - - 76 - - 76 - - 66 - - 65 - - 67 - - 75 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.236845177Z - restimestampmock: 2024-02-09T10:21:11.236868259Z diff --git a/fastapi-postgres/keploy/test-set-1/tests/test-1.yaml b/fastapi-postgres/keploy/test-set-1/tests/test-1.yaml deleted file mode 100755 index e5100d2..0000000 --- a/fastapi-postgres/keploy/test-set-1/tests/test-1.yaml +++ /dev/null @@ -1,55 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-1 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/students/ - header: - Accept: '*/*' - Content-Length: "105" - Content-Type: application/json - Host: 127.0.0.1:8000 - User-Agent: curl/8.2.1 - body: |- - { - "name": "Eva White", - "email": "evawhite@example.com", - "password": "evawhite111" - } - body_type: "" - timestamp: 2024-02-09T10:21:01.532943145Z - host: "" - resp: - status_code: 200 - header: - Content-Length: "107" - Content-Type: application/json - Date: Fri, 09 Feb 2024 10:21:00 GMT - Server: uvicorn - body: '{"name":"Eva White","email":"evawhite@example.com","password":"sfwbxijuf222","stream":"Mathematics","id":1}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2024-02-09T10:21:03.574647019Z - objects: [] - assertions: - noise: - header.Date: [] - created: 1707474063 -curl: |- - curl --request POST \ - --url http://127.0.0.1:8000/students/ \ - --header 'Host: 127.0.0.1:8000' \ - --header 'User-Agent: curl/8.2.1' \ - --header 'Accept: */*' \ - --header 'Content-Type: application/json' \ - --data '{ - "name": "Eva White", - "email": "evawhite@example.com", - "password": "evawhite111" - }' diff --git a/fastapi-postgres/keploy/test-set-1/tests/test-2.yaml b/fastapi-postgres/keploy/test-set-1/tests/test-2.yaml deleted file mode 100755 index ecddaf6..0000000 --- a/fastapi-postgres/keploy/test-set-1/tests/test-2.yaml +++ /dev/null @@ -1,55 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-2 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/students/ - header: - Accept: '*/*' - Content-Length: "106" - Content-Type: application/json - Host: 127.0.0.1:8000 - User-Agent: curl/8.2.1 - body: |4- - { - "name": "John Doe", - "email": "johndoe@example.com", - "password": "johndoe123" - } - body_type: "" - timestamp: 2024-02-09T10:21:11.21894436Z - host: "" - resp: - status_code: 200 - header: - Content-Length: "104" - Content-Type: application/json - Date: Fri, 09 Feb 2024 10:21:10 GMT - Server: uvicorn - body: '{"name":"John Doe","email":"johndoe@example.com","password":"skpioepf234","stream":"Mathematics","id":2}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2024-02-09T10:21:13.238027535Z - objects: [] - assertions: - noise: - header.Date: [] - created: 1707474073 -curl: |- - curl --request POST \ - --url http://127.0.0.1:8000/students/ \ - --header 'User-Agent: curl/8.2.1' \ - --header 'Accept: */*' \ - --header 'Content-Type: application/json' \ - --header 'Host: 127.0.0.1:8000' \ - --data ' { - "name": "John Doe", - "email": "johndoe@example.com", - "password": "johndoe123" - }' diff --git a/fastapi-postgres/requirements.txt b/fastapi-postgres/requirements.txt index 5201c90..c7ad5e0 100644 --- a/fastapi-postgres/requirements.txt +++ b/fastapi-postgres/requirements.txt @@ -16,7 +16,6 @@ itsdangerous==2.1.2 Jinja2==3.1.2 MarkupSafe==2.1.3 orjson==3.9.8 -psycopg2==2.9.9 psycopg2-binary==2.9.9 pydantic==2.4.2 pydantic-extra-types==2.1.0 diff --git a/fastapi-twilio/README.md b/fastapi-twilio/README.md index 0afbc7e..d1d5ca9 100644 --- a/fastapi-twilio/README.md +++ b/fastapi-twilio/README.md @@ -6,6 +6,7 @@ A sample FastAPI-Twilio app to test Keploy integration capabilities using [FastA ```bash git clone https://github.com/keploy/samples-python.git && cd samples-python/fastapi-twilio +pip3 install coverage pip3 install -r requirements.txt ``` @@ -14,8 +15,7 @@ pip3 install -r requirements.txt Keploy can be installed on Linux directly and on Windows with the help of WSL. Based on your system architecture, install the keploy latest binary release ```bash - curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh - keploy +curl -O https://keploy.io/install.sh && source install.sh ``` ### Get your Twilio Credentials @@ -28,7 +28,7 @@ Once you get the Twilio Account SID, Auth Token, and Phone Number, modify the `. This command will start the recording of API calls:- ```shell -keploy record -c "uvicorn main:app --reload" +keploy record -c "uvicorn main:app" ``` Make API Calls using Hoppscotch, Postman or cURL command. Keploy with capture those calls to generate the test-suites containing testcases and data mocks. @@ -37,25 +37,25 @@ Make API Calls using Hoppscotch, Postman or cURL command. Keploy with capture th 1. Replace the place holder below i.e. `YOUR_REGISTERED_PERSONAL_PHONE_NUMBER` with your registered personal phone number that you linked with Twilio. - ```bash - curl --location 'http://127.0.0.1:8000/send-sms/' \ - --header 'Content-Type: application/json' \ - --data '{ - "Body": "Test, testtt, testttttttssss :)", - "To": "YOUR_REGISTERED_PERSONAL_PHONE_NUMBER", - }' - ``` +```bash +curl --location 'http://127.0.0.1:8000/send-sms/' \ + --header 'Content-Type: application/json' \ + --data-raw '{ + "Body": "Test", + "To": "" + }' +``` 2. Replace the place holder below i.e. `SOME_WRONG_PHONE_NUMBER` with any wrong phone number and make the request. - ```bash - curl --location 'http://127.0.0.1:8000/send-sms/' \ +```bash +curl --location 'http://127.0.0.1:8000/send-sms/' \ --header 'Content-Type: application/json' \ - --data '{ + --data-raw '{ "Body": "Test, testtt, testttttttssss :)", - "To": "SOME_WRONG_PHONE_NUMBER", + "To": "", }' - ``` +``` Now all these API calls were captured as **editable** testcases and written to `keploy/tests` folder. The keploy directory would also have `mocks` file that contains all the outputs of Twilio operations. @@ -64,7 +64,9 @@ Now all these API calls were captured as **editable** testcases and written to ` Now let's run the application in test mode. ```shell -keploy test -c "uvicorn main:app --reload" --delay 10 +keploy test -c "python3 -m uvicorn main:app" --delay 10 ``` -So, no need to setup fake apis like Twilio or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to Twilio 😄** +So, no need to setup fake apis like Twilio or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to Twilio 😄** . We can notice that for a single API without using Twilio, we got around 89% of coverage : + +![testRun](./img/testrun.png) diff --git a/fastapi-twilio/img/testrun.png b/fastapi-twilio/img/testrun.png new file mode 100644 index 0000000..8173f8e Binary files /dev/null and b/fastapi-twilio/img/testrun.png differ diff --git a/fastapi-twilio/keploy-config.yaml b/fastapi-twilio/keploy-config.yaml deleted file mode 100755 index c7e3e02..0000000 --- a/fastapi-twilio/keploy-config.yaml +++ /dev/null @@ -1,64 +0,0 @@ -record: - path: "" - # mandatory - command: "" - proxyport: 0 - containerName: "" - networkName: "" - delay: 5 - passThroughPorts: [] -test: - path: "" - # mandatory - command: "" - proxyport: 0 - containerName: "" - networkName: "" - testSets: [] - globalNoise: |- - { - "global": { - "body": {}, - "header": {} - }, - "test-sets": { - "test-set-name": { - "body": {}, - "header": {} - } - } - } - delay: 5 - apiTimeout: 5 - passThroughPorts: [] - # - # Example on using globalNoise - # globalNoise: |- - # { - # "global": { - # "body": { - # # to ignore some values for a field, - # # pass regex patterns to the corresponding array value - # "url": ["https?://\S+", "http://\S+"], - # }, - # "header": { - # # to ignore the entire field, pass an empty array - # "Date: [], - # } - # }, - # # to ignore fields or the corresponding values for a specific test-set, - # # pass the test-set-name as a key to the "test-sets" object and - # # populate the corresponding "body" and "header" objects - # "test-sets": { - # "test-set-1": { - # "body": { - # # ignore all the values for the "url" field - # "url": [] - # }, - # "header": { - # # we can also pass the exact value to ignore for a field - # "User-Agent": ["PostmanRuntime/7.34.0"] - # } - # } - # } - # } diff --git a/fastapi-twilio/keploy.yml b/fastapi-twilio/keploy.yml new file mode 100755 index 0000000..34deba8 --- /dev/null +++ b/fastapi-twilio/keploy.yml @@ -0,0 +1,43 @@ +path: "" +appId: 0 +appName: "" +command: uvicorn main:app +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: "" +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + 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. diff --git a/fastapi-twilio/keploy/test-set-0/mocks.yaml b/fastapi-twilio/keploy/test-set-0/mocks.yaml deleted file mode 100755 index cd2a8bf..0000000 --- a/fastapi-twilio/keploy/test-set-0/mocks.yaml +++ /dev/null @@ -1,162 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: mocks -spec: - metadata: - name: Http - operation: POST - type: HTTP_CLIENT - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: /2010-04-01/Accounts/AC19413687d9ce28c80cda944730f8b286/Messages.json - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate - Authorization: Basic QUMxOTQxMzY4N2Q5Y2UyOGM4MGNkYTk0NDczMGY4YjI4NjpjMTc0MDc5YzU2NTA0N2FmYWJmNDk5MWI2ZGQ1MmFiYg== - Connection: keep-alive - Content-Length: "82" - Content-Type: application/x-www-form-urlencoded - User-Agent: python-requests/2.31.0 - body: Body=Test%2C+testtt%2C+testttttttssss+%3A%29&From=%2B16413324066&To=%2B91700004379 - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 400 - header: - Access-Control-Allow-Credentials: "true" - Access-Control-Allow-Headers: Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Idempotency-Key - Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS - Access-Control-Allow-Origin: '*' - Access-Control-Expose-Headers: ETag - Connection: keep-alive - Content-Length: 158,158 - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:29 GMT - Strict-Transport-Security: max-age=31536000 - Twilio-Concurrent-Requests: "1" - Twilio-Request-Duration: "0.051" - Twilio-Request-Id: RQec3c4676524fe2951583489e90bc1b33 - X-Api-Domain: api.twilio.com - X-Home-Region: us1 - X-Powered-By: AT-5000 - X-Shenanigans: none - body: '{"code": 21211, "message": "The ''To'' number +9170000XXXX is not a valid phone number", "more_info": "https://www.twilio.com/docs/errors/21211", "status": 400}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 0001-01-01T00:00:00Z - objects: [] - created: 1699953989 - reqTimestampMock: 2023-11-14T14:56:28.791864295+05:30 - resTimestampMock: 2023-11-14T14:56:29.304057844+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Http -name: mocks -spec: - metadata: - name: Http - operation: POST - type: HTTP_CLIENT - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: /2010-04-01/Accounts/AC19413687d9ce28c80cda944730f8b286/Messages.json - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate - Authorization: Basic QUMxOTQxMzY4N2Q5Y2UyOGM4MGNkYTk0NDczMGY4YjI4NjpjMTc0MDc5YzU2NTA0N2FmYWJmNDk5MWI2ZGQ1MmFiYg== - Connection: keep-alive - Content-Length: "83" - Content-Type: application/x-www-form-urlencoded - User-Agent: python-requests/2.31.0 - body: Body=Test%2C+testtt%2C+testttttttssss+%3A%29&From=%2B16413324066&To=%2B917000043797 - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 201 - header: - Access-Control-Allow-Credentials: "true" - Access-Control-Allow-Headers: Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Idempotency-Key - Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS - Access-Control-Allow-Origin: '*' - Access-Control-Expose-Headers: ETag - Connection: keep-alive - Content-Length: 834,834 - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:35 GMT - Twilio-Concurrent-Requests: "1" - Twilio-Request-Duration: "0.131" - Twilio-Request-Id: RQ2f5288499581f3fe12524b11bbb3d866 - X-Api-Domain: api.twilio.com - X-Home-Region: us1 - X-Powered-By: AT-5000 - X-Shenanigans: none - body: '{"body": "Sent from your Twilio trial account - Test, testtt, testttttttssss :)", "num_segments": "1", "direction": "outbound-api", "from": "+16413324066", "date_updated": "Tue, 14 Nov 2023 09:26:35 +0000", "price": null, "error_message": null, "uri": "/2010-04-01/Accounts/AC19413687d9ce28c80cda944730f8b286/Messages/SM2f5288499581f3fe12524b11bbb3d866.json", "account_sid": "AC19413687d9ce28c80cda944730f8b286", "num_media": "0", "to": "+917000043797", "date_created": "Tue, 14 Nov 2023 09:26:35 +0000", "status": "queued", "sid": "SM2f5288499581f3fe12524b11bbb3d866", "date_sent": null, "messaging_service_sid": null, "error_code": null, "price_unit": "USD", "api_version": "2010-04-01", "subresource_uris": {"media": "/2010-04-01/Accounts/AC19413687d9ce28c80cda944730f8b286/Messages/SM2f5288499581f3fe12524b11bbb3d866/Media.json"}}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 0001-01-01T00:00:00Z - objects: [] - created: 1699953995 - reqTimestampMock: 2023-11-14T14:56:34.833506359+05:30 - resTimestampMock: 2023-11-14T14:56:35.27188354+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Http -name: mocks -spec: - metadata: - name: Http - operation: POST - type: HTTP_CLIENT - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: /2010-04-01/Accounts/AC19413687d9ce28c80cda944730f8b286/Messages.json - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate - Authorization: Basic QUMxOTQxMzY4N2Q5Y2UyOGM4MGNkYTk0NDczMGY4YjI4NjpjMTc0MDc5YzU2NTA0N2FmYWJmNDk5MWI2ZGQ1MmFiYg== - Connection: keep-alive - Content-Length: "81" - Content-Type: application/x-www-form-urlencoded - User-Agent: python-requests/2.31.0 - body: Body=Test%2C+testtt%2C+testttttttssss+%3A%29&From=%2B16413324066&To=%2B9170000437 - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 400 - header: - Access-Control-Allow-Credentials: "true" - Access-Control-Allow-Headers: Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Idempotency-Key - Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS - Access-Control-Allow-Origin: '*' - Access-Control-Expose-Headers: ETag - Connection: keep-alive - Content-Length: 335,335 - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:27:21 GMT - Twilio-Concurrent-Requests: "1" - Twilio-Request-Duration: "0.080" - Twilio-Request-Id: RQb54d7f05d29e83bc89889cc136bcd99d - X-Api-Domain: api.twilio.com - X-Home-Region: us1 - X-Powered-By: AT-5000 - X-Shenanigans: none - body: '{"code": 21608, "message": "The number +917000XXXX is unverified. Trial accounts cannot send messages to unverified numbers; verify +917000XXXX at twilio.com/user/account/phone-numbers/verified, or purchase a Twilio number to send messages to unverified numbers", "more_info": "https://www.twilio.com/docs/errors/21608", "status": 400}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 0001-01-01T00:00:00Z - objects: [] - created: 1699954041 - reqTimestampMock: 2023-11-14T14:57:20.914415283+05:30 - resTimestampMock: 2023-11-14T14:57:21.298027703+05:30 diff --git a/fastapi-twilio/keploy/test-set-0/tests/test-1.yaml b/fastapi-twilio/keploy/test-set-0/tests/test-1.yaml deleted file mode 100755 index c088b98..0000000 --- a/fastapi-twilio/keploy/test-set-0/tests/test-1.yaml +++ /dev/null @@ -1,58 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-1 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "75" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: c871b715-7aae-46b6-8e0d-1341aa426624 - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+91700004379" - } - body_type: "" - timestamp: 2023-11-14T14:56:25.800517709+05:30 - resp: - status_code: 200 - header: - Content-Length: "73" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:25 GMT - Server: uvicorn - body: '{"message":"Failed to send SMS. Please check the provided phone number."}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2023-11-14T14:56:32.013566624+05:30 - objects: [] - assertions: - noise: - header.Date: [] - created: 1699953992 -curl: |- - curl --request POST \ - --url http://127.0.0.1:8000/send-sms/ \ - --header 'User-Agent: PostmanRuntime/7.34.0' \ - --header 'Accept: */*' \ - --header 'Postman-Token: c871b715-7aae-46b6-8e0d-1341aa426624' \ - --header 'Host: 127.0.0.1:8000' \ - --header 'Accept-Encoding: gzip, deflate, br' \ - --header 'Connection: keep-alive' \ - --header 'Content-Type: application/json' \ - --data '{ - "Body": "Test, testtt, testttttttssss :)", - "To": "+91700004379" - }' diff --git a/fastapi-twilio/keploy/test-set-0/tests/test-2.yaml b/fastapi-twilio/keploy/test-set-0/tests/test-2.yaml deleted file mode 100755 index bb9db1e..0000000 --- a/fastapi-twilio/keploy/test-set-0/tests/test-2.yaml +++ /dev/null @@ -1,58 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-2 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "76" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: a3780363-733f-4c88-915b-d4d69384822c - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+917000043797" - } - body_type: "" - timestamp: 2023-11-14T14:56:33.722179585+05:30 - resp: - status_code: 200 - header: - Content-Length: "36" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:33 GMT - Server: uvicorn - body: '{"message":"SMS sent successfully!"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2023-11-14T14:56:37.588988851+05:30 - objects: [] - assertions: - noise: - header.Date: [] - created: 1699953997 -curl: |- - curl --request POST \ - --url http://127.0.0.1:8000/send-sms/ \ - --header 'Content-Type: application/json' \ - --header 'User-Agent: PostmanRuntime/7.34.0' \ - --header 'Accept: */*' \ - --header 'Postman-Token: a3780363-733f-4c88-915b-d4d69384822c' \ - --header 'Host: 127.0.0.1:8000' \ - --header 'Accept-Encoding: gzip, deflate, br' \ - --header 'Connection: keep-alive' \ - --data '{ - "Body": "Test, testtt, testttttttssss :)", - "To": "+917000043797" - }' diff --git a/fastapi-twilio/keploy/test-set-0/tests/test-3.yaml b/fastapi-twilio/keploy/test-set-0/tests/test-3.yaml deleted file mode 100755 index 3a01fb6..0000000 --- a/fastapi-twilio/keploy/test-set-0/tests/test-3.yaml +++ /dev/null @@ -1,58 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-3 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "74" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: 5e8c1a07-c35d-4816-8b32-c6bcfd28d94d - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+9170000437" - } - body_type: "" - timestamp: 2023-11-14T14:57:19.642139975+05:30 - resp: - status_code: 200 - header: - Content-Length: "73" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:27:18 GMT - Server: uvicorn - body: '{"message":"Failed to send SMS. Please check the provided phone number."}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2023-11-14T14:57:23.973137683+05:30 - objects: [] - assertions: - noise: - header.Date: [] - created: 1699954043 -curl: |- - curl --request POST \ - --url http://127.0.0.1:8000/send-sms/ \ - --header 'Accept: */*' \ - --header 'Postman-Token: 5e8c1a07-c35d-4816-8b32-c6bcfd28d94d' \ - --header 'Host: 127.0.0.1:8000' \ - --header 'Accept-Encoding: gzip, deflate, br' \ - --header 'Connection: keep-alive' \ - --header 'Content-Type: application/json' \ - --header 'User-Agent: PostmanRuntime/7.34.0' \ - --data '{ - "Body": "Test, testtt, testttttttssss :)", - "To": "+9170000437" - }' diff --git a/fastapi-twilio/keploy/testReports/report-1.yaml b/fastapi-twilio/keploy/testReports/report-1.yaml deleted file mode 100755 index acf2233..0000000 --- a/fastapi-twilio/keploy/testReports/report-1.yaml +++ /dev/null @@ -1,284 +0,0 @@ -version: api.keploy.io/v1beta1 -name: report-1 -status: PASSED -success: 3 -failure: 0 -total: 3 -tests: - - kind: Http - name: report-1 - status: PASSED - started: 1699954104 - completed: 1699954106 - test_case_path: /home/shashwat/test/python-twilio/keploy/test-set-0 - mock_path: "" - test_case_id: test-1 - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "75" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: c871b715-7aae-46b6-8e0d-1341aa426624 - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+91700004379" - } - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 200 - header: - Content-Length: "73" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:25 GMT - Server: uvicorn - body: '{"message":"Failed to send SMS. Please check the provided phone number."}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 0001-01-01T00:00:00Z - noise: - header.Date: [] - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Content-Length - value: - - "73" - actual: - key: Content-Length - value: - - "73" - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Tue, 14 Nov 2023 09:26:25 GMT - actual: - key: Date - value: - - Tue, 14 Nov 2023 09:28:24 GMT - - normal: true - expected: - key: Server - value: - - uvicorn - actual: - key: Server - value: - - uvicorn - body_result: - - normal: true - type: JSON - expected: '{"message":"Failed to send SMS. Please check the provided phone number."}' - actual: '{"message":"Failed to send SMS. Please check the provided phone number."}' - dep_result: [] - - kind: Http - name: report-1 - status: PASSED - started: 1699954106 - completed: 1699954107 - test_case_path: /home/shashwat/test/python-twilio/keploy/test-set-0 - mock_path: "" - test_case_id: test-2 - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "76" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: a3780363-733f-4c88-915b-d4d69384822c - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+917000043797" - } - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 200 - header: - Content-Length: "36" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:33 GMT - Server: uvicorn - body: '{"message":"SMS sent successfully!"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 0001-01-01T00:00:00Z - noise: - header.Date: [] - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Tue, 14 Nov 2023 09:26:33 GMT - actual: - key: Date - value: - - Tue, 14 Nov 2023 09:28:26 GMT - - normal: true - expected: - key: Server - value: - - uvicorn - actual: - key: Server - value: - - uvicorn - - normal: true - expected: - key: Content-Length - value: - - "36" - actual: - key: Content-Length - value: - - "36" - body_result: - - normal: true - type: JSON - expected: '{"message":"SMS sent successfully!"}' - actual: '{"message":"SMS sent successfully!"}' - dep_result: [] - - kind: Http - name: report-1 - status: PASSED - started: 1699954107 - completed: 1699954108 - test_case_path: /home/shashwat/test/python-twilio/keploy/test-set-0 - mock_path: "" - test_case_id: test-3 - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "74" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: 5e8c1a07-c35d-4816-8b32-c6bcfd28d94d - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+9170000437" - } - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 200 - header: - Content-Length: "73" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:27:18 GMT - Server: uvicorn - body: '{"message":"Failed to send SMS. Please check the provided phone number."}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 0001-01-01T00:00:00Z - noise: - header.Date: [] - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Tue, 14 Nov 2023 09:27:18 GMT - actual: - key: Date - value: - - Tue, 14 Nov 2023 09:28:27 GMT - - normal: true - expected: - key: Server - value: - - uvicorn - actual: - key: Server - value: - - uvicorn - - normal: true - expected: - key: Content-Length - value: - - "73" - actual: - key: Content-Length - value: - - "73" - body_result: - - normal: true - type: JSON - expected: '{"message":"Failed to send SMS. Please check the provided phone number."}' - actual: '{"message":"Failed to send SMS. Please check the provided phone number."}' - dep_result: [] -test_set: test-set-0 diff --git a/fastapi-twilio/main.py b/fastapi-twilio/main.py index 82800cd..4cbb40c 100644 --- a/fastapi-twilio/main.py +++ b/fastapi-twilio/main.py @@ -3,18 +3,17 @@ from dotenv import load_dotenv from pydantic import BaseModel import os +import asyncio - +# Load environment variables from a .env file load_dotenv() - class Message(BaseModel): Body: str To: str app = FastAPI() - @app.post('/send-sms/') def send_sms(data: Message): twilio_account_sid = os.getenv('TWILIO_ACCOUNT_SID') @@ -37,3 +36,10 @@ def send_sms(data: Message): return {"message": "Failed to send SMS. Please check the provided phone number."} except Exception as e: return {"message": str(e)} + +# Graceful shutdown +@app.on_event("shutdown") +async def shutdown_event(): + print("Shutting down gracefully...") + # Perform any additional cleanup here if needed + # For example, closing database connections or other resources \ No newline at end of file diff --git a/fastapi-twilio/requirements.txt b/fastapi-twilio/requirements.txt index d86cb8b..7a9ca73 100644 --- a/fastapi-twilio/requirements.txt +++ b/fastapi-twilio/requirements.txt @@ -26,3 +26,28 @@ typing_extensions==4.8.0 urllib3==2.0.7 uvicorn==0.24.0.post1 yarl==1.9.2 +blinker==1.5 +chardet==5.1.0 +configobj==5.0.8 +cryptography==38.0.4 +httplib2==0.20.4 +Jinja2==3.1.2 +jsonpatch==1.32 +jsonpointer==2.3 +jsonschema==4.10.3 +markdown-it-py==2.1.0 +MarkupSafe==2.1.2 +mdurl==0.1.2 +netifaces==0.11.0 +oauthlib==3.2.2 +Pygments==2.14.0 +pyparsing==3.0.9 +pyrsistent==0.18.1 +pyserial==3.5 +PySimpleSOAP==1.16.2 +python-debian==0.1.49 +python-debianbts==4.0.1 +PyYAML==6.0 +rich==13.3.1 +six==1.16.0 +ssh-import-id==5.10 diff --git a/flask-mongo/Dockerfile b/flask-mongo/Dockerfile index cbefd2c..f892efb 100644 --- a/flask-mongo/Dockerfile +++ b/flask-mongo/Dockerfile @@ -14,4 +14,4 @@ RUN pip3 install -r requirements.txt EXPOSE 6000 # Start the Flask application -CMD ["python3", "app.py"] +CMD ["python3", "app.py"] \ No newline at end of file diff --git a/flask-mongo/README.md b/flask-mongo/README.md index 54bc693..5239c2b 100644 --- a/flask-mongo/README.md +++ b/flask-mongo/README.md @@ -1,6 +1,7 @@ +# Flask-Mongo Sample Application + This application is a simple student management API built using Python's Flask framework and MongoDB for data storage. It allows you to perform basic CRUD (Create, Read, Update, Delete) operations on student records. The API supports CORS (Cross-Origin Resource Sharing) to facilitate cross-domain requests. -## Table of Contents # Introduction @@ -10,10 +11,18 @@ This application is a simple student management API built using Python's Flask f - Install WSL (`wsl --install`) for Windows Windows. -## Optional 🛠️ +#### Optional 🛠️ - Install Colima( `brew install colima && colima start` ) for MacOS MacOs. +## Install Keploy + +- Install Keploy CLI using the following command: + +```bash +curl -O -L https://keploy.io/install.sh && source install.sh +``` + ## Get Started! 🎬 ## Setup the MongoDB Database 📦 @@ -34,40 +43,16 @@ docker run -p 27017:27017 -d --network backend --name mongo mongo ```bash git clone https://github.com/keploy/samples-python.git && cd samples-python/flask-mongo +pip3 install -r requirements.txt ``` ## Installation 📥 -Depending on your OS, choose your adventure: - --
- Linux Linux or Windows Windows - - Alright, let's equip ourselves with the **latest Keploy binary**: - - ```bash - curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp - - sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy - ``` - - If everything goes right, your screen should look a bit like this: - - Moving on... -
- Run App with Docker Container Docker - - #### Add alias for Keploy: - - ```bash - alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy' - ``` - - ### Lights, Camera, Record! 🎥 + ### With Docker 🎥 Build the app image: - ```bash + ```sh docker build -t flask-app:1.0 . ``` @@ -88,7 +73,13 @@ Depending on your OS, choose your adventure: **1. Make a POST request** ```bash - curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345 + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students + ``` + + Let's add one more student: + + ```sh + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students ``` **2. Make a GET request** @@ -226,12 +217,9 @@ Depending on your OS, choose your adventure: Happy coding! ✨👩‍💻👨‍💻✨ -
-
- -
- Run App on 🐧 Linux +--- + ## Running In Linux/WSL We'll be running our sample application right on Linux, but just to make things a tad more thrilling, we'll have the database (PostgreSQL) chill on Docker. Ready? Let's get the party started!🎉 ### 📼 Roll the Tape - Recording Time! @@ -262,205 +250,14 @@ Depending on your OS, choose your adventure: **1. Make a POST request** - ```bash - curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345 - ``` - - **2. Make a GET request** - - ```bash - curl http://localhost:6000/students - ``` - - **3. Make a PUT request** - - ```bash - curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345 - ``` - - **4. Make a GET request** - - ```bash - curl http://localhost:6000/students/12345 - ``` - - **5. Make a DELETE request** - - ```bash - curl -X DELETE http://localhost:6000/students/12345 - ``` - - 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 `test-1.yml` and `mocks.yml`. - - ```yaml - version: api.keploy.io/v1beta2 - kind: Http - name: test-1 - spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://localhost:6000/students - header: - Accept: "*/*" - Content-Length: "56" - Content-Type: application/json - Host: localhost:6000 - User-Agent: curl/7.81.0 - body: '{"student_id": "12344", "name": "John Doeww", "age": 10}' - body_type: "" - timestamp: 2023-11-13T13:02:32.241333562Z - resp: - status_code: 200 - header: - Content-Length: "48" - Content-Type: application/json - Date: Mon, 13 Nov 2023 13:02:32 GMT - Server: Werkzeug/2.2.2 Python/3.9.18 - body: | - { - "message": "Student created successfully" - } - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2023-11-13T13:02:34.752123715Z - objects: [] - assertions: - noise: - - header.Date - created: 1699880554 - curl: |- - curl --request POST \ - --url http://localhost:6000/students \ - --header 'Host: localhost:6000' \ - --header 'User-Agent: curl/7.81.0' \ - --header 'Accept: */*' \ - --header 'Content-Type: application/json' \ - --data '{"student_id": "12344", "name": "John Doeww", "age": 10}' - ``` - - This is how `mocks.yml` generated would look like:- - - ```yaml - version: api.keploy.io/v1beta2 - kind: Mongo - name: mocks - spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"students","filter":{"student_id":"12345"},"projection":{"_id":{"$numberInt":"0"}},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"vPKsEFRdTLytlbnyVimqIA==","subType":"04"}}},"$db":"studentsdb"} }], checksum: 0 }' - requests: - - header: - length: 187 - requestId: 2127584089 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"find":"students","filter":{"student_id":"12345"},"projection":{"_id":{"$numberInt":"0"}},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"vPKsEFRdTLytlbnyVimqIA==","subType":"04"}}},"$db":"studentsdb"} }' - checksum: 0 - read_delay: 3469848802 - responses: - - header: - length: 166 - requestId: 154 - responseTo: 2127584089 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"student_id":"12345","name":"John Doe","age":{"$numberInt":"20"}}],"id":{"$numberLong":"0"},"ns":"studentsdb.students"},"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 869555 - created: 1699880576 - reqTimestampMock: 2023-11-13T13:02:56.385067848Z - resTimestampMock: 2023-11-13T13:02:56.386374941Z + ```bash + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students ``` - Want to see if everything works as expected? - - #### Run Tests - - Time to put things to the test 🧪 + Let's add one more student: - ```shell - keploy test -c "python3 app.py" --delay 10 - ``` - - > The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking. - - Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the `mocks.yml`, or fiddle with the request or response in `test-x.yml`. Run the tests again and see the magic unfold!✨👩‍💻👨‍💻✨ - - ## 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! ✨👩‍💻👨‍💻✨ -
- -
- -
- --
- MacOS MacOs - - Dive straight in, but first in case you're using **Keploy** with **Colima**, give it a gentle nudge with (`colima start`). Let's make sure it's awake and ready for action! - - ### Add alias for Keploy 🐰: - - For the sake of convenience (and a bit of Mac magic 🪄), let's set up a shortcut for Keploy: - - ### Use Keploy with Docker-Desktop - - Note: To run Keploy on MacOS through [Docker](https://docs.docker.com/desktop/release-notes/#4252) the version must be `4.25.2` or above. - - #### Creating Docker Volume - - ```bash - docker volume create --driver local --opt type=debugfs --opt device=debugfs debugfs - ``` - - ```bash - alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v debugfs:/sys/kernel/debug:rw -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy' - ``` - - ### Use Keploy with Colima - - ```bash - alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy' - ``` - - ### Lights, Camera, Record! 🎥 - - Build the app image: - - ```bash - docker build -t flask-app:1.0 . - ``` - - Capture the test-cases- - - ```shell - keploy record -c "docker run -p 6000:6000 --name DjangoApp --network backend --name flask-app flask-app:1.0" - ``` - - 🔥**Make some API calls**. Postman, Hoppscotch or even curl - take your pick! - - Let's make URLs short and sweet: - - ### Generate testcases - - To generate testcases we just need to **make some API calls.** - - **1. Make a POST request** - - ```bash - curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345 + ```sh + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students ``` **2. Make a GET request** @@ -577,16 +374,19 @@ Depending on your OS, choose your adventure: reqTimestampMock: 2023-11-13T13:02:56.385067848Z resTimestampMock: 2023-11-13T13:02:56.386374941Z ``` + + On terminal we can see the testcases generated - - Want to see if everything works as expected? + ![keploy testcases](./img/testcases.png) #### Run Tests Time to put things to the test 🧪 ```shell - keploy test -c "sudo docker run -p 6000:6000 --rm --network backend --name flask-app flask-app:1.0" --delay 10 + keploy test -c "python3 app.py" --delay 10 ``` + ![keploy testrun](./img/testrun-with-coverage.png) > The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking. @@ -594,7 +394,6 @@ Depending on your OS, choose your adventure: ## 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.😊🚀 + 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! ✨👩‍💻👨‍💻✨ -
+ Happy coding! ✨👩‍💻👨‍💻✨ \ No newline at end of file diff --git a/flask-mongo/app.py b/flask-mongo/app.py index 6e31416..8a6418b 100644 --- a/flask-mongo/app.py +++ b/flask-mongo/app.py @@ -3,6 +3,7 @@ from flask_cors import CORS import collections.abc + app = Flask(__name__) cors = CORS(app, resources={r"/api/*": {"origins": "*"}}) diff --git a/flask-mongo/call.sh b/flask-mongo/call.sh new file mode 100644 index 0000000..ca13ded --- /dev/null +++ b/flask-mongo/call.sh @@ -0,0 +1,13 @@ + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students + + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12347", "name": "Bob Brown", "age": 24}' http://localhost:6000/students + + curl http://localhost:6000/students + curl http://localhost:6000/students/12345 + curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345 + curl -X DELETE http://localhost:6000/students/12345 \ No newline at end of file diff --git a/flask-mongo/docker-compose.yml b/flask-mongo/docker-compose.yml index 7ef7346..5e8b47b 100644 --- a/flask-mongo/docker-compose.yml +++ b/flask-mongo/docker-compose.yml @@ -8,7 +8,7 @@ services: volumes: - data:/data/db networks: - - backend + - keploy-network flask-app: image: flask-app:1.0 @@ -20,10 +20,10 @@ services: depends_on: - mongo networks: - - backend + - keploy-network networks: - backend: + keploy-network: external: true volumes: - data: + data: \ No newline at end of file diff --git a/flask-mongo/img/testcases.png b/flask-mongo/img/testcases.png new file mode 100644 index 0000000..2199621 Binary files /dev/null and b/flask-mongo/img/testcases.png differ diff --git a/flask-mongo/img/testrun-with-coverage.png b/flask-mongo/img/testrun-with-coverage.png new file mode 100644 index 0000000..2f3ee30 Binary files /dev/null and b/flask-mongo/img/testrun-with-coverage.png differ diff --git a/flask-mongo/keploy.yml b/flask-mongo/keploy.yml new file mode 100755 index 0000000..e71edbf --- /dev/null +++ b/flask-mongo/keploy.yml @@ -0,0 +1,43 @@ +path: "" +appId: 0 +appName: "" +command: python3 app.py +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: "" +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + 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. diff --git a/flask-mongo/keploy/test-set-1/config.yaml b/flask-mongo/keploy/test-set-1/config.yaml deleted file mode 100755 index e451518..0000000 --- a/flask-mongo/keploy/test-set-1/config.yaml +++ /dev/null @@ -1,167 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Mongo -name: config -spec: - metadata: - operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo","version": "4.4.1"},"os": {"type": "Linux","name": "Linux","architecture": "aarch64","version": "6.1.29-0-virt"},"platform": "CPython 3.9.17.final.0"}}, returnFieldsSelector: }' - requests: - - header: - length: 262 - requestId: 1890541915 - responseTo: 0 - Opcode: 2004 - message: - flags: 0 - collection_name: admin.$cmd - number_to_skip: 0 - number_to_return: -1 - query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo","version":"4.4.1"},"os":{"type":"Linux","name":"Linux","architecture":"aarch64","version":"6.1.29-0-virt"},"platform":"CPython 3.9.17.final.0"}}' - return_fields_selector: "" - read_delay: 82208 - responses: - - header: - length: 329 - requestId: 3 - responseTo: 1890541915 - Opcode: 1 - message: - response_flags: 8 - cursor_id: 0 - starting_from: 0 - number_returned: 1 - documents: - - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1692190448932"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"17"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}' - read_delay: 659750 - created: 1692190448 ---- -version: api.keploy.io/v1beta2 -kind: Mongo -name: config -spec: - metadata: - operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo","version": "4.4.1"},"os": {"type": "Linux","name": "Linux","architecture": "aarch64","version": "6.1.29-0-virt"},"platform": "CPython 3.9.17.final.0"},"compression": []}, returnFieldsSelector: }' - requests: - - header: - length: 280 - requestId: 1076681270 - responseTo: 0 - Opcode: 2004 - message: - flags: 0 - collection_name: admin.$cmd - number_to_skip: 0 - number_to_return: -1 - query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo","version":"4.4.1"},"os":{"type":"Linux","name":"Linux","architecture":"aarch64","version":"6.1.29-0-virt"},"platform":"CPython 3.9.17.final.0"},"compression":[]}' - return_fields_selector: "" - read_delay: 51917 - responses: - - header: - length: 329 - requestId: 4 - responseTo: 1076681270 - Opcode: 1 - message: - response_flags: 8 - cursor_id: 0 - starting_from: 0 - number_returned: 1 - documents: - - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1692190448936"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"2"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"17"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}' - read_delay: 999250 - created: 1692190448 ---- -version: api.keploy.io/v1beta2 -kind: Mongo -name: config -spec: - metadata: - operation: '{ OpMsg flags: 65536, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }], checksum: 0 }' - requests: - - header: - length: 134 - requestId: 613273587 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 65536 - sections: - - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }' - checksum: 0 - read_delay: 3336333 - responses: - - header: - length: 313 - requestId: 10 - responseTo: 613273587 - Opcode: 2013 - message: - flagBits: 2 - sections: - - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1692190458940"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"17"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 10005077213 - created: 1692190458 ---- -version: api.keploy.io/v1beta2 -kind: Mongo -name: config -spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }], checksum: 0 }' - requests: - - header: - length: 52 - requestId: 1075693109 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }' - checksum: 0 - read_delay: 10043184088 - responses: - - header: - length: 313 - requestId: 11 - responseTo: 1075693109 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1692190458982"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"3"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"17"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 746417 - created: 1692190458 ---- -version: api.keploy.io/v1beta2 -kind: Mongo -name: config -spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }], checksum: 0 }' - requests: - - header: - length: 65 - requestId: 1299455543 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }' - checksum: 0 - read_delay: 10042282047 - responses: - - header: - length: 314 - requestId: 15 - responseTo: 1299455543 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1692190469027"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"3"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"17"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 1815417 - created: 1692190469 diff --git a/flask-mongo/keploy/test-set-1/mocks.yaml b/flask-mongo/keploy/test-set-1/mocks.yaml deleted file mode 100755 index 3051236..0000000 --- a/flask-mongo/keploy/test-set-1/mocks.yaml +++ /dev/null @@ -1,64 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Mongo -name: mocks -spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"students","ordered":true,"lsid":{"id":{"$binary":{"base64":"HHvg4XLYQFWra6WjBn1j/A==","subType":"04"}}},"$db":"studentsdb"} }, { SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"64dcc6f03b29d5de7bb2ae07"},"student_id":"123","name":"Sarthak","age":{"$numberInt":"20"}} ] }], checksum: 0 }' - requests: - - header: - length: 197 - requestId: 1340074696 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"insert":"students","ordered":true,"lsid":{"id":{"$binary":{"base64":"HHvg4XLYQFWra6WjBn1j/A==","subType":"04"}}},"$db":"studentsdb"} }' - - '{ SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"64dcc6f03b29d5de7bb2ae07"},"student_id":"123","name":"Sarthak","age":{"$numberInt":"20"}} ] }' - checksum: 0 - read_delay: 566167 - responses: - - header: - length: 45 - requestId: 6 - responseTo: 1340074696 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 27458 - created: 1692190448 ---- -version: api.keploy.io/v1beta2 -kind: Mongo -name: mocks -spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"students","filter":{},"projection":{"_id":{"$numberInt":"0"}},"lsid":{"id":{"$binary":{"base64":"HHvg4XLYQFWra6WjBn1j/A==","subType":"04"}}},"$db":"studentsdb"} }], checksum: 0 }' - requests: - - header: - length: 140 - requestId: 1596327406 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"find":"students","filter":{},"projection":{"_id":{"$numberInt":"0"}},"lsid":{"id":{"$binary":{"base64":"HHvg4XLYQFWra6WjBn1j/A==","subType":"04"}}},"$db":"studentsdb"} }' - checksum: 0 - read_delay: 9681533921 - responses: - - header: - length: 273 - requestId: 9 - responseTo: 1596327406 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"student_id":"123","name":"Sarthak","age":{"$numberInt":"20"}},{"student_id":"123","name":"Sarthak","age":{"$numberInt":"20"}},{"student_id":"123","name":"Sarthak","age":{"$numberInt":"20"}}],"id":{"$numberLong":"0"},"ns":"studentsdb.students"},"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 40167 - created: 1692190458 diff --git a/flask-mongo/keploy/test-set-1/test-1.yaml b/flask-mongo/keploy/test-set-1/test-1.yaml deleted file mode 100755 index 4141f28..0000000 --- a/flask-mongo/keploy/test-set-1/test-1.yaml +++ /dev/null @@ -1,38 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Http -name: test-1 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://localhost:6000/students - header: - Accept: '*/*' - Content-Length: "51" - Content-Type: application/json - Host: localhost:6000 - User-Agent: curl/7.77.0 - body: '{"student_id": "123", "name": "Sarthak", "age": 20}' - body_type: "" - resp: - status_code: 200 - header: - Content-Length: "48" - Content-Type: application/json - Date: Wed, 16 Aug 2023 12:54:08 GMT - Server: Werkzeug/2.3.7 Python/3.9.17 - body: | - { - "message": "Student created successfully" - } - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - objects: [] - assertions: - noise: - - header.Date - created: 1692190448 diff --git a/flask-mongo/keploy/test-set-1/test-2.yaml b/flask-mongo/keploy/test-set-1/test-2.yaml deleted file mode 100755 index 77cb4a3..0000000 --- a/flask-mongo/keploy/test-set-1/test-2.yaml +++ /dev/null @@ -1,34 +0,0 @@ -version: api.keploy.io/v1beta2 -kind: Http -name: test-2 -spec: - metadata: {} - req: - method: GET - proto_major: 1 - proto_minor: 1 - url: http://localhost:6000/students - header: - Accept: '*/*' - Host: localhost:6000 - User-Agent: curl/7.77.0 - body: "" - body_type: "" - resp: - status_code: 200 - header: - Content-Length: "224" - Content-Type: application/json - Date: Wed, 16 Aug 2023 12:54:18 GMT - Server: Werkzeug/2.3.7 Python/3.9.17 - body: "[\n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }\n]\n" - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - objects: [] - assertions: - noise: - - header.Date - - body.name - created: 1692190458 diff --git a/flask-mongo/keploy/testReports/report-1.yaml b/flask-mongo/keploy/testReports/report-1.yaml deleted file mode 100755 index 14623ce..0000000 --- a/flask-mongo/keploy/testReports/report-1.yaml +++ /dev/null @@ -1,181 +0,0 @@ -version: api.keploy.io/v1beta1 -name: report-1 -status: PASSED -success: 2 -failure: 0 -total: 2 -tests: - - kind: Http - name: report-1 - status: PASSED - started: 1692258836 - completed: 1692258836 - test_case_path: /files/keploy - mock_path: "" - test_case_id: test-1 - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://172.19.0.4:6000/students - header: - Accept: '*/*' - Content-Length: "51" - Content-Type: application/json - Host: localhost:6000 - User-Agent: curl/7.77.0 - body: '{"student_id": "123", "name": "Sarthak", "age": 20}' - body_type: "" - resp: - status_code: 200 - header: - Content-Length: "48" - Content-Type: application/json - Date: Wed, 16 Aug 2023 12:54:08 GMT - Server: Werkzeug/2.3.7 Python/3.9.17 - body: | - { - "message": "Student created successfully" - } - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - noise: - - header.Date - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Server - value: - - Werkzeug/2.3.7 Python/3.9.17 - actual: - key: Server - value: - - Werkzeug/2.3.7 Python/3.9.17 - - normal: true - expected: - key: Content-Length - value: - - "48" - actual: - key: Content-Length - value: - - "48" - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Wed, 16 Aug 2023 12:54:08 GMT - actual: - key: Date - value: - - Thu, 17 Aug 2023 07:53:56 GMT - body_result: - - normal: true - type: JSON - expected: | - { - "message": "Student created successfully" - } - actual: | - { - "message": "Student created successfully" - } - dep_result: [] - - kind: Http - name: report-1 - status: PASSED - started: 1692258836 - completed: 1692258836 - test_case_path: /files/keploy - mock_path: "" - test_case_id: test-2 - req: - method: GET - proto_major: 1 - proto_minor: 1 - url: http://172.19.0.4:6000/students - header: - Accept: '*/*' - Host: localhost:6000 - User-Agent: curl/7.77.0 - body: "" - body_type: "" - resp: - status_code: 200 - header: - Content-Length: "224" - Content-Type: application/json - Date: Wed, 16 Aug 2023 12:54:18 GMT - Server: Werkzeug/2.3.7 Python/3.9.17 - body: "[\n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }\n]\n" - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - noise: - - header.Date - - body.name - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Date - value: - - Wed, 16 Aug 2023 12:54:18 GMT - actual: - key: Date - value: - - Thu, 17 Aug 2023 07:53:56 GMT - - normal: true - expected: - key: Server - value: - - Werkzeug/2.3.7 Python/3.9.17 - actual: - key: Server - value: - - Werkzeug/2.3.7 Python/3.9.17 - - normal: true - expected: - key: Content-Length - value: - - "224" - actual: - key: Content-Length - value: - - "224" - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - body_result: - - normal: true - type: JSON - expected: "[\n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }\n]\n" - actual: "[\n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }\n]\n" - dep_result: [] diff --git a/flask-mongo/postman_tests/delete.js b/flask-mongo/postman_tests/delete.js new file mode 100644 index 0000000..a2e8f13 --- /dev/null +++ b/flask-mongo/postman_tests/delete.js @@ -0,0 +1,17 @@ +pm.test("Status code is 200 or 404", function () { + pm.expect(pm.response.code).to.be.oneOf([200, 404]); +}); + +pm.test("Successful deletion response message", function () { + if (pm.response.code === 200) { + var jsonData = pm.response.json(); + pm.expect(jsonData.message).to.eql("Task deleted successfully"); + } +}); + +pm.test("Task not found", function () { + if (pm.response.code === 404) { + var jsonData = pm.response.json(); + pm.expect(jsonData.error).to.eql("Task not found"); + } +}); diff --git a/flask-mongo/postman_tests/get.js b/flask-mongo/postman_tests/get.js new file mode 100644 index 0000000..74b758a --- /dev/null +++ b/flask-mongo/postman_tests/get.js @@ -0,0 +1,17 @@ +pm.test("Status code is 200", function () { + pm.response.to.have.status(200); +}); + +pm.test("Response is an array", function () { + var jsonData = pm.response.json(); + pm.expect(jsonData.tasks).to.be.an("array"); +}); + +pm.test("Each task has an id, title, and description", function () { + var jsonData = pm.response.json(); + jsonData.tasks.forEach(function (task) { + pm.expect(task).to.have.property("id"); + pm.expect(task).to.have.property("title"); + pm.expect(task).to.have.property("description"); + }); +}); diff --git a/flask-mongo/postman_tests/post.js b/flask-mongo/postman_tests/post.js new file mode 100644 index 0000000..9efeeb8 --- /dev/null +++ b/flask-mongo/postman_tests/post.js @@ -0,0 +1,14 @@ +pm.test("Status code is 201", function () { + pm.response.to.have.status(201); +}); + +pm.test("Response contains task ID", function () { + var jsonData = pm.response.json(); + pm.expect(jsonData).to.have.property("id"); + pm.expect(jsonData.id).to.not.be.empty; +}); + +pm.test("Response message is correct", function () { + var jsonData = pm.response.json(); + pm.expect(jsonData.message).to.eql("Task created successfully"); +}); diff --git a/flask-mongo/postman_tests/put.js b/flask-mongo/postman_tests/put.js new file mode 100644 index 0000000..d8af377 --- /dev/null +++ b/flask-mongo/postman_tests/put.js @@ -0,0 +1,17 @@ +pm.test("Status code is 200 or 404", function () { + pm.expect(pm.response.code).to.be.oneOf([200, 404]); +}); + +pm.test("Successful update response message", function () { + if (pm.response.code === 200) { + var jsonData = pm.response.json(); + pm.expect(jsonData.message).to.eql("Task updated successfully"); + } +}); + +pm.test("Task not found or no changes made", function () { + if (pm.response.code === 404) { + var jsonData = pm.response.json(); + pm.expect(jsonData.error).to.eql("Task not found or no changes were made"); + } +}); diff --git a/flask-mongo/requirements.txt b/flask-mongo/requirements.txt index 7a03746..cbc61f9 100644 --- a/flask-mongo/requirements.txt +++ b/flask-mongo/requirements.txt @@ -1,4 +1,42 @@ Flask pymongo==4.4.1 Flask-Cors==3.0.10 -Werkzeug==2.2.2 \ No newline at end of file +Werkzeug==2.2.2 +annotated-types==0.7.0 +anyio==4.4.0 +certifi==2024.7.4 +charset-normalizer==3.3.2 +click==8.1.7 +coverage==7.6.0 +dnspython==2.6.1 +email_validator==2.2.0 +fastapi==0.111.1 +fastapi-cli==0.0.4 +h11==0.14.0 +httpcore==1.0.5 +httptools==0.6.1 +httpx==0.27.0 +idna==3.7 +Jinja2==3.1.4 +keploy==2.0.0a39 +markdown-it-py==3.0.0 +MarkupSafe==2.1.5 +mdurl==0.1.2 +pydantic==2.8.2 +pydantic_core==2.20.1 +Pygments==2.18.0 +python-dotenv==1.0.1 +python-multipart==0.0.9 +PyYAML==6.0.1 +requests==2.32.3 +rich==13.7.1 +shellingham==1.5.4 +sniffio==1.3.1 +starlette==0.37.2 +typer==0.12.3 +typing_extensions==4.12.2 +urllib3==2.2.2 +uvicorn==0.30.3 +uvloop==0.19.0 +watchfiles==0.22.0 +websockets==12.0 diff --git a/flask-mongo/test_app.py b/flask-mongo/test_app.py new file mode 100644 index 0000000..f07148a --- /dev/null +++ b/flask-mongo/test_app.py @@ -0,0 +1,32 @@ +import pytest +from flask import Flask, json +from pymongo import MongoClient +from app import app as flask_app # Assuming your Flask app is saved as app.py + +@pytest.fixture +def client(): + with flask_app.test_client() as client: + yield client + + +def test_get_nonexistent_student(client): + student_id = '999' + response = client.get(f'/students/{student_id}') + assert response.status_code == 200 + data = json.loads(response.data) + assert data is None + + +def test_update_nonexistent_student(client): + student_id = '999' + updated_student = { + "name": "Nonexistent Student", + "age": 30, + "major": "Physics" + } + response = client.put(f'/students/{student_id}', json=updated_student) + assert response.status_code == 200 + data = json.loads(response.data) + assert data["message"] == "Student updated successfully" + + diff --git a/flask-mongo/test_keploy.py b/flask-mongo/test_keploy.py new file mode 100644 index 0000000..4ee126a --- /dev/null +++ b/flask-mongo/test_keploy.py @@ -0,0 +1,8 @@ +from keploy import run, RunOptions + +def test_keploy(): + try: + options = RunOptions(delay=15, debug=False, port=0) + except ValueError as e: + print(e) + run("python3 -m coverage run -p --data-file=.coverage.keploy app.py", options) \ No newline at end of file diff --git a/flask-redis/Dockerfile b/flask-redis/Dockerfile new file mode 100644 index 0000000..9c0e897 --- /dev/null +++ b/flask-redis/Dockerfile @@ -0,0 +1,26 @@ +# Use the official Python image from the Docker Hub +FROM python:3.10-slim + +# RUN apt-get update && apt-get install -y curl +# Set the working directory in the container +WORKDIR /app + +# Copy the requirements file into the container +COPY requirements.txt . + +# Install the Python dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code into the container +COPY . . + +# Download Keploy CA certificate and setup script +# RUN curl -o ca.crt https://raw.githubusercontent.com/keploy/keploy/main/pkg/core/proxy/asset/ca.crt && \ +# curl -o setup_ca.sh https://raw.githubusercontent.com/keploy/keploy/main/pkg/core/proxy/asset/setup_ca.sh && \ +# chmod +x setup_ca.sh # Make the setup script executable + +# Expose the port the app runs on +EXPOSE 5000 + +# Define the command to run the app +CMD ["python", "app.py"] diff --git a/flask-redis/README.md b/flask-redis/README.md new file mode 100644 index 0000000..7364e9d --- /dev/null +++ b/flask-redis/README.md @@ -0,0 +1,160 @@ +# flask-redis + +A sample App using flask and redis + +## Setup application + +1. Clone the repository and move to flask-redis folder +2. Create a .env file and copy-paste below credentials: + +```bash +REDIS_HOST=redis +REDIS_PORT=6379 +``` + +# Installing Redis + +```sh +brew install redis +``` +If homebrew is not installed, then go to https://brew.sh/ and install it. + +```bash +git clone https://github.com/keploy/samples-typescript && cd samples-typescript/flask-redis + +# Install the dependencies +pip3 install -r requirements.txt +``` + +# Installing Keploy + +Let's get started by setting up the Keploy alias with this command: + +```sh +curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh +``` + +## Using Keploy : + +There are 2 ways you can run this sample application. + +1. [Natively on Linux/WSL](#natively-on-ubuntuwsl) +2. [Using Docker](#running-sample-app-using-docker) + +# Natively on Ubuntu/WSL + +## Let's install certificates + +1. **Install required packages:** + + ```sh + sudo apt-get install -y --no-install-recommends ca-certificates curl + ``` + + This command installs necessary packages without additional recommended packages. + +2. **Download CA certificate:** + + ```sh + curl -o ca.crt https://raw.githubusercontent.com/keploy/keploy/main/pkg/core/proxy/asset/ca.crt + ``` + + This command downloads the CA certificate to `ca.crt`. + +3. **Download setup script:** + + ```sh + curl -o setup_ca.sh https://raw.githubusercontent.com/keploy/keploy/main/pkg/core/proxy/asset/setup_ca.sh + ``` + + This command downloads the setup script to `setup_ca.sh`. + +4. **Make the setup script executable:** + + ```sh + chmod +x setup_ca.sh + ``` + + This command changes the permissions of `setup_ca.sh` to make it executable. + +5. **Run the setup script:** + + ```sh + source ./setup_ca.sh + ``` + + This command executes the setup script in the current shell. + +6. **Start the redis server:** + ```sh + redis-server + ``` + This command starts the redis server. + +## Capture the test cases + +1. **Start recording tests:** + ```bash + sudo -E env "PATH=$PATH" keploybin record -c 'python3 app.py' + ``` + +## Let's Generate the test cases + +Make API Calls using Hoppscotch, Postman or cURL command. Keploy will capture those calls to generate test suites containing test cases and data mocks. + +1. Refer to flask-redis/api.txt to make api calls. + +2. **Observe terminal output:** + Let's go ahead and create a few more test cases for different endpoints! + +## Running the test cases + +1. **Start the application:** + + ```bash + python3 app.py + ``` + +2. **Run the recorded tests:** + + ```bash + sudo -E env "PATH=$PATH" keploybin test -c 'python3 app.py' --delay 10 + ``` + +3. **Observe test run results:** + _Voila!! Our test cases have passed 🌟_ + +--- + +# Using Docker + +Since we have to setup our app using docker(make sure your docker is running) + +## Create a custom network for Keploy since we are using the Docker + +```bash +docker network create keploy-network +``` + +## Capture the testcases + +We will run the keploy in record mode with docker-compose to start our application:- + +```bash +keploy record -c "sudo docker-compose up" --containerName "flask-web" + +``` + +#### Let's generate the testcases. + +Make API Calls using [Hoppscotch](https://hoppscotch.io), [Postman](https://postman.com) or curl command. Keploy with capture those calls to generate the test-suites containing testcases and data mocks. + +1. Refer to flask-redis/api.txt to make api calls + +## Running the testcases + +```bash +keploy test -c 'sudo docker-compose up' --containerName "flask-web" --delay 10 +``` + +_Voila!! Our testcases has passed 🌟_ diff --git a/flask-redis/api.txt b/flask-redis/api.txt new file mode 100644 index 0000000..68b4b23 --- /dev/null +++ b/flask-redis/api.txt @@ -0,0 +1,44 @@ +--------------------------------------------------------------------------------------------------- +// Add a Book + +curl -X POST http://localhost:5000/books/ \ +-H "Content-Type: application/json" \ +-d '{"title": "1984", "author": "George Orwell"}' + +--------------------------------------------------------------------------------------------------- + +// Get All Books(with Pagination) + +curl -X GET "http://localhost:5000/books/?page=1&limit=10" + +--------------------------------------------------------------------------------------------------- + +// Get Book Details + +curl -X GET http://localhost:5000/books/1 + +--------------------------------------------------------------------------------------------------- + + +//Search Books by Title + +curl -X GET "http://localhost:5000/books/search?query=1984" + + +--------------------------------------------------------------------------------------------------- + +//Update a Book + +curl -X PUT http://localhost:5000/books/1 \ +-H "Content-Type: application/json" \ +-d '{"title": "1984 - Updated", "author": "George Orwell"}' + + +--------------------------------------------------------------------------------------------------- + +//Delete a Book + +curl -X DELETE http://localhost:5000/books/1 + +--------------------------------------------------------------------------------------------------- + diff --git a/flask-redis/app.py b/flask-redis/app.py new file mode 100644 index 0000000..bf701d1 --- /dev/null +++ b/flask-redis/app.py @@ -0,0 +1,14 @@ +from flask import Flask +from routes.book_routes import book + +app = Flask(__name__) + +# Register Blueprints +app.register_blueprint(book, url_prefix="/books") + +@app.route('/', methods=['GET']) +def hello(): + return {"message": "Welcome to the Book Management System!"}, 200 + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000, debug=True) diff --git a/flask-redis/docker-compose.yml b/flask-redis/docker-compose.yml new file mode 100644 index 0000000..99a6016 --- /dev/null +++ b/flask-redis/docker-compose.yml @@ -0,0 +1,36 @@ +version: "3.8" + +services: + web: + build: . + container_name: flask-web + restart: always + ports: + - "5000:5000" + depends_on: + - redis + environment: + - FLASK_ENV=development + - REDIS_HOST=redis + - REDIS_PORT=6379 + # volumes: + # - .:/usr/src/app + networks: + - keploy-network + + redis: + image: "redis:alpine" + container_name: redis-server + restart: always + ports: + - "6379:6379" + # volumes: + # - db_data:/var/lib/redis + networks: + - keploy-network + +networks: + keploy-network: + external: true +# volumes: +# db_data: diff --git a/flask-redis/dump.rdb b/flask-redis/dump.rdb new file mode 100644 index 0000000..601ee4a Binary files /dev/null and b/flask-redis/dump.rdb differ diff --git a/flask-redis/keploy.yml b/flask-redis/keploy.yml new file mode 100755 index 0000000..7b17386 --- /dev/null +++ b/flask-redis/keploy.yml @@ -0,0 +1,43 @@ +path: "" +appId: 0 +appName: "" +command: sudo docker-compose up +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: flask-web +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + 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: false +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. diff --git a/flask-redis/keploy/reports/test-run-0/test-set-0-report.yaml b/flask-redis/keploy/reports/test-run-0/test-set-0-report.yaml new file mode 100755 index 0000000..34f4af7 --- /dev/null +++ b/flask-redis/keploy/reports/test-run-0/test-set-0-report.yaml @@ -0,0 +1,606 @@ +version: api.keploy.io/v1beta1 +name: test-set-0-report +status: PASSED +success: 6 +failure: 0 +ignored: 0 +total: 6 +tests: + - kind: Http + name: test-set-0 + status: PASSED + started: 1722636974 + completed: 1722636974 + test_case_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0 + mock_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0/mocks + test_case_id: test-1 + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://172.18.0.4:5000/books/ + header: + Accept: '*/*' + Content-Length: "44" + Content-Type: application/json + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: '{"title": "1984", "author": "George Orwell"}' + timestamp: 2024-08-02T22:15:10.596402605Z + resp: + status_code: 201 + header: + Content-Length: "59" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:16:14 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "book_id": 1, + "message": "Book added successfully" + } + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 201 + actual: 201 + headers_result: + - normal: true + expected: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + actual: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + - normal: true + expected: + key: Content-Length + value: + - "59" + actual: + key: Content-Length + value: + - "59" + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + - normal: true + expected: + key: Date + value: + - Fri, 02 Aug 2024 22:15:10 GMT + actual: + key: Date + value: + - Fri, 02 Aug 2024 22:16:14 GMT + body_result: + - normal: true + type: JSON + expected: | + { + "book_id": 1, + "message": "Book added successfully" + } + actual: | + { + "book_id": 1, + "message": "Book added successfully" + } + dep_result: [] + - kind: Http + name: test-set-0 + status: PASSED + started: 1722636974 + completed: 1722636974 + test_case_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0 + mock_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0/mocks + test_case_id: test-2 + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://172.18.0.4:5000/books/?page=1&limit=10 + url_params: + limit: "10" + page: "1" + header: + Accept: '*/*' + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: "" + timestamp: 2024-08-02T22:15:17.339856691Z + resp: + status_code: 200 + header: + Content-Length: "88" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:16:14 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "books": [ + { + "author": "George Orwell", + "title": "1984" + } + ] + } + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 200 + actual: 200 + headers_result: + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + - normal: true + expected: + key: Date + value: + - Fri, 02 Aug 2024 22:15:17 GMT + actual: + key: Date + value: + - Fri, 02 Aug 2024 22:16:14 GMT + - normal: true + expected: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + actual: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + - normal: true + expected: + key: Content-Length + value: + - "88" + actual: + key: Content-Length + value: + - "88" + body_result: + - normal: true + type: JSON + expected: | + { + "books": [ + { + "author": "George Orwell", + "title": "1984" + } + ] + } + actual: | + { + "books": [ + { + "author": "George Orwell", + "title": "1984" + } + ] + } + dep_result: [] + - kind: Http + name: test-set-0 + status: PASSED + started: 1722636974 + completed: 1722636974 + test_case_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0 + mock_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0/mocks + test_case_id: test-3 + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://172.18.0.4:5000/books/1 + header: + Accept: '*/*' + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: "" + timestamp: 2024-08-02T22:15:24.919087736Z + resp: + status_code: 200 + header: + Content-Length: "51" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:16:14 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "author": "George Orwell", + "title": "1984" + } + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 200 + actual: 200 + headers_result: + - normal: true + expected: + key: Date + value: + - Fri, 02 Aug 2024 22:15:24 GMT + actual: + key: Date + value: + - Fri, 02 Aug 2024 22:16:14 GMT + - normal: true + expected: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + actual: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + - normal: true + expected: + key: Content-Length + value: + - "51" + actual: + key: Content-Length + value: + - "51" + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + body_result: + - normal: true + type: JSON + expected: | + { + "author": "George Orwell", + "title": "1984" + } + actual: | + { + "author": "George Orwell", + "title": "1984" + } + dep_result: [] + - kind: Http + name: test-set-0 + status: PASSED + started: 1722636974 + completed: 1722636974 + test_case_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0 + mock_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0/mocks + test_case_id: test-4 + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://172.18.0.4:5000/books/search?query=1984 + url_params: + query: "1984" + header: + Accept: '*/*' + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: "" + timestamp: 2024-08-02T22:15:32.960447823Z + resp: + status_code: 200 + header: + Content-Length: "90" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:16:14 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "results": [ + { + "author": "George Orwell", + "title": "1984" + } + ] + } + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 200 + actual: 200 + headers_result: + - normal: true + expected: + key: Content-Length + value: + - "90" + actual: + key: Content-Length + value: + - "90" + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + - normal: true + expected: + key: Date + value: + - Fri, 02 Aug 2024 22:15:32 GMT + actual: + key: Date + value: + - Fri, 02 Aug 2024 22:16:14 GMT + - normal: true + expected: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + actual: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + body_result: + - normal: true + type: JSON + expected: | + { + "results": [ + { + "author": "George Orwell", + "title": "1984" + } + ] + } + actual: | + { + "results": [ + { + "author": "George Orwell", + "title": "1984" + } + ] + } + dep_result: [] + - kind: Http + name: test-set-0 + status: PASSED + started: 1722636974 + completed: 1722636974 + test_case_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0 + mock_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0/mocks + test_case_id: test-5 + req: + method: PUT + proto_major: 1 + proto_minor: 1 + url: http://172.18.0.4:5000/books/1 + header: + Accept: '*/*' + Content-Length: "54" + Content-Type: application/json + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: '{"title": "1984 - Updated", "author": "George Orwell"}' + timestamp: 2024-08-02T22:15:39.802018618Z + resp: + status_code: 200 + header: + Content-Length: "123" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:16:14 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "book": { + "author": "George Orwell", + "title": "1984 - Updated" + }, + "message": "Book updated successfully" + } + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 200 + actual: 200 + headers_result: + - normal: true + expected: + key: Date + value: + - Fri, 02 Aug 2024 22:15:39 GMT + actual: + key: Date + value: + - Fri, 02 Aug 2024 22:16:14 GMT + - normal: true + expected: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + actual: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + - normal: true + expected: + key: Content-Length + value: + - "123" + actual: + key: Content-Length + value: + - "123" + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + body_result: + - normal: true + type: JSON + expected: | + { + "book": { + "author": "George Orwell", + "title": "1984 - Updated" + }, + "message": "Book updated successfully" + } + actual: | + { + "book": { + "author": "George Orwell", + "title": "1984 - Updated" + }, + "message": "Book updated successfully" + } + dep_result: [] + - kind: Http + name: test-set-0 + status: PASSED + started: 1722636974 + completed: 1722636974 + test_case_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0 + mock_path: /Users/amanrai/Desktop/flask-redis/keploy/test-set-0/mocks + test_case_id: test-6 + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://172.18.0.4:5000/books/1 + header: + Accept: '*/*' + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: "" + timestamp: 2024-08-02T22:15:47.228393997Z + resp: + status_code: 200 + header: + Content-Length: "45" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:16:14 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "message": "Book deleted successfully" + } + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 200 + actual: 200 + headers_result: + - normal: true + expected: + key: Content-Length + value: + - "45" + actual: + key: Content-Length + value: + - "45" + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + - normal: true + expected: + key: Date + value: + - Fri, 02 Aug 2024 22:15:47 GMT + actual: + key: Date + value: + - Fri, 02 Aug 2024 22:16:14 GMT + - normal: true + expected: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + actual: + key: Server + value: + - Werkzeug/3.0.3 Python/3.10.14 + body_result: + - normal: true + type: JSON + expected: | + { + "message": "Book deleted successfully" + } + actual: | + { + "message": "Book deleted successfully" + } + dep_result: [] +test_set: test-set-0 diff --git a/flask-redis/keploy/test-set-0/mocks.yaml b/flask-redis/keploy/test-set-0/mocks.yaml new file mode 100755 index 0000000..1e3ba8b --- /dev/null +++ b/flask-redis/keploy/test-set-0/mocks.yaml @@ -0,0 +1,417 @@ +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-0 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*4\r\n$6\r\nCLIENT\r\n$7\r\nSETINFO\r\n$8\r\nLIB-NAME\r\n$8\r\nredis-py\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-08-02T22:15:10.6084523Z + restimestampmock: 2024-08-02T22:15:10.608930466Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-1 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*4\r\n$6\r\nCLIENT\r\n$7\r\nSETINFO\r\n$7\r\nLIB-VER\r\n$5\r\n5.0.8\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-08-02T22:15:10.610066633Z + restimestampmock: 2024-08-02T22:15:10.610752633Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-2 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*3\r\n$6\r\nINCRBY\r\n$7\r\nbook_id\r\n$1\r\n1\r\n" + redisresponses: + - origin: server + message: + - type: string + data: ":1\r\n" + reqtimestampmock: 2024-08-02T22:15:10.611978716Z + restimestampmock: 2024-08-02T22:15:10.612786841Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-3 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*6\r\n$4\r\nHSET\r\n$6\r\nbook:1\r\n$5\r\ntitle\r\n$4\r\n1984\r\n$6\r\nauthor\r\n$13\r\nGeorge Orwell\r\n" + redisresponses: + - origin: server + message: + - type: string + data: ":2\r\n" + reqtimestampmock: 2024-08-02T22:15:10.613938591Z + restimestampmock: 2024-08-02T22:15:10.614915925Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-4 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$3\r\nGET\r\n$18\r\nbooks_cache:page_1\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "$-1\r\n" + reqtimestampmock: 2024-08-02T22:15:17.343482553Z + restimestampmock: 2024-08-02T22:15:17.344991261Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-5 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$4\r\nKEYS\r\n$6\r\nbook:*\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "*1\r\n$6\r\nbook:1\r\n" + reqtimestampmock: 2024-08-02T22:15:17.345461178Z + restimestampmock: 2024-08-02T22:15:17.346119386Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-6 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$7\r\nHGETALL\r\n$6\r\nbook:1\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "*4\r\n$5\r\ntitle\r\n$4\r\n1984\r\n$6\r\nauthor\r\n$13\r\nGeorge Orwell\r\n" + reqtimestampmock: 2024-08-02T22:15:17.346484636Z + restimestampmock: 2024-08-02T22:15:17.346881469Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-7 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*4\r\n$5\r\nSETEX\r\n$18\r\nbooks_cache:page_1\r\n$3\r\n300\r\n$46\r\n[{\"title\": \"1984\", \"author\": \"George Orwell\"}]\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-08-02T22:15:17.347539428Z + restimestampmock: 2024-08-02T22:15:17.348107886Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-8 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$7\r\nHGETALL\r\n$6\r\nbook:1\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "*4\r\n$5\r\ntitle\r\n$4\r\n1984\r\n$6\r\nauthor\r\n$13\r\nGeorge Orwell\r\n" + reqtimestampmock: 2024-08-02T22:15:24.91868625Z + restimestampmock: 2024-08-02T22:15:24.918989625Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-9 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$3\r\nGET\r\n$17\r\nsearch:books:1984\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "$-1\r\n" + reqtimestampmock: 2024-08-02T22:15:32.959388379Z + restimestampmock: 2024-08-02T22:15:32.959604088Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-10 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$4\r\nKEYS\r\n$6\r\nbook:*\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "*1\r\n$6\r\nbook:1\r\n" + reqtimestampmock: 2024-08-02T22:15:32.959842713Z + restimestampmock: 2024-08-02T22:15:32.959998921Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-11 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$7\r\nHGETALL\r\n$6\r\nbook:1\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "*4\r\n$5\r\ntitle\r\n$4\r\n1984\r\n$6\r\nauthor\r\n$13\r\nGeorge Orwell\r\n" + reqtimestampmock: 2024-08-02T22:15:32.960231671Z + restimestampmock: 2024-08-02T22:15:32.960389213Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-12 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*4\r\n$5\r\nSETEX\r\n$17\r\nsearch:books:1984\r\n$3\r\n300\r\n$46\r\n[{\"title\": \"1984\", \"author\": \"George Orwell\"}]\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-08-02T22:15:32.960706004Z + restimestampmock: 2024-08-02T22:15:32.960838838Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-13 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$6\r\nEXISTS\r\n$6\r\nbook:1\r\n" + redisresponses: + - origin: server + message: + - type: string + data: ":1\r\n" + reqtimestampmock: 2024-08-02T22:15:39.801969841Z + restimestampmock: 2024-08-02T22:15:39.802299174Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-14 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*4\r\n$4\r\nHSET\r\n$6\r\nbook:1\r\n$5\r\ntitle\r\n$14\r\n1984 - Updated\r\n" + redisresponses: + - origin: server + message: + - type: string + data: ":0\r\n" + reqtimestampmock: 2024-08-02T22:15:39.802669008Z + restimestampmock: 2024-08-02T22:15:39.803126174Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-15 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*4\r\n$4\r\nHSET\r\n$6\r\nbook:1\r\n$6\r\nauthor\r\n$13\r\nGeorge Orwell\r\n" + redisresponses: + - origin: server + message: + - type: string + data: ":0\r\n" + reqtimestampmock: 2024-08-02T22:15:39.803492508Z + restimestampmock: 2024-08-02T22:15:39.803768216Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-16 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*3\r\n$4\r\nHGET\r\n$6\r\nbook:1\r\n$5\r\ntitle\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "$14\r\n1984 - Updated\r\n" + reqtimestampmock: 2024-08-02T22:15:39.804229258Z + restimestampmock: 2024-08-02T22:15:39.804523466Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-17 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*3\r\n$4\r\nHGET\r\n$6\r\nbook:1\r\n$6\r\nauthor\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "$13\r\nGeorge Orwell\r\n" + reqtimestampmock: 2024-08-02T22:15:39.805022091Z + restimestampmock: 2024-08-02T22:15:39.805174924Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-18 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*6\r\n$5\r\nHMSET\r\n$6\r\nbook:1\r\n$5\r\ntitle\r\n$14\r\n1984 - Updated\r\n$6\r\nauthor\r\n$13\r\nGeorge Orwell\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-08-02T22:15:39.806458299Z + restimestampmock: 2024-08-02T22:15:39.807372758Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-19 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$6\r\nEXISTS\r\n$6\r\nbook:1\r\n" + redisresponses: + - origin: server + message: + - type: string + data: ":1\r\n" + reqtimestampmock: 2024-08-02T22:15:47.227235428Z + restimestampmock: 2024-08-02T22:15:47.227446803Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-20 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$3\r\nDEL\r\n$6\r\nbook:1\r\n" + redisresponses: + - origin: server + message: + - type: string + data: ":1\r\n" + reqtimestampmock: 2024-08-02T22:15:47.227812303Z + restimestampmock: 2024-08-02T22:15:47.228129511Z +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-21 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$3\r\nDEL\r\n$18\r\nbooks_cache:page_*\r\n" + redisresponses: + - origin: server + message: + - type: string + data: ":0\r\n" + reqtimestampmock: 2024-08-02T22:15:47.228357053Z + restimestampmock: 2024-08-02T22:15:47.228491803Z diff --git a/flask-redis/keploy/test-set-0/tests/test-1.yaml b/flask-redis/keploy/test-set-0/tests/test-1.yaml new file mode 100755 index 0000000..ddc1544 --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-1.yaml @@ -0,0 +1,47 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/books/ + header: + Accept: '*/*' + Content-Length: "44" + Content-Type: application/json + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: '{"title": "1984", "author": "George Orwell"}' + timestamp: 2024-08-02T22:15:10.596402605Z + resp: + status_code: 201 + header: + Content-Length: "59" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:15:10 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "book_id": 1, + "message": "Book added successfully" + } + status_message: Created + proto_major: 0 + proto_minor: 0 + timestamp: 2024-08-02T22:15:12.681157884Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1722636912 +curl: |- + curl --request POST \ + --url http://localhost:5000/books/ \ + --header 'Accept: */*' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:5000' \ + --header 'User-Agent: curl/8.6.0' \ + --data '{"title": "1984", "author": "George Orwell"}' diff --git a/flask-redis/keploy/test-set-0/tests/test-2.yaml b/flask-redis/keploy/test-set-0/tests/test-2.yaml new file mode 100755 index 0000000..85115b2 --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-2.yaml @@ -0,0 +1,50 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-2 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/books/?page=1&limit=10 + url_params: + limit: "10" + page: "1" + header: + Accept: '*/*' + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: "" + timestamp: 2024-08-02T22:15:17.339856691Z + resp: + status_code: 200 + header: + Content-Length: "88" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:15:17 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "books": [ + { + "author": "George Orwell", + "title": "1984" + } + ] + } + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-08-02T22:15:19.428364137Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1722636919 +curl: | + curl --request GET \ + --url http://localhost:5000/books/?page=1&limit=10 \ + --header 'Host: localhost:5000' \ + --header 'User-Agent: curl/8.6.0' \ + --header 'Accept: */*' \ diff --git a/flask-redis/keploy/test-set-0/tests/test-3.yaml b/flask-redis/keploy/test-set-0/tests/test-3.yaml new file mode 100755 index 0000000..316a90d --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-3.yaml @@ -0,0 +1,43 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-3 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/books/1 + header: + Accept: '*/*' + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: "" + timestamp: 2024-08-02T22:15:24.919087736Z + resp: + status_code: 200 + header: + Content-Length: "51" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:15:24 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "author": "George Orwell", + "title": "1984" + } + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-08-02T22:15:26.965315001Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1722636926 +curl: | + curl --request GET \ + --url http://localhost:5000/books/1 \ + --header 'Accept: */*' \ + --header 'Host: localhost:5000' \ + --header 'User-Agent: curl/8.6.0' \ diff --git a/flask-redis/keploy/test-set-0/tests/test-4.yaml b/flask-redis/keploy/test-set-0/tests/test-4.yaml new file mode 100755 index 0000000..e659f2f --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-4.yaml @@ -0,0 +1,49 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-4 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/books/search?query=1984 + url_params: + query: "1984" + header: + Accept: '*/*' + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: "" + timestamp: 2024-08-02T22:15:32.960447823Z + resp: + status_code: 200 + header: + Content-Length: "90" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:15:32 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "results": [ + { + "author": "George Orwell", + "title": "1984" + } + ] + } + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-08-02T22:15:34.98447863Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1722636934 +curl: | + curl --request GET \ + --url http://localhost:5000/books/search?query=1984 \ + --header 'Host: localhost:5000' \ + --header 'User-Agent: curl/8.6.0' \ + --header 'Accept: */*' \ diff --git a/flask-redis/keploy/test-set-0/tests/test-5.yaml b/flask-redis/keploy/test-set-0/tests/test-5.yaml new file mode 100755 index 0000000..7f38a10 --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-5.yaml @@ -0,0 +1,50 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-5 +spec: + metadata: {} + req: + method: PUT + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/books/1 + header: + Accept: '*/*' + Content-Length: "54" + Content-Type: application/json + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: '{"title": "1984 - Updated", "author": "George Orwell"}' + timestamp: 2024-08-02T22:15:39.802018618Z + resp: + status_code: 200 + header: + Content-Length: "123" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:15:39 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "book": { + "author": "George Orwell", + "title": "1984 - Updated" + }, + "message": "Book updated successfully" + } + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-08-02T22:15:41.813988842Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1722636941 +curl: |- + curl --request PUT \ + --url http://localhost:5000/books/1 \ + --header 'Host: localhost:5000' \ + --header 'User-Agent: curl/8.6.0' \ + --header 'Accept: */*' \ + --header 'Content-Type: application/json' \ + --data '{"title": "1984 - Updated", "author": "George Orwell"}' diff --git a/flask-redis/keploy/test-set-0/tests/test-6.yaml b/flask-redis/keploy/test-set-0/tests/test-6.yaml new file mode 100755 index 0000000..228ce8e --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-6.yaml @@ -0,0 +1,42 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-6 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/books/1 + header: + Accept: '*/*' + Host: localhost:5000 + User-Agent: curl/8.6.0 + body: "" + timestamp: 2024-08-02T22:15:47.228393997Z + resp: + status_code: 200 + header: + Content-Length: "45" + Content-Type: application/json + Date: Fri, 02 Aug 2024 22:15:47 GMT + Server: Werkzeug/3.0.3 Python/3.10.14 + body: | + { + "message": "Book deleted successfully" + } + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-08-02T22:15:49.269456095Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1722636949 +curl: | + curl --request DELETE \ + --url http://localhost:5000/books/1 \ + --header 'Accept: */*' \ + --header 'Host: localhost:5000' \ + --header 'User-Agent: curl/8.6.0' \ diff --git a/flask-redis/redisClient.py b/flask-redis/redisClient.py new file mode 100644 index 0000000..dc01e64 --- /dev/null +++ b/flask-redis/redisClient.py @@ -0,0 +1,12 @@ +import redis +import os + +# Connect to Redis server +client = redis.Redis( + host=os.getenv('REDIS_HOST', 'localhost'), + port=int(os.getenv('REDIS_PORT', 6379)), + db=0 +) + +def get_redis_client(): + return client diff --git a/flask-redis/requirements.txt b/flask-redis/requirements.txt new file mode 100644 index 0000000..bdb539d --- /dev/null +++ b/flask-redis/requirements.txt @@ -0,0 +1,3 @@ +Flask +redis +python-dotenv \ No newline at end of file diff --git a/flask-redis/routes/book_routes.py b/flask-redis/routes/book_routes.py new file mode 100644 index 0000000..6d58543 --- /dev/null +++ b/flask-redis/routes/book_routes.py @@ -0,0 +1,133 @@ +from flask import Blueprint, request, jsonify +from redisClient import get_redis_client +import json + +book = Blueprint('book', __name__) +redis_client = get_redis_client() + +@book.route('/', methods=['POST']) +def add_book(): + data = request.get_json() + title = data.get('title') + author = data.get('author') + + if not title or not author: + return jsonify({"error": "Title and author are required"}), 400 + + book_id = redis_client.incr('book_id') # Auto-increment ID for new book + redis_client.hset(f'book:{book_id}', mapping={"title": title, "author": author}) + + return jsonify({"message": "Book added successfully", "book_id": book_id}), 201 + + +@book.route('/', methods=['GET']) +def get_books(): + page = int(request.args.get('page', 1)) + limit = int(request.args.get('limit', 10)) + start = (page - 1) * limit + end = start + limit - 1 + + # Define your cache key here + cache_key = f'books_cache:page_{page}' + + # Check if the result is already in cache + cached_books = redis_client.get(cache_key) + if cached_books: + return jsonify(json.loads(cached_books)), 200 + + # If not cached, fetch from Redis + keys = redis_client.keys('book:*') + books = [ + {k.decode('utf-8'): v.decode('utf-8') for k, v in redis_client.hgetall(key).items()} + for key in keys + ] + redis_client.setex(cache_key, 300, json.dumps(books)) + + return jsonify({"books": books}), 200 + + +@book.route('/', methods=['GET']) +def get_book(book_id): + # Create a cache key based on the book ID + cache_key = f'book:{book_id}' + + # Check if the key exists in the cache + cached_book = redis_client.hgetall(cache_key) # Use hgetall for hash + + if cached_book: + # Decode the keys and values from bytes to strings + decoded_book = {key.decode('utf-8'): value.decode('utf-8') for key, value in cached_book.items()} + return jsonify(decoded_book), 200 + else: + return jsonify({"message": "Book not found"}), 404 + + +@book.route('/', methods=['PUT']) +def update_book(book_id): + data = request.get_json() + title = data.get('title') + author = data.get('author') + + if not redis_client.exists(f'book:{book_id}'): + return jsonify({"error": "Book not found"}), 404 + + if title: + redis_client.hset(f'book:{book_id}', "title", title) + if author: + redis_client.hset(f'book:{book_id}', "author", author) + + # Retrieve the updated book data + updated_book = { + "title": redis_client.hget(f'book:{book_id}', "title").decode('utf-8'), + "author": redis_client.hget(f'book:{book_id}', "author").decode('utf-8') + } + + # Update the cache with the latest data + redis_client.hmset(f'book:{book_id}', updated_book) + + return jsonify({"message": "Book updated successfully", "book": updated_book}), 200 + + + +@book.route('/', methods=['DELETE']) +def delete_book(book_id): + # Check if the book exists + if not redis_client.exists(f'book:{book_id}'): + return jsonify({"message": "Book not found"}), 404 + + # Delete the book + redis_client.delete(f'book:{book_id}') + + # Invalidate related caches + redis_client.delete(f'books_cache:page_*') # Adjust this if you cache other items + + return jsonify({"message": "Book deleted successfully"}), 200 + +@book.route('/search', methods=['GET']) +def search_books(): + query = request.args.get('query', '') + + if not query: + return jsonify({"error": "Search query is required"}), 400 + + cache_key = f'search:books:{query}' + cached_results = redis_client.get(cache_key) + + if cached_results: + return jsonify(json.loads(cached_results)), 200 + + all_books = redis_client.keys(f'book:*') + search_results = [] + + for book_key in all_books: + book_data = redis_client.hgetall(book_key) + title = book_data[b'title'].decode('utf-8') + author = book_data[b'author'].decode('utf-8') + if query.lower() in title.lower(): + search_results.append({"title": title, "author": author}) + + # Store search results in cache + redis_client.setex(cache_key, 300, json.dumps(search_results)) # Cache for 5 minutes + + return jsonify({"results": search_results}), 200 + diff --git a/flask_mysql/Dockerfile b/flask_mysql/Dockerfile new file mode 100644 index 0000000..4cf7653 --- /dev/null +++ b/flask_mysql/Dockerfile @@ -0,0 +1,39 @@ +# Use an official Python runtime as a parent image +FROM python:3.11-slim + +# Set the working directory inside the container +WORKDIR /app + +# ---- START NEW ---- +# Explicitly create the directory for sockets to ensure it exists +# with the correct permissions before the volume is mounted over it. +RUN mkdir -p /keploy-sockets && chmod 777 /keploy-sockets +# ---- END NEW ---- + + +# Copy the current directory contents into the container at /app +COPY . /app + +RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir gunicorn + +# Create the keploy directory and download the time freeze agent +RUN mkdir -p /lib/keploy +ADD https://keploy-enterprise.s3.us-west-2.amazonaws.com/releases/latest/assets/freeze_time_amd64.so /lib/keploy/freeze_time_amd64.so +RUN chmod +x /lib/keploy/freeze_time_amd64.so +RUN ls -la /lib/keploy/freeze_time_amd64.so + +# Set LD_PRELOAD environment variable +ENV LD_PRELOAD=/lib/keploy/freeze_time_amd64.so +ENV FLASK_ENV=production + +# Expose port 5000 for Flask +EXPOSE 5000 + +# ---- START NEW HEALTHCHECK ---- +# Add a healthcheck to ensure the app is running before considering it "up" +HEALTHCHECK --interval=5s --timeout=3s --start-period=10s --retries=3 \ + CMD curl -f http://localhost:5000/ || exit 1 +# ---- END NEW HEALTHCHECK ---- + +CMD ["python", "main.py"] \ No newline at end of file diff --git a/flask_mysql/README.md b/flask_mysql/README.md new file mode 100644 index 0000000..def3a9f --- /dev/null +++ b/flask_mysql/README.md @@ -0,0 +1,347 @@ +# Flask-MySQL Sample Application + +This application is a comprehensive financial management API built using Python's Flask framework and MySQL for data storage. It provides various endpoints for handling clients, accounts, transactions, and generating financial reports, all secured with JWT authentication. + +# Introduction + +🪄 Dive into the world of Financial APIs and see how seamlessly Keploy integrated with [Flask](https://flask.palletsprojects.com/en/3.0.x/) and [MySQL](https://www.mysql.com/). Buckle up, it's gonna be a fun ride! 🎢 + +## Pre-Requisite 🛠️ + +- Install WSL (`wsl --install`) for Windows Windows. + +#### Optional 🛠️ + +- Install Colima( `brew install colima && colima start` ) for MacOS MacOs. + +## Install Keploy + +- Install Keploy CLI using the following command: + +```bash +curl -O -L https://keploy.io/install.sh && source install.sh +``` + +## Get Started! 🎬 + +## Setup the MySQL Database 📦 + +First, create the docker network that Keploy and our application will use to communicate: + +```bash +docker network create keploy-network +``` + +Next, start the MySQL instance using the provided `docker-compose.yml` file: + +```bash +docker-compose up -d db +``` + +## Installation 📥 + +### With Docker 🎥 + +Build the application's Docker image: + +```sh +docker build -t flask-mysql-app:1.0 . +``` + +Capture the test cases and mocks: + +```shell +keploy record -c "docker run -p 5000:5000 --name flask-mysql-app --network keploy-network -e DB_HOST=db flask-mysql-app:1.0" --containerName flask-mysql-app +``` + +🔥**Make some API calls**. Postman, Hoppscotch or even curl - take your pick! + +### Generate testcases + +To generate test cases, we just need to **make some API calls.** + +**1. Log in to get a JWT token** + +First, we need to authenticate to get an access token. The default credentials are `admin` / `admin123`. + +```bash +curl -X POST -H "Content-Type: application/json" -d '{"username": "admin", "password": "admin123"}' http://localhost:5000/login +``` + +This will return a token. Copy the `access_token` value and export it as an environment variable to make the next steps easier. + +```bash +export JWT_TOKEN= +``` + +**2. Check application health** + +This endpoint doesn't require authentication. + +```bash +curl -X GET http://localhost:5000/health +``` + +**3. Create a new data payload** + +```bash +curl -X POST \ + http://localhost:5000/data \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $JWT_TOKEN" \ + -d '{"message": "First data log"}' +``` + +**4. Get all data payloads** + +```bash +curl -X GET \ + http://localhost:5000/data \ + -H "Authorization: Bearer $JWT_TOKEN" +``` + +**5. Generate complex queries** + +```bash +curl -X GET \ + http://localhost:5000/generate-complex-queries \ + -H "Authorization: Bearer $JWT_TOKEN" +``` + +**6. Get system status** + +```bash +curl -X GET \ + http://localhost:5000/system/status \ + -H "Authorization: Bearer $JWT_TOKEN" +``` + +**7. Get database migrations** + +```bash +curl -X GET \ + http://localhost:5000/system/migrations \ + -H "Authorization: Bearer $JWT_TOKEN" +``` + +**8. Check a blacklisted token** + +This uses a sample JTI (`9522d59c56404995af98d4c30bde72b3`) that is seeded into the database by the startup script. + +```bash +curl -X GET \ + http://localhost:5000/auth/check-token/9522d59c56404995af98d4c30bde72b3 \ + -H "Authorization: Bearer $JWT_TOKEN" +``` + +**9. Create an API log entry** + +```bash +curl -X POST \ + http://localhost:5000/logs \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $JWT_TOKEN" \ + -d '{"event": "user_action", "details": "testing log endpoint"}' +``` + +**10. Generate a client summary report** + +```bash +curl -X GET \ + http://localhost:5000/reports/client-summary \ + -H "Authorization: Bearer $JWT_TOKEN" +``` + +**11. Get a full financial summary report** + +```bash +curl -X GET \ + http://localhost:5000/reports/full-financial-summary \ + -H "Authorization: Bearer $JWT_TOKEN" +``` + +**12. Search for a client** + +Search by client name: +```bash +curl -X GET \ + "http://localhost:5000/search/clients?q=Global" \ + -H "Authorization: Bearer $JWT_TOKEN" +``` +Search by account number: +```bash +curl -X GET \ + "http://localhost:5000/search/clients?q=F12345" \ + -H "Authorization: Bearer $JWT_TOKEN" +``` + +**13. Perform a fund transfer** + +This transfers `100.00` from account `1` to account `2`, which are created by the startup script. +```bash +curl -X POST \ + http://localhost:5000/transactions/transfer \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $JWT_TOKEN" \ + -d '{"from_account_id": 1, "to_account_id": 2, "amount": "100.00"}' +``` + +Give yourself a pat on the back! With those simple spells, you've conjured up a test case with a mock for each endpoint! Explore the **Keploy directory** and you'll discover your handiwork in your `test-*.yml` and `mocks.yml` files. + +A generated test case for the POST request will look like this: + +```yaml +version: api.keploy.io/v1beta2 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: /data + header: + Accept: "*/*" + Authorization: Bearer + Content-Length: "29" + Content-Type: application/json + Host: localhost:5000 + User-Agent: curl/7.81.0 + body: '{"message": "First data log"}' + body_type: "" + timestamp: 2023-12-01T10:00:00Z + resp: + status_code: 201 + header: + Content-Length: "20" + Content-Type: application/json + body: | + {"status":"created"} + body_type: "" + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 2023-12-01T10:00:01Z + objects: [] + assertions: + noise: + - header.Date + created: 1701424801 +curl: |- + curl --request POST \ + --url http://localhost:5000/data \ + --header 'Host: localhost:5000' \ + --header 'User-Agent: curl/7.81.0' \ + --header 'Authorization: Bearer ' \ + --header 'Accept: */*' \ + --header 'Content-Type: application/json' \ + --data '{"message": "First data log"}' +``` + +This is how the captured MySQL dependency in `mocks.yml` would look: + +```yaml +version: api.keploy.io/v1beta2 +kind: MySql +name: mocks +spec: + metadata: + name: payloads + type: TABLE + operation: query + requests: + - header: + header: + payload_length: 39 + sequence_id: 1 + packet_type: COM_QUERY + message: + query: "INSERT INTO payloads (data) VALUES ('First data log')" + responses: + - header: + header: + payload_length: 9 + sequence_id: 2 + packet_type: OK + message: + header: 0 + affected_rows: 1 + last_insert_id: 5 + created: 1701424801 +``` + +Want to see if everything works as expected? + +#### Run Tests + +Time to put things to the test 🧪 + +```shell +keploy test -c "docker run -p 5000:5000 --name flask-mysql-app --network keploy-network -e DB_HOST=db flask-mysql-app:1.0" --delay 10 --containerName flask-mysql-app +``` + +> The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking. + +--- + +### Running In Linux/WSL + +We'll be running our sample application right on Linux, but we'll keep the MySQL database running in Docker as set up earlier. Ready? Let's get the party started!🎉 + +#### 📼 Roll the Tape - Recording Time! + +First, install the Python dependencies: + +```bash +pip install -r requirements.txt +``` + +Before running, ensure the `DB_HOST` environment variable points to your Docker database instance, which is exposed on `127.0.0.1`. + +```bash +export DB_HOST=127.0.0.1 +``` + +Ready, set, record! Here's how: + +```bash +keploy record -c "python3 main.py" +``` + +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 the same API calls as before! + +#### Generate testcases + +**1. Log in to get a JWT token** + +```bash +curl -X POST -H "Content-Type: application/json" -d '{"username": "admin", "password": "admin123"}' http://localhost:5000/login +# Export the token +export JWT_TOKEN= +``` + +**2. Make API calls** + +Use the `curl` commands from the "With Docker" section above to generate tests for all the other endpoints. + +After making a few calls, you will see test cases and mocks being generated in your project directory. + +#### Run Tests + +Time to put things to the test 🧪 + +```shell +keploy test -c "python3 main.py" --delay 10 +``` + +Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the `mocks.yml`, or fiddle with the request or response in `test-x.yml`. Run the tests again and see the magic unfold!✨👩‍💻👨‍💻✨ + +## 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! ✨👩‍💻👨‍💻✨ +``` \ No newline at end of file diff --git a/flask_mysql/docker-compose.yml b/flask_mysql/docker-compose.yml new file mode 100644 index 0000000..e29f651 --- /dev/null +++ b/flask_mysql/docker-compose.yml @@ -0,0 +1,23 @@ +services: + db: + image: mysql:8.4 + container_name: simple-demo-db + environment: + MYSQL_ROOT_PASSWORD: rootpass + MYSQL_DATABASE: demo + MYSQL_USER: demo + MYSQL_PASSWORD: demopass + + networks: + - keploy-network + ports: # expose to host → 127.0.0.1:3306 + - "3306:3306" + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-pdemopass"] + interval: 5s + retries: 10 + +networks: + keploy-network: + external: true + driver: bridge diff --git a/flask_mysql/main.py b/flask_mysql/main.py new file mode 100644 index 0000000..c449729 --- /dev/null +++ b/flask_mysql/main.py @@ -0,0 +1,341 @@ +import os +from flask import Flask, jsonify, request +from flask.json.provider import JSONProvider +from flask_jwt_extended import JWTManager, create_access_token, jwt_required +from werkzeug.security import generate_password_hash, check_password_hash +import datetime +import json +import mysql.connector +import sys +import decimal +import time + +# --- Custom JSON Provider to Handle Datetime and Decimal --- +class CustomJSONProvider(JSONProvider): + def dumps(self, obj, **kwargs): + return json.dumps(obj, **kwargs, default=self.default) + def loads(self, s, **kwargs): + return json.loads(s, **kwargs) + @staticmethod + def default(o): + if isinstance(o, (datetime.datetime, datetime.date)): + return o.isoformat() + if isinstance(o, decimal.Decimal): + return str(o) + raise TypeError(f"Object of type {type(o).__name__} is not JSON serializable") + +app = Flask(__name__) +app.json = CustomJSONProvider(app) + +# --- App Configuration --- +app.config["JWT_SECRET_KEY"] = "super-secret-key-for-testing" +jwt = JWTManager(app) + +# --- User Authentication --- +users = {"admin": {"username": "admin", "password": generate_password_hash("admin123")}} + +@app.route("/login", methods=["POST"]) +def login(): + username = request.json.get("username", None) + password = request.json.get("password", None) + if not (user := users.get(username)) or not check_password_hash(user["password"], password): + return jsonify({"msg": "Bad username or password"}), 401 + return jsonify(access_token=create_access_token(identity=username)) + +# --- Database Configuration & Connection --- +DB_CFG = dict( + host=os.getenv("DB_HOST", "127.0.0.1"), + port=int(os.getenv("DB_PORT", 3306)), + user=os.getenv("DB_USER", "demo"), + password=os.getenv("DB_PASSWORD", "demopass"), + database=os.getenv("DB_NAME", "demo"), +) + +def get_db_connection(): + try: + return mysql.connector.connect(**DB_CFG) + except mysql.connector.Error as err: + print(f"FATAL: Could not connect to database: {err}", file=sys.stderr) + return None + +def setup_database(): + """Creates/resets and populates the database tables on startup.""" + print("Connecting to database to run setup...") + conn = get_db_connection() + if not conn: sys.exit(1) + + try: + print("Setting up tables...") + cur = conn.cursor() + + # Disable FK checks and drop tables + cur.execute("SET foreign_key_checks = 0;") + cur.execute("DROP TABLE IF EXISTS transactions, api_logs, accounts, token_blacklist_blacklistedtoken, token_blacklist_outstandingtoken, django_migrations, permissions, clients, payloads, programs;") + cur.execute("SET foreign_key_checks = 1;") + + # Rest of your setup code... + conn.commit() + + except mysql.connector.Error as err: + print(f"Database setup failed: {err}") + conn.rollback() + sys.exit(1) + finally: + if conn.is_connected(): + cur.close() + conn.close() + print("Database setup complete.") + """Creates/resets and populates the database tables on startup.""" + print("Connecting to database to run setup...") + conn = get_db_connection() + if not conn: sys.exit(1) + + try: + print("Setting up tables...") + cur = conn.cursor() + + # Disable FK checks and drop tables + cur.execute("SET foreign_key_checks = 0;") + cur.execute("DROP TABLE IF EXISTS transactions, api_logs, accounts, token_blacklist_blacklistedtoken, token_blacklist_outstandingtoken, django_migrations, permissions, clients, payloads, programs;") + cur.execute("SET foreign_key_checks = 1;") + + # Rest of your setup code... + conn.commit() + + except mysql.connector.Error as err: + print(f"Database setup failed: {err}") + conn.rollback() + sys.exit(1) + finally: + if conn.is_connected(): + cur.close() + conn.close() + print("Database setup complete.") + """Creates/resets and populates the database tables on startup.""" + print("Connecting to database to run setup...") + conn = get_db_connection() + if not conn: sys.exit(1) + + print("Setting up tables...") + cur = conn.cursor() + + cur.execute("SET foreign_key_checks = 0;") + cur.execute("DROP TABLE IF EXISTS transactions, api_logs, accounts, token_blacklist_blacklistedtoken, token_blacklist_outstandingtoken, django_migrations, permissions, clients, payloads, programs;") + cur.execute("SET foreign_key_checks = 1;") + + # Create tables + cur.execute("CREATE TABLE programs (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100));") + cur.execute("CREATE TABLE clients (id BIGINT PRIMARY KEY AUTO_INCREMENT, display_name VARCHAR(255) NOT NULL, client_status VARCHAR(50), program_id INT NULL, FOREIGN KEY (program_id) REFERENCES programs(id));") + cur.execute("CREATE TABLE accounts (id BIGINT PRIMARY KEY AUTO_INCREMENT, client_id BIGINT, account_no_dataphile VARCHAR(100) NULL, market_value DECIMAL(20, 2), FOREIGN KEY (client_id) REFERENCES clients(id) ON DELETE CASCADE);") + cur.execute("CREATE TABLE transactions (id BIGINT PRIMARY KEY AUTO_INCREMENT, from_account_id BIGINT, to_account_id BIGINT, amount DECIMAL(20, 2), transaction_time TIMESTAMP, FOREIGN KEY (from_account_id) REFERENCES accounts(id), FOREIGN KEY (to_account_id) REFERENCES accounts(id));") + cur.execute("CREATE TABLE permissions (id BIGINT PRIMARY KEY AUTO_INCREMENT, role_name VARCHAR(100), resource_name VARCHAR(100), can_read BOOLEAN);") + cur.execute("CREATE TABLE payloads (id BIGINT PRIMARY KEY AUTO_INCREMENT, data LONGTEXT);") + cur.execute("CREATE TABLE django_migrations (id INT AUTO_INCREMENT PRIMARY KEY, app VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, applied DATETIME NOT NULL);") + cur.execute("CREATE TABLE token_blacklist_outstandingtoken (id INT AUTO_INCREMENT PRIMARY KEY, jti VARCHAR(255) UNIQUE NOT NULL, token TEXT NOT NULL, created_at DATETIME, expires_at DATETIME NOT NULL);") + cur.execute("CREATE TABLE token_blacklist_blacklistedtoken (id INT AUTO_INCREMENT PRIMARY KEY, token_id INT NOT NULL, blacklisted_at DATETIME NOT NULL, FOREIGN KEY (token_id) REFERENCES token_blacklist_outstandingtoken(id));") + cur.execute("CREATE TABLE api_logs (id INT AUTO_INCREMENT PRIMARY KEY, timestamp DATETIME, endpoint VARCHAR(255), method VARCHAR(10), request_headers TEXT, request_body TEXT, response_code INT, response_body TEXT, user_agent VARCHAR(255), ip_address VARCHAR(45), duration_ms INT, status VARCHAR(20), correlation_id VARCHAR(100), service_name VARCHAR(100), log_level VARCHAR(20), error_message TEXT);") + + # Insert sample data + cur.execute("INSERT INTO programs (name) VALUES ('Premium'), ('Standard'), ('Legacy');") + cur.execute("INSERT INTO clients (display_name, client_status, program_id) VALUES ('Global Corp Inc.', 'Active', 1), ('Tech Innovators LLC', 'Active', 1), ('Legacy Systems', 'Inactive', 3), ('Solo Trader', 'Active', 2);") + cur.execute("INSERT INTO accounts (client_id, account_no_dataphile, market_value) VALUES (1, 'F12345', 150000.75), (1, 'F12346', 25000.50), (2, 'F54321', 75000.00), (4, 'F98765', 12000.00);") + cur.execute("INSERT INTO django_migrations (app, name, applied) VALUES ('contenttypes', '0001_initial', NOW()), ('auth', '0001_initial', NOW());") + cur.execute("INSERT INTO token_blacklist_outstandingtoken (jti, token, expires_at) VALUES ('9522d59c56404995af98d4c30bde72b3', 'dummy-token', NOW() + INTERVAL 1 DAY);") + cur.execute("INSERT INTO token_blacklist_blacklistedtoken (token_id, blacklisted_at) VALUES (1, NOW());") + cur.execute("INSERT INTO permissions (role_name, resource_name, can_read) VALUES ('admin', 'ClientsViewSet', true);") + + conn.commit() + cur.close() + conn.close() + print("Database setup complete.") + +# --- Health Check --- +@app.route("/health", methods=["GET"]) +def health_check(): + return jsonify({"status": "healthy"}), 200 + +# --- Original Simple Endpoints --- +@app.route("/data", methods=["POST"]) +@jwt_required() +def create_data(): + conn = get_db_connection() + cur = conn.cursor() + cur.execute("INSERT INTO payloads (data) VALUES (%s)", (request.json.get("message"),)) + conn.commit() + conn.close() + return jsonify({"status": "created"}), 201 + +@app.route("/data", methods=["GET"]) +@jwt_required() +def get_all_data(): + conn = get_db_connection() + cur = conn.cursor(dictionary=True) + cur.execute("SELECT id, data FROM payloads ORDER BY id DESC") + payloads = cur.fetchall() + conn.close() + return jsonify(payloads) + +# --- Initial Complex Endpoint --- +@app.route("/generate-complex-queries", methods=["GET"]) +@jwt_required() +def generate_complex_queries(): + conn = get_db_connection() + if not conn: return jsonify({"error": "Database connection failed"}), 500 + results = {} + try: + cur = conn.cursor(dictionary=True) + cur.execute("SELECT c.id as client_id, c.display_name, a.id as account_id, a.account_no_dataphile FROM clients c INNER JOIN accounts a ON c.id = a.client_id WHERE c.id = 1") + results['join_query'] = cur.fetchall() + cur.execute("SELECT id, display_name FROM clients WHERE id IN (SELECT client_id FROM accounts WHERE market_value > 50000)") + results['subquery_query'] = cur.fetchall() + cur.execute("SELECT role_name FROM permissions WHERE can_read = TRUE") + results['permission_query'] = cur.fetchall() + return jsonify(results) + finally: + if conn and conn.is_connected(): conn.close() + +# --- Second Set of Complex Endpoints --- +@app.route("/system/status", methods=["GET"]) +@jwt_required() +def get_system_status(): + conn = get_db_connection() + if not conn: return jsonify({"error": "Database connection failed"}), 500 + try: + cur = conn.cursor(dictionary=True) + cur.execute("SELECT VERSION() AS version, @@sql_mode AS sql_mode, @@default_storage_engine AS storage_engine, CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC') IS NOT NULL AS utc_check") + return jsonify(cur.fetchone()) + finally: + if conn and conn.is_connected(): conn.close() + +@app.route("/system/migrations", methods=["GET"]) +@jwt_required() +def get_migrations(): + conn = get_db_connection() + if not conn: return jsonify({"error": "Database connection failed"}), 500 + try: + cur = conn.cursor(dictionary=True) + cur.execute("SELECT `id`, `app`, `name`, `applied` FROM `django_migrations`") + return jsonify(cur.fetchall()) + finally: + if conn and conn.is_connected(): conn.close() + +@app.route("/auth/check-token/", methods=["GET"]) +@jwt_required() +def check_blacklisted_token(jti): + conn = get_db_connection() + if not conn: return jsonify({"error": "Database connection failed"}), 500 + try: + cur = conn.cursor(dictionary=True) + query = "SELECT 1 AS `is_blacklisted` FROM `token_blacklist_blacklistedtoken` bt INNER JOIN `token_blacklist_outstandingtoken` ot ON (bt.`token_id` = ot.`id`) WHERE ot.`jti` = %s LIMIT 1" + cur.execute(query, (jti,)) + return jsonify({"status": "Token is blacklisted" if cur.fetchone() else "Token is valid"}) + finally: + if conn and conn.is_connected(): conn.close() + +@app.route("/logs", methods=["POST"]) +@jwt_required() +def create_api_log(): + conn = get_db_connection() + if not conn: return jsonify({"error": "Database connection failed"}), 500 + try: + cur = conn.cursor() + query = "INSERT INTO `api_logs` (`timestamp`, `endpoint`, `method`, `request_headers`, `request_body`, `response_code`, `response_body`, `user_agent`, `ip_address`, `duration_ms`, `status`, `correlation_id`, `service_name`, `log_level`, `error_message`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" + params = (datetime.datetime.now(), request.path, request.method, json.dumps(dict(request.headers)), json.dumps(request.json), 201, '{"status": "logged"}', request.user_agent.string, request.remote_addr, 55, 'SUCCESS', request.headers.get("X-Request-ID", "N/A"), 'api-logger', 'INFO', None) + cur.execute(query, params) + conn.commit() + return jsonify({"status": "log created", "id": cur.lastrowid}), 201 + finally: + if conn and conn.is_connected(): conn.close() + +@app.route("/reports/client-summary", methods=["GET"]) +@jwt_required() +def generate_client_summary(): + conn = get_db_connection() + if not conn: return jsonify({"error": "Database connection failed"}), 500 + try: + cursor = conn.cursor(dictionary=True) + cursor.execute("DROP TEMPORARY TABLE IF EXISTS client_summary;") + cursor.execute("CREATE TEMPORARY TABLE `client_summary` (client_id INT, total_balance DECIMAL(20,2));") + cursor.execute("INSERT INTO `client_summary` (client_id, total_balance) SELECT client_id, SUM(market_value) FROM accounts GROUP BY client_id;") + cursor.execute("SELECT c.display_name, cs.total_balance FROM `client_summary` cs JOIN clients c ON cs.client_id = c.id ORDER BY cs.total_balance DESC;") + return jsonify(cursor.fetchall()) + finally: + if conn and conn.is_connected(): conn.close() + + + +# --- Most Complex Endpoints --- +@app.route("/reports/full-financial-summary", methods=["GET"]) +@jwt_required() +def get_full_financial_summary(): + conn = get_db_connection() + if not conn: return jsonify({"error": "Database connection failed"}), 500 + try: + cur = conn.cursor(dictionary=True) + query = """ + SELECT c.display_name, p.name AS program_name, + (SELECT COUNT(*) FROM accounts a2 WHERE a2.client_id = c.id) AS number_of_accounts, + SUM(a.market_value) AS total_market_value, + CASE WHEN SUM(a.market_value) > 100000 THEN 'Tier 1' + WHEN SUM(a.market_value) BETWEEN 50000 AND 100000 THEN 'Tier 2' + ELSE 'Tier 3' + END AS client_tier + FROM clients c + LEFT JOIN accounts a ON c.id = a.client_id + LEFT JOIN programs p ON c.program_id = p.id + WHERE c.client_status = 'Active' + GROUP BY c.id, p.name + HAVING total_market_value > 10000 OR number_of_accounts > 0 + ORDER BY total_market_value DESC; + """ + cur.execute(query) + return jsonify(cur.fetchall()) + finally: + if conn and conn.is_connected(): conn.close() + +@app.route("/search/clients", methods=["GET"]) +@jwt_required() +def search_clients(): + search_term = request.args.get('q', '') + if not search_term: return jsonify({"error": "Query parameter 'q' is required."}), 400 + conn = get_db_connection() + if not conn: return jsonify({"error": "Database connection failed"}), 500 + try: + cur = conn.cursor(dictionary=True) + query = "SELECT DISTINCT c.id, c.display_name, c.client_status FROM clients c JOIN (SELECT id, client_id, account_no_dataphile FROM accounts) AS a ON c.id = a.client_id WHERE (c.display_name LIKE %s OR a.account_no_dataphile LIKE %s);" + like_pattern = f"%{search_term}%" + cur.execute(query, (like_pattern, like_pattern)) + return jsonify(cur.fetchall()) + finally: + if conn and conn.is_connected(): conn.close() + +@app.route("/transactions/transfer", methods=["POST"]) +@jwt_required() +def transfer_funds(): + data = request.json + from_id, to_id, amount = data.get('from_account_id'), data.get('to_account_id'), decimal.Decimal(data.get('amount', 0)) + if not all([from_id, to_id, amount > 0]): return jsonify({"error": "Missing or invalid parameters"}), 400 + conn = get_db_connection() + if not conn: return jsonify({"error": "Database connection failed"}), 500 + try: + cur = conn.cursor(dictionary=True) + conn.start_transaction() + cur.execute("SELECT market_value FROM accounts WHERE id = %s FOR UPDATE", (from_id,)) + from_account = cur.fetchone() + if not from_account or from_account['market_value'] < amount: + conn.rollback() + return jsonify({"error": "Insufficient funds"}), 400 + cur.execute("UPDATE accounts SET market_value = market_value - %s WHERE id = %s", (amount, from_id)) + cur.execute("UPDATE accounts SET market_value = market_value + %s WHERE id = %s", (amount, to_id)) + cur.execute("INSERT INTO transactions (from_account_id, to_account_id, amount, transaction_time) VALUES (%s, %s, %s, %s)", (from_id, to_id, amount, datetime.datetime.now())) + conn.commit() + return jsonify({"status": "Transfer successful"}), 200 + except mysql.connector.Error as err: + if conn.is_connected(): conn.rollback() + return jsonify({"error": f"Transaction failed: {err}"}), 500 + finally: + if conn and conn.is_connected(): conn.close() + +if __name__ == "__main__": + setup_database() + app.run(host="0.0.0.0", port=5000) \ No newline at end of file diff --git a/flask_mysql/requirements.txt b/flask_mysql/requirements.txt new file mode 100644 index 0000000..55b07e4 --- /dev/null +++ b/flask_mysql/requirements.txt @@ -0,0 +1,4 @@ +Flask==3.1.1 +Flask_JWT_Extended==4.7.1 +mysql-connector-python==9.1.0 +Werkzeug==3.1.3 \ No newline at end of file diff --git a/flask_postgresql_app/.env b/flask_postgresql_app/.env new file mode 100644 index 0000000..e6f528c --- /dev/null +++ b/flask_postgresql_app/.env @@ -0,0 +1,2 @@ +FLASK_ENV=development +DATABASE_URL=postgresql://flaskuser:password@db:5432/flaskdb diff --git a/flask_postgresql_app/Dockerfile b/flask_postgresql_app/Dockerfile new file mode 100644 index 0000000..9c4f754 --- /dev/null +++ b/flask_postgresql_app/Dockerfile @@ -0,0 +1,18 @@ + +FROM python:3.9-slim + + +WORKDIR /usr/src/app + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the working directory contents +COPY . . + +EXPOSE 5000 + +# env +ENV FLASK_APP=app.py + +CMD ["flask", "run", "--host=0.0.0.0"] diff --git a/flask_postgresql_app/README.md b/flask_postgresql_app/README.md new file mode 100644 index 0000000..e41dbc3 --- /dev/null +++ b/flask_postgresql_app/README.md @@ -0,0 +1,81 @@ +# User Management API + + +## Overview + +This is a Flask-based web application that uses PostgreSQL as its database. The project is containerized using Docker and Docker Compose for easy deployment and management. +The endpoints available will be: + +1. `GET /` - Home Route +2. `GET /users` - List all users +3. `POST /users` - Create a new user +4. `PUT /users/` - Update a user +5. `DELETE /users//` - Delete a user + + + +## Setup Instructions + +1. Clone the repository and navigate to project directory. + ```bash + git clone https://github.com/keploy/samples-python.git + cd samples-python/flask_postgresql_app + ``` +2. Install Keploy. + ```bash + curl --silent -O -L https://keploy.io/install.sh && source install.sh + ``` +3. Build and run the Docker containers: + ```bash + docker compose up --build + ``` +4. Access the application: + Once the containers are running, the Flask app will be available at: + ```bash + http://localhost:5000 + ``` +5. Capture the testcases. + ```bash + keploy record -c "docker compose up" --container-name "flask_web_app" + ``` +6. Generate testcases by making API calls. + ### Home Route + # GET / + ```bash + curl -X GET http://localhost:5000 + ``` + ```bash + # Retrieves a list of all users. + # GET /users + curl -X GET http://localhost:5000/users \ + ``` + ```bash + # Create a new user by providing a name. + # POST /users + curl -X POST http://localhost:5000/users -H "Content-Type: application/json" -d '{"name": "Harsh"}' + + ``` + ```bash + # Retrieve a user by their ID. + # GET /users/ + curl -X GET http://localhost:8000/users// \ + + ``` + ```bash + # Update the name of a user by their ID. + # PUT /users/ + curl -X PUT http://localhost:5000/users/ -H "Content-Type: application/json" -d '{"name": "Updated Name"}' + ``` + ```bash + # Delete a user by their ID + # DELETE / + curl -X DELETE http://localhost:5000/users/ + ``` + ```bash + Replace `` with the actual ID of the item you want to retrieve, update, or delete. + +## Run the testcases +```bash +keploy test -c "docker compose up" --container-name "flask_web_app" +``` + diff --git a/flask_postgresql_app/app.py b/flask_postgresql_app/app.py new file mode 100644 index 0000000..cce0ca9 --- /dev/null +++ b/flask_postgresql_app/app.py @@ -0,0 +1,77 @@ +from flask import Flask, jsonify, request +from flask_sqlalchemy import SQLAlchemy +from dotenv import load_dotenv +import os + +# Load environment variables from .env file +load_dotenv() + +app = Flask(__name__) +app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL') +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False + +db = SQLAlchemy(app) + +class User(db.Model): + __tablename__ = 'users' + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String(80), nullable=False) + + def __init__(self, name): + self.name = name + +# Create the database tables +@app.before_request +def create_tables(): + db.create_all() + +# Home route +@app.route('/', methods=['GET']) +def home(): + return jsonify({"message": "Welcome to the User Management API!"}), 200 + +# GET all users +@app.route('/users', methods=['GET']) +def get_users(): + users = User.query.all() + return jsonify([{'id': user.id, 'name': user.name} for user in users]) + +# POST a new user +@app.route('/users', methods=['POST']) +def add_user(): + name = request.json.get('name') + if not name: + return jsonify({"error": "Name is required."}), 400 + user = User(name=name) + db.session.add(user) + db.session.commit() + return jsonify({"message": f"User {name} added.", "id": user.id}), 201 + +# PUT to update a user +@app.route('/users/', methods=['PUT']) +def update_user(id): + user = User.query.get(id) + if user is None: + return jsonify({"error": "User not found."}), 404 + + name = request.json.get('name') + if name: + user.name = name + db.session.commit() + return jsonify({"message": f"User {id} updated."}) + + return jsonify({"error": "Name is required."}), 400 + +# DELETE a user +@app.route('/users/', methods=['DELETE']) +def delete_user(id): + user = User.query.get(id) + if user is None: + return jsonify({"error": "User not found."}), 404 + + db.session.delete(user) + db.session.commit() + return jsonify({"message": f"User {id} deleted."}) + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=5000) diff --git a/flask_postgresql_app/docker-compose.yml b/flask_postgresql_app/docker-compose.yml new file mode 100644 index 0000000..f35f9c5 --- /dev/null +++ b/flask_postgresql_app/docker-compose.yml @@ -0,0 +1,23 @@ +services: + web: + build: . + container_name: flask_web_app + ports: + - "5000:5000" + environment: + - DATABASE_URL=postgresql://flaskuser:password@db:5432/flaskdb + - FLASK_APP=app.py # Ensure Flask app is specified + - FLASK_ENV=development + command: flask run --host=0.0.0.0 # Ensure Flask runs with the correct host + depends_on: + - db + + db: + image: postgres:13 + container_name: flask_db + environment: + POSTGRES_DB: flaskdb + POSTGRES_USER: flaskuser + POSTGRES_PASSWORD: password + ports: + - "5432:5432" diff --git a/flask_postgresql_app/keploy.yml b/flask_postgresql_app/keploy.yml new file mode 100755 index 0000000..4a2a998 --- /dev/null +++ b/flask_postgresql_app/keploy.yml @@ -0,0 +1,61 @@ +path: "" +appId: 0 +appName: flask_postgresql_app +command: docker compose up --build +templatize: + testSets: [] +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: flask_postgresql_app +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + test-sets: {} + delay: 5 + host: "" + port: 0 + apiTimeout: 5 + skipCoverage: false + coverageReportPath: "" + ignoreOrdering: true + mongoPassword: default@123 + language: "" + removeUnusedMocks: false + fallBackOnMiss: false + jacocoAgentPath: "" + basePath: "" + mocking: true + ignoredTests: {} + disableLineCoverage: false + disableMockUpload: true + useLocalMock: false + updateTemplate: false +record: + filters: [] + recordTimer: 0s +configPath: "" +bypassRules: [] +generateGithubActions: false +keployContainer: keploy-v2 +keployNetwork: keploy-network +cmdType: native +contract: + services: [] + tests: [] + path: "" + download: false + generate: false + driven: consumer + mappings: + servicesMapping: {} + self: "" +inCi: false + +# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file. diff --git a/flask_postgresql_app/keploy/.gitignore b/flask_postgresql_app/keploy/.gitignore new file mode 100644 index 0000000..5137843 --- /dev/null +++ b/flask_postgresql_app/keploy/.gitignore @@ -0,0 +1,2 @@ + +/reports/ diff --git a/flask_postgresql_app/keploy/test-set-0/mocks.yaml b/flask_postgresql_app/keploy/test-set-0/mocks.yaml new file mode 100755 index 0000000..2fb48be --- /dev/null +++ b/flask_postgresql_app/keploy/test-set-0/mocks.yaml @@ -0,0 +1,1246 @@ +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-0 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.830573028Z + restimestampmock: 2024-10-09T16:52:02.831244867Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-1 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAKQADAAB1c2VyAGZsYXNrdXNlcgBkYXRhYmFzZQBmbGFza2RiAAA= + auth_type: 0 + postgresresponses: + - header: [R] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [133, 3, 221, 191] + msg_type: 82 + auth_type: 5 + reqtimestampmock: 2024-10-09T16:52:02.831996616Z + restimestampmock: 2024-10-09T16:52:02.832039452Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-2 +spec: + metadata: + type: config + postgresrequests: + - header: [p] + identifier: ClientRequest + length: 8 + password_message: + password: md5e9ccf75670af20adf7c4e48379bb8588 + msg_type: 112 + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 34 + secret_key: 2476999767 + parameter_status: + - name: application_name + value: "" + - name: client_encoding + value: UTF8 + - name: DateStyle + value: ISO, MDY + - name: integer_datetimes + value: "on" + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "on" + - name: server_encoding + value: UTF8 + - name: server_version + value: 13.16 (Debian 13.16-1.pgdg120+1) + - name: session_authorization + value: flaskuser + - name: standard_conforming_strings + value: "on" + - name: TimeZone + value: Etc/UTC + - name: TimeZone + value: Etc/UTC + - name: TimeZone + value: Etc/UTC + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.835642375Z + restimestampmock: 2024-10-09T16:52:02.835723939Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-3 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: BEGIN + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: BEGIN + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.836164161Z + restimestampmock: 2024-10-09T16:52:02.83619432Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-4 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + payload: UQAAAHdTRUxFQ1QgdC5vaWQsIHR5cGFycmF5CkZST00gcGdfdHlwZSB0IEpPSU4gcGdfbmFtZXNwYWNlIG5zCiAgICBPTiB0eXBuYW1lc3BhY2UgPSBucy5vaWQKV0hFUkUgdHlwbmFtZSA9ICdoc3RvcmUnOwoA + query: + string: 'SELECT t.oid, typarray FROM pg_type t JOIN pg_namespace ns ON typnamespace = ns.oid WHERE typname = ''hstore''; ' + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 0 + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: oid, table_oid: 1247, table_attribute_number: 1, data_type_oid: 26, data_type_size: 4, type_modifier: -1, format: 0}, {field_name: typarray, table_oid: 1247, table_attribute_number: 14, data_type_oid: 26, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.837461213Z + restimestampmock: 2024-10-09T16:52:02.837501512Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-5 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: ROLLBACK + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: ROLLBACK + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.837848953Z + restimestampmock: 2024-10-09T16:52:02.837885486Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-6 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: BEGIN + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: BEGIN + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.838418843Z + restimestampmock: 2024-10-09T16:52:02.838454616Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-7 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: select version() + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: ['PostgreSQL 13.16 (Debian 13.16-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit']}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: version, table_oid: 0, table_attribute_number: 0, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.838665794Z + restimestampmock: 2024-10-09T16:52:02.838698521Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-8 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: select current_schema() + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: [public]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: current_schema, table_oid: 0, table_attribute_number: 0, data_type_oid: 19, data_type_size: 64, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.839613853Z + restimestampmock: 2024-10-09T16:52:02.839662169Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-9 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: show transaction isolation level + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SHOW + data_row: [{row_values: [read committed]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: transaction_isolation, table_oid: 0, table_attribute_number: 0, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.83998089Z + restimestampmock: 2024-10-09T16:52:02.840014622Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-10 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: [test plain returns]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: anon_1, table_oid: 0, table_attribute_number: 0, data_type_oid: 1043, data_type_size: -1, type_modifier: 64, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.841477739Z + restimestampmock: 2024-10-09T16:52:02.84152715Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-11 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: [test unicode returns]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: anon_1, table_oid: 0, table_attribute_number: 0, data_type_oid: 1043, data_type_size: -1, type_modifier: 64, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.842010391Z + restimestampmock: 2024-10-09T16:52:02.84203208Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-12 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: show standard_conforming_strings + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SHOW + data_row: [{row_values: ["on"]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: standard_conforming_strings, table_oid: 0, table_attribute_number: 0, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.842246434Z + restimestampmock: 2024-10-09T16:52:02.842285151Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-13 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: ROLLBACK + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: ROLLBACK + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.842554536Z + restimestampmock: 2024-10-09T16:52:02.842597306Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-14 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: BEGIN + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: BEGIN + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.84341846Z + restimestampmock: 2024-10-09T16:52:02.84347898Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-15 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where pg_catalog.pg_table_is_visible(c.oid) and relname='users' + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: [users]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: relname, table_oid: 1259, table_attribute_number: 2, data_type_oid: 19, data_type_size: 64, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.844216679Z + restimestampmock: 2024-10-09T16:52:02.844269317Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-16 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: ROLLBACK + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: ROLLBACK + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:02.844850035Z + restimestampmock: 2024-10-09T16:52:02.844879734Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-17 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: BEGIN + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: BEGIN + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:15.942120188Z + restimestampmock: 2024-10-09T16:52:15.942255625Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-18 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: INSERT INTO users (name) VALUES ('harshjoshi') RETURNING users.id + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: INSERT 0 1 + data_row: [{row_values: ["5"]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: id, table_oid: 16387, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:15.943656569Z + restimestampmock: 2024-10-09T16:52:15.943699019Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-19 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: COMMIT + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: COMMIT + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:15.948172194Z + restimestampmock: 2024-10-09T16:52:15.948306699Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-20 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: BEGIN + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: BEGIN + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:15.950999349Z + restimestampmock: 2024-10-09T16:52:15.951212649Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-21 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + payload: UQAAAFpTRUxFQ1QgdXNlcnMuaWQgQVMgdXNlcnNfaWQsIHVzZXJzLm5hbWUgQVMgdXNlcnNfbmFtZSAKRlJPTSB1c2VycyAKV0hFUkUgdXNlcnMuaWQgPSA1AA== + query: + string: SELECT users.id AS users_id, users.name AS users_name FROM users WHERE users.id = 5 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: ["5", harshjoshi]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: users_id, table_oid: 16387, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {field_name: users_name, table_oid: 16387, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: 84, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:15.960229809Z + restimestampmock: 2024-10-09T16:52:15.960468611Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-22 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: ROLLBACK + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: ROLLBACK + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:15.964142202Z + restimestampmock: 2024-10-09T16:52:15.964294111Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-23 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: BEGIN + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: BEGIN + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:24.27538668Z + restimestampmock: 2024-10-09T16:52:24.275522488Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-24 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + payload: UQAAAFpTRUxFQ1QgdXNlcnMuaWQgQVMgdXNlcnNfaWQsIHVzZXJzLm5hbWUgQVMgdXNlcnNfbmFtZSAKRlJPTSB1c2VycyAKV0hFUkUgdXNlcnMuaWQgPSA1AA== + query: + string: SELECT users.id AS users_id, users.name AS users_name FROM users WHERE users.id = 5 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: ["5", harshjoshi]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: users_id, table_oid: 16387, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {field_name: users_name, table_oid: 16387, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: 84, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:24.276356632Z + restimestampmock: 2024-10-09T16:52:24.276478637Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-25 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: UPDATE users SET name='harshjoshi1' WHERE users.id = 5 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: UPDATE 1 + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:24.278842896Z + restimestampmock: 2024-10-09T16:52:24.278889652Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-26 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: COMMIT + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: COMMIT + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:24.281524213Z + restimestampmock: 2024-10-09T16:52:24.281569809Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-27 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: BEGIN + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: BEGIN + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:29.150281172Z + restimestampmock: 2024-10-09T16:52:29.150394831Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-28 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + payload: UQAAAFpTRUxFQ1QgdXNlcnMuaWQgQVMgdXNlcnNfaWQsIHVzZXJzLm5hbWUgQVMgdXNlcnNfbmFtZSAKRlJPTSB1c2VycyAKV0hFUkUgdXNlcnMuaWQgPSA1AA== + query: + string: SELECT users.id AS users_id, users.name AS users_name FROM users WHERE users.id = 5 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: ["5", harshjoshi1]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: users_id, table_oid: 16387, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {field_name: users_name, table_oid: 16387, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: 84, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:29.151126001Z + restimestampmock: 2024-10-09T16:52:29.151159414Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-29 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: DELETE FROM users WHERE users.id = 5 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: DELETE 1 + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:29.152177132Z + restimestampmock: 2024-10-09T16:52:29.1522471Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-30 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: COMMIT + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: COMMIT + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:29.154192548Z + restimestampmock: 2024-10-09T16:52:29.154266201Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-31 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: BEGIN + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: BEGIN + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:34.320529598Z + restimestampmock: 2024-10-09T16:52:34.320605115Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-32 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + payload: UQAAAEZTRUxFQ1QgdXNlcnMuaWQgQVMgdXNlcnNfaWQsIHVzZXJzLm5hbWUgQVMgdXNlcnNfbmFtZSAKRlJPTSB1c2VycwA= + query: + string: SELECT users.id AS users_id, users.name AS users_name FROM users + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: ["4", harsh]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: users_id, table_oid: 16387, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {field_name: users_name, table_oid: 16387, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: 84, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:34.321330701Z + restimestampmock: 2024-10-09T16:52:34.321478797Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-33 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: ROLLBACK + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: ROLLBACK + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:34.323701768Z + restimestampmock: 2024-10-09T16:52:34.323826848Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-34 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: BEGIN + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: BEGIN + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:49.282145701Z + restimestampmock: 2024-10-09T16:52:49.282269829Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-35 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + payload: UQAAAFpTRUxFQ1QgdXNlcnMuaWQgQVMgdXNlcnNfaWQsIHVzZXJzLm5hbWUgQVMgdXNlcnNfbmFtZSAKRlJPTSB1c2VycyAKV0hFUkUgdXNlcnMuaWQgPSA0AA== + query: + string: SELECT users.id AS users_id, users.name AS users_name FROM users WHERE users.id = 4 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: ["4", harsh]}] + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: users_id, table_oid: 16387, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {field_name: users_name, table_oid: 16387, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: 84, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:49.282941176Z + restimestampmock: 2024-10-09T16:52:49.283010044Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-36 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: DELETE FROM users WHERE users.id = 4 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: DELETE 1 + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:49.284580663Z + restimestampmock: 2024-10-09T16:52:49.284602152Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-37 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: COMMIT + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: COMMIT + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:49.286666457Z + restimestampmock: 2024-10-09T16:52:49.286736895Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-38 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: BEGIN + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: BEGIN + ready_for_query: + txstatus: 84 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:56.967044619Z + restimestampmock: 2024-10-09T16:52:56.967123063Z +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-39 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + payload: UQAAAEZTRUxFQ1QgdXNlcnMuaWQgQVMgdXNlcnNfaWQsIHVzZXJzLm5hbWUgQVMgdXNlcnNfbmFtZSAKRlJPTSB1c2VycwA= + query: + string: SELECT users.id AS users_id, users.name AS users_name FROM users + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 0 + ready_for_query: + txstatus: 84 + row_description: {fields: [{field_name: users_id, table_oid: 16387, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {field_name: users_name, table_oid: 16387, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: 84, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-10-09T16:52:56.96770962Z + restimestampmock: 2024-10-09T16:52:56.967773952Z +connectionId: "0" diff --git a/flask_postgresql_app/keploy/test-set-0/tests/test-1.yaml b/flask_postgresql_app/keploy/test-set-0/tests/test-1.yaml new file mode 100755 index 0000000..6e22f8a --- /dev/null +++ b/flask_postgresql_app/keploy/test-set-0/tests/test-1.yaml @@ -0,0 +1,53 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/ + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: close + Content-Length: "25" + Content-Type: application/json + Host: localhost:5000 + User-Agent: Thunder Client (https://www.thunderclient.com) + body: |- + { + "name":"harshjoshi" + } + timestamp: 2024-10-09T16:52:02.809644362Z + resp: + status_code: 200 + header: + Content-Length: "55" + Content-Type: application/json + Date: Wed, 09 Oct 2024 16:52:02 GMT + Server: Werkzeug/2.0.1 Python/3.9.20 + body: | + { + "message": "Welcome to the User Management API!" + } + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-09T16:52:04.856965925Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1728492724 +curl: |- + curl --request GET \ + --url http://localhost:5000/ \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Accept: */*' \ + --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:5000' \ + --header 'Connection: close' \ + --data "{\n \"name\":\"harshjoshi\"\n}" diff --git a/flask_postgresql_app/keploy/test-set-0/tests/test-2.yaml b/flask_postgresql_app/keploy/test-set-0/tests/test-2.yaml new file mode 100755 index 0000000..ca56fc9 --- /dev/null +++ b/flask_postgresql_app/keploy/test-set-0/tests/test-2.yaml @@ -0,0 +1,50 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-2 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/users + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: close + Content-Length: "25" + Content-Type: application/json + Host: localhost:5000 + User-Agent: Thunder Client (https://www.thunderclient.com) + body: |- + { + "name":"harshjoshi" + } + timestamp: 2024-10-09T16:52:15.936436966Z + resp: + status_code: 201 + header: + Content-Length: "54" + Content-Type: application/json + Date: Wed, 09 Oct 2024 16:52:15 GMT + Server: Werkzeug/2.0.1 Python/3.9.20 + body: "{\n \"id\": 5, \n \"message\": \"User harshjoshi added.\"\n}\n" + status_message: Created + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-09T16:52:18.022153619Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1728492738 +curl: |- + curl --request POST \ + --url http://localhost:5000/users \ + --header 'Accept: */*' \ + --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:5000' \ + --header 'Connection: close' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --data "{\n \"name\":\"harshjoshi\"\n}" diff --git a/flask_postgresql_app/keploy/test-set-0/tests/test-3.yaml b/flask_postgresql_app/keploy/test-set-0/tests/test-3.yaml new file mode 100755 index 0000000..f99ce73 --- /dev/null +++ b/flask_postgresql_app/keploy/test-set-0/tests/test-3.yaml @@ -0,0 +1,53 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-3 +spec: + metadata: {} + req: + method: PUT + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/users/5 + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: close + Content-Length: "26" + Content-Type: application/json + Host: localhost:5000 + User-Agent: Thunder Client (https://www.thunderclient.com) + body: |- + { + "name":"harshjoshi1" + } + timestamp: 2024-10-09T16:52:24.271748853Z + resp: + status_code: 200 + header: + Content-Length: "35" + Content-Type: application/json + Date: Wed, 09 Oct 2024 16:52:24 GMT + Server: Werkzeug/2.0.1 Python/3.9.20 + body: | + { + "message": "User 5 updated." + } + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-09T16:52:26.3624278Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1728492746 +curl: |- + curl --request PUT \ + --url http://localhost:5000/users/5 \ + --header 'Connection: close' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Accept: */*' \ + --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:5000' \ + --data "{\n \"name\":\"harshjoshi1\"\n}" diff --git a/flask_postgresql_app/keploy/test-set-0/tests/test-4.yaml b/flask_postgresql_app/keploy/test-set-0/tests/test-4.yaml new file mode 100755 index 0000000..36650b5 --- /dev/null +++ b/flask_postgresql_app/keploy/test-set-0/tests/test-4.yaml @@ -0,0 +1,53 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-4 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/users/5 + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: close + Content-Length: "26" + Content-Type: application/json + Host: localhost:5000 + User-Agent: Thunder Client (https://www.thunderclient.com) + body: |- + { + "name":"harshjoshi1" + } + timestamp: 2024-10-09T16:52:29.147040179Z + resp: + status_code: 200 + header: + Content-Length: "35" + Content-Type: application/json + Date: Wed, 09 Oct 2024 16:52:29 GMT + Server: Werkzeug/2.0.1 Python/3.9.20 + body: | + { + "message": "User 5 deleted." + } + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-09T16:52:31.185249908Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1728492751 +curl: |- + curl --request DELETE \ + --url http://localhost:5000/users/5 \ + --header 'Host: localhost:5000' \ + --header 'Connection: close' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Accept: */*' \ + --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \ + --header 'Content-Type: application/json' \ + --data "{\n \"name\":\"harshjoshi1\"\n}" diff --git a/flask_postgresql_app/keploy/test-set-0/tests/test-5.yaml b/flask_postgresql_app/keploy/test-set-0/tests/test-5.yaml new file mode 100755 index 0000000..97dab2a --- /dev/null +++ b/flask_postgresql_app/keploy/test-set-0/tests/test-5.yaml @@ -0,0 +1,50 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-5 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/users + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: close + Content-Length: "26" + Content-Type: application/json + Host: localhost:5000 + User-Agent: Thunder Client (https://www.thunderclient.com) + body: |- + { + "name":"harshjoshi1" + } + timestamp: 2024-10-09T16:52:34.318334127Z + resp: + status_code: 200 + header: + Content-Length: "46" + Content-Type: application/json + Date: Wed, 09 Oct 2024 16:52:34 GMT + Server: Werkzeug/2.0.1 Python/3.9.20 + body: "[\n {\n \"id\": 4, \n \"name\": \"harsh\"\n }\n]\n" + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-09T16:52:36.413011311Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1728492756 +curl: |- + curl --request GET \ + --url http://localhost:5000/users \ + --header 'Accept: */*' \ + --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:5000' \ + --header 'Connection: close' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --data "{\n \"name\":\"harshjoshi1\"\n}" diff --git a/flask_postgresql_app/keploy/test-set-0/tests/test-6.yaml b/flask_postgresql_app/keploy/test-set-0/tests/test-6.yaml new file mode 100755 index 0000000..649f206 --- /dev/null +++ b/flask_postgresql_app/keploy/test-set-0/tests/test-6.yaml @@ -0,0 +1,53 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-6 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/users/4 + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: close + Content-Length: "26" + Content-Type: application/json + Host: localhost:5000 + User-Agent: Thunder Client (https://www.thunderclient.com) + body: |- + { + "name":"harshjoshi1" + } + timestamp: 2024-10-09T16:52:49.27966925Z + resp: + status_code: 200 + header: + Content-Length: "35" + Content-Type: application/json + Date: Wed, 09 Oct 2024 16:52:49 GMT + Server: Werkzeug/2.0.1 Python/3.9.20 + body: | + { + "message": "User 4 deleted." + } + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-09T16:52:51.378732252Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1728492771 +curl: |- + curl --request DELETE \ + --url http://localhost:5000/users/4 \ + --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:5000' \ + --header 'Connection: close' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Accept: */*' \ + --data "{\n \"name\":\"harshjoshi1\"\n}" diff --git a/flask_postgresql_app/keploy/test-set-0/tests/test-7.yaml b/flask_postgresql_app/keploy/test-set-0/tests/test-7.yaml new file mode 100755 index 0000000..3aa1e77 --- /dev/null +++ b/flask_postgresql_app/keploy/test-set-0/tests/test-7.yaml @@ -0,0 +1,54 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-7 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:5000/users/ + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: close + Content-Length: "26" + Content-Type: application/json + Host: localhost:5000 + User-Agent: Thunder Client (https://www.thunderclient.com) + body: |- + { + "name":"harshjoshi1" + } + timestamp: 2024-10-09T16:52:53.793701467Z + resp: + status_code: 404 + header: + Content-Length: "232" + Content-Type: text/html; charset=utf-8 + Date: Wed, 09 Oct 2024 16:52:53 GMT + Server: Werkzeug/2.0.1 Python/3.9.20 + body: | + + 404 Not Found +

Not Found

+

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

+ status_message: Not Found + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-09T16:52:55.800973357Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1728492775 +curl: |- + curl --request GET \ + --url http://localhost:5000/users/ \ + --header 'Host: localhost:5000' \ + --header 'Connection: close' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Accept: */*' \ + --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \ + --header 'Content-Type: application/json' \ + --data "{\n \"name\":\"harshjoshi1\"\n}" diff --git a/flask_postgresql_app/requirements.txt b/flask_postgresql_app/requirements.txt new file mode 100644 index 0000000..d6ff7bb --- /dev/null +++ b/flask_postgresql_app/requirements.txt @@ -0,0 +1,6 @@ +Flask==2.3.3 +Flask-SQLAlchemy==3.0.5 +psycopg2-binary==2.9.10 +Werkzeug==3.0.5 +SQLAlchemy==2.0.36 +python-dotenv diff --git a/sanic-mongo/README.md b/sanic-mongo/README.md new file mode 100644 index 0000000..f0cc267 --- /dev/null +++ b/sanic-mongo/README.md @@ -0,0 +1,122 @@ +This application is a simple movie management API built using Python's Sanic framework and MongoDB for data storage. It allows you to perform basic CRUD (Create, Read, Update, Delete) operations on Movie records. + +## Table of Contents + +# Introduction + +🪄 Dive into the world of Movie CRUD Apps and see how seamlessly Keploy integrated with [Sanic](hhttps://sanic.dev/en/) and [MongoDB](https://www.mongodb.com/). Buckle up, it's gonna be a fun ride! 🎢 + +## Pre-Requisite 🛠️ + +- Install WSL (`wsl --install`) for Windows Windows. + +## Optional 🛠️ + +- Install Colima( `brew install colima && colima start` ) for MacOS MacOs. + +## Installation 📥 + +Depending on your OS, choose your adventure: + +Alright, let's equip ourselves with the **latest Keploy binary**: + +```bash +curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp + +sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy +``` + +#### Add alias for Keploy: + +```bash +alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy' +``` + +Now head to the folder of the application and run + +``` +pip3 install -r requirements.txt +``` + +### Lights, Camera, Record! 🎥 + +Capture the test-cases- + +```shell +keploy record -c "python3 server.py" +``` + +🔥**Make some API calls**. Postman, Hoppscotch or even curl - take your pick! + +Let's make URLs short and sweet: + +### Generate testcases + +To generate testcases we just need to **make some API calls.** + +**1. Make a POST requests** + +```bash + curl -X "POST" "http://127.0.0.1:8000/add_movie" \ + -H 'Accept: application/json' \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d '{ + "name": "Whiplash" + }' +``` + +```bash + curl -X "POST" "http://127.0.0.1:8000/add_movie" \ + -H 'Accept: application/json' \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d '{ + "name": "Chappie" + }' +``` + +```bash + curl -X "POST" "http://127.0.0.1:8000/add_movie" \ + -H 'Accept: application/json' \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d '{ + "name": "Titanic" + }' +``` + +**2. Make a GET request** + +In order to see all the movies added to the database, run: + +``` +curl -X "GET" "http://127.0.0.1:8000/movies" \ + -H 'Accept: application/json' \ + -H 'Content-Type: application/json; charset=utf-8' +``` + +**3. Make a DELETE request** + +In order to delete all the movies, run: + +```bash + curl -X "DELETE" "http://127.0.0.1:8000/movies" \ + -H 'Accept: application/json' \ + -H 'Content-Type: application/json; charset=utf-8' +``` + +You will now see a folder named `keploy` with your recorded tests. + +#### Run Tests + +Time to put things to the test 🧪 + +```shell +keploy test -c "python server.py" +``` + +## 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! ✨👩‍💻👨‍💻✨ + +
diff --git a/sanic-mongo/keploy/test-set-0/mocks.yaml b/sanic-mongo/keploy/test-set-0/mocks.yaml new file mode 100644 index 0000000..55e5e0a --- /dev/null +++ b/sanic-mongo/keploy/test-set-0/mocks.yaml @@ -0,0 +1,490 @@ +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-0 +spec: + metadata: + operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo|Motor","version": "4.6.3|3.4.0"},"os": {"type": "Linux","name": "Linux","architecture": "x86_64","version": "5.15.146.1-microsoft-standard-WSL2"},"platform": "CPython 3.10.12.final.0|asyncio"}}, returnFieldsSelector: }' + type: config + requests: + - header: + length: 303 + requestId: 1804289383 + responseTo: 0 + Opcode: 2004 + message: + flags: 0 + collection_name: admin.$cmd + number_to_skip: 0 + number_to_return: -1 + query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo|Motor","version":"4.6.3|3.4.0"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"5.15.146.1-microsoft-standard-WSL2"},"platform":"CPython 3.10.12.final.0|asyncio"}}' + return_fields_selector: "" + responses: + - header: + length: 329 + requestId: 13 + responseTo: 1804289383 + Opcode: 1 + message: + response_flags: 8 + cursor_id: 0 + starting_from: 0 + number_returned: 1 + documents: + - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"667b1d2066b0c1d16885b016"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1719344783026"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"4"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}' + read_delay: 560917 + created: 1719344783 + reqTimestampMock: 2024-06-26T01:16:23.025984506+05:30 + resTimestampMock: 2024-06-26T01:16:23.026710262+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-1 +spec: + metadata: + operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo|Motor","version": "4.6.3|3.4.0"},"os": {"type": "Linux","name": "Linux","architecture": "x86_64","version": "5.15.146.1-microsoft-standard-WSL2"},"platform": "CPython 3.10.12.final.0|asyncio"},"compression": []}, returnFieldsSelector: }' + type: config + requests: + - header: + length: 321 + requestId: 1714636915 + responseTo: 0 + Opcode: 2004 + message: + flags: 0 + collection_name: admin.$cmd + number_to_skip: 0 + number_to_return: -1 + query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo|Motor","version":"4.6.3|3.4.0"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"5.15.146.1-microsoft-standard-WSL2"},"platform":"CPython 3.10.12.final.0|asyncio"},"compression":[]}' + return_fields_selector: "" + responses: + - header: + length: 329 + requestId: 15 + responseTo: 1714636915 + Opcode: 1 + message: + response_flags: 8 + cursor_id: 0 + starting_from: 0 + number_returned: 1 + documents: + - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"667b1d2066b0c1d16885b016"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1719344783030"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"6"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}' + read_delay: 657515 + created: 1719344783 + reqTimestampMock: 2024-06-26T01:16:23.030363133+05:30 + resTimestampMock: 2024-06-26T01:16:23.031173194+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-2 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"movies","ordered":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }, { SectionSingle identifier: documents , msgs: [ {"_id":"667b1e8fd71cb97567de07c5","name":"Whiplash"} ] }], checksum: 0 }' + requests: + - header: + length: 179 + requestId: 1957747793 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"insert":"movies","ordered":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }' + - '{ SectionSingle identifier: documents , msgs: [ {"_id":"667b1e8fd71cb97567de07c5","name":"Whiplash"} ] }' + checksum: 0 + read_delay: 542094 + responses: + - header: + length: 45 + requestId: 16 + responseTo: 1957747793 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 551413 + created: 1719344783 + reqTimestampMock: 2024-06-26T01:16:23.031860881+05:30 + resTimestampMock: 2024-06-26T01:16:23.032549882+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-3 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"movies","filter":{"_id":"667b1e8fd71cb97567de07c5"},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }], checksum: 0 }' + requests: + - header: + length: 166 + requestId: 424238335 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"movies","filter":{"_id":"667b1e8fd71cb97567de07c5"},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }' + checksum: 0 + read_delay: 1402363 + responses: + - header: + length: 162 + requestId: 17 + responseTo: 424238335 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":"667b1e8fd71cb97567de07c5","name":"Whiplash"}],"id":{"$numberLong":"0"},"ns":"myapp.movies"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 778841 + created: 1719344783 + reqTimestampMock: 2024-06-26T01:16:23.034169772+05:30 + resTimestampMock: 2024-06-26T01:16:23.035109665+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-4 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"movies","ordered":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }, { SectionSingle identifier: documents , msgs: [ {"_id":"667b1e95d71cb97567de07c6","name":"Chappie"} ] }], checksum: 0 }' + requests: + - header: + length: 178 + requestId: 719885386 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"insert":"movies","ordered":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }' + - '{ SectionSingle identifier: documents , msgs: [ {"_id":"667b1e95d71cb97567de07c6","name":"Chappie"} ] }' + checksum: 0 + read_delay: 6203095487 + responses: + - header: + length: 45 + requestId: 18 + responseTo: 719885386 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 745693 + created: 1719344789 + reqTimestampMock: 2024-06-26T01:16:29.238351946+05:30 + resTimestampMock: 2024-06-26T01:16:29.239303785+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-5 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"movies","filter":{"_id":"667b1e95d71cb97567de07c6"},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }], checksum: 0 }' + requests: + - header: + length: 166 + requestId: 1649760492 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"movies","filter":{"_id":"667b1e95d71cb97567de07c6"},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }' + checksum: 0 + read_delay: 2447949 + responses: + - header: + length: 161 + requestId: 19 + responseTo: 1649760492 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":"667b1e95d71cb97567de07c6","name":"Chappie"}],"id":{"$numberLong":"0"},"ns":"myapp.movies"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 630241 + created: 1719344789 + reqTimestampMock: 2024-06-26T01:16:29.241914889+05:30 + resTimestampMock: 2024-06-26T01:16:29.242682647+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-6 +spec: + metadata: + operation: '{ OpMsg flags: 65536, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"667b1d2066b0c1d16885b016"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 134 + requestId: 846930886 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 65536 + sections: + - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"667b1d2066b0c1d16885b016"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }' + checksum: 0 + read_delay: 2161277 + responses: + - header: + length: 313 + requestId: 20 + responseTo: 846930886 + Opcode: 2013 + message: + flagBits: 2 + sections: + - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"667b1d2066b0c1d16885b016"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1719344793039"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"4"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 10010918319 + created: 1719344793 + reqTimestampMock: 2024-06-26T01:16:23.029068649+05:30 + resTimestampMock: 2024-06-26T01:16:33.040142118+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-7 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 52 + requestId: 596516649 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }' + checksum: 0 + read_delay: 10012578387 + responses: + - header: + length: 313 + requestId: 21 + responseTo: 596516649 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"667b1d2066b0c1d16885b016"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1719344793043"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"5"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 455336 + created: 1719344793 + reqTimestampMock: 2024-06-26T01:16:33.043665579+05:30 + resTimestampMock: 2024-06-26T01:16:33.044280965+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-8 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"movies","ordered":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }, { SectionSingle identifier: documents , msgs: [ {"_id":"667b1e9bd71cb97567de07c7","name":"Titanic"} ] }], checksum: 0 }' + requests: + - header: + length: 178 + requestId: 1189641421 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"insert":"movies","ordered":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }' + - '{ SectionSingle identifier: documents , msgs: [ {"_id":"667b1e9bd71cb97567de07c7","name":"Titanic"} ] }' + checksum: 0 + read_delay: 6649200875 + responses: + - header: + length: 45 + requestId: 22 + responseTo: 1189641421 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 561569 + created: 1719344795 + reqTimestampMock: 2024-06-26T01:16:35.892029796+05:30 + resTimestampMock: 2024-06-26T01:16:35.892711+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-9 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"movies","filter":{"_id":"667b1e9bd71cb97567de07c7"},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }], checksum: 0 }' + requests: + - header: + length: 166 + requestId: 1025202362 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"movies","filter":{"_id":"667b1e9bd71cb97567de07c7"},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }' + checksum: 0 + read_delay: 1988209 + responses: + - header: + length: 161 + requestId: 23 + responseTo: 1025202362 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":"667b1e9bd71cb97567de07c7","name":"Titanic"}],"id":{"$numberLong":"0"},"ns":"myapp.movies"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 502216 + created: 1719344795 + reqTimestampMock: 2024-06-26T01:16:35.894867685+05:30 + resTimestampMock: 2024-06-26T01:16:35.895517417+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-10 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"movies","filter":{},"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }], checksum: 0 }' + requests: + - header: + length: 107 + requestId: 1350490027 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"movies","filter":{},"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }' + checksum: 0 + read_delay: 6177066246 + responses: + - header: + length: 343 + requestId: 24 + responseTo: 1350490027 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":"667b1e6d33a7849da6520cea","name":"Whiplash"},{"_id":"667b1e8fd71cb97567de07c5","name":"Whiplash"},{"_id":"667b1e95d71cb97567de07c6","name":"Chappie"},{"_id":"667b1e9bd71cb97567de07c7","name":"Titanic"}],"id":{"$numberLong":"0"},"ns":"myapp.movies"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 1275690 + created: 1719344802 + reqTimestampMock: 2024-06-26T01:16:42.072696856+05:30 + resTimestampMock: 2024-06-26T01:16:42.074091198+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-11 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 65 + requestId: 783368690 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }' + checksum: 0 + read_delay: 10012605933 + responses: + - header: + length: 314 + requestId: 26 + responseTo: 783368690 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"667b1d2066b0c1d16885b016"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1719344803057"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"5"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 522723 + created: 1719344803 + reqTimestampMock: 2024-06-26T01:16:43.057053931+05:30 + resTimestampMock: 2024-06-26T01:16:43.057762251+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-12 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"delete":"movies","ordered":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }, { SectionSingle identifier: deletes , msgs: [ {"q":{},"limit":{"$numberInt":"0"}} ] }], checksum: 0 }' + requests: + - header: + length: 143 + requestId: 1102520059 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"delete":"movies","ordered":true,"lsid":{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}},"$db":"myapp"} }' + - '{ SectionSingle identifier: deletes , msgs: [ {"q":{},"limit":{"$numberInt":"0"}} ] }' + checksum: 0 + read_delay: 9127441948 + responses: + - header: + length: 45 + requestId: 27 + responseTo: 1102520059 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"n":{"$numberInt":"4"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 761264 + created: 1719344811 + reqTimestampMock: 2024-06-26T01:16:51.201703124+05:30 + resTimestampMock: 2024-06-26T01:16:51.20258821+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-13 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"endSessions":[{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}}],"$db":"admin"} }], checksum: 0 }' + requests: + - header: + length: 92 + requestId: 1967513926 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"endSessions":[{"id":{"$binary":{"base64":"Mx+ps9bVQSSsAdH3K5VdCg==","subType":"04"}}}],"$db":"admin"} }' + checksum: 0 + read_delay: 8507808445 + responses: + - header: + length: 38 + requestId: 30 + responseTo: 1967513926 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 382255 + created: 1719344819 + reqTimestampMock: 2024-06-26T01:16:59.710542397+05:30 + resTimestampMock: 2024-06-26T01:16:59.711041681+05:30 diff --git a/sanic-mongo/keploy/test-set-0/tests/test-1.yaml b/sanic-mongo/keploy/test-set-0/tests/test-1.yaml new file mode 100644 index 0000000..320cd9b --- /dev/null +++ b/sanic-mongo/keploy/test-set-0/tests/test-1.yaml @@ -0,0 +1,42 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://127.0.0.1:8000/add_movie + header: + Accept: application/json + Content-Length: "20" + Content-Type: application/json; charset=utf-8 + Host: 127.0.0.1:8000 + User-Agent: curl/7.81.0 + body: '{"name": "Whiplash"}' + timestamp: 2024-06-26T01:16:23.022752322+05:30 + resp: + status_code: 200 + header: + Alt-Svc: "" + Connection: keep-alive + Content-Length: "52" + Content-Type: application/json + body: '{"_id":"667b1e8fd71cb97567de07c5","name":"Whiplash"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-06-26T01:16:25.086349854+05:30 + objects: [] + assertions: + noise: {} + created: 1719344785 +curl: |- + curl --request POST \ + --url http://127.0.0.1:8000/add_movie \ + --header 'Host: 127.0.0.1:8000' \ + --header 'User-Agent: curl/7.81.0' \ + --header 'Accept: application/json' \ + --header 'Content-Type: application/json; charset=utf-8' \ + --data '{"name": "Whiplash"}' diff --git a/sanic-mongo/keploy/test-set-0/tests/test-2.yaml b/sanic-mongo/keploy/test-set-0/tests/test-2.yaml new file mode 100644 index 0000000..719b20c --- /dev/null +++ b/sanic-mongo/keploy/test-set-0/tests/test-2.yaml @@ -0,0 +1,42 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-2 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://127.0.0.1:8000/add_movie + header: + Accept: application/json + Content-Length: "19" + Content-Type: application/json; charset=utf-8 + Host: 127.0.0.1:8000 + User-Agent: curl/7.81.0 + body: '{"name": "Chappie"}' + timestamp: 2024-06-26T01:16:29.236765225+05:30 + resp: + status_code: 200 + header: + Alt-Svc: "" + Connection: keep-alive + Content-Length: "51" + Content-Type: application/json + body: '{"_id":"667b1e95d71cb97567de07c6","name":"Chappie"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-06-26T01:16:31.312393895+05:30 + objects: [] + assertions: + noise: {} + created: 1719344791 +curl: |- + curl --request POST \ + --url http://127.0.0.1:8000/add_movie \ + --header 'Host: 127.0.0.1:8000' \ + --header 'User-Agent: curl/7.81.0' \ + --header 'Accept: application/json' \ + --header 'Content-Type: application/json; charset=utf-8' \ + --data '{"name": "Chappie"}' diff --git a/sanic-mongo/keploy/test-set-0/tests/test-3.yaml b/sanic-mongo/keploy/test-set-0/tests/test-3.yaml new file mode 100644 index 0000000..9948d84 --- /dev/null +++ b/sanic-mongo/keploy/test-set-0/tests/test-3.yaml @@ -0,0 +1,42 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-3 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://127.0.0.1:8000/add_movie + header: + Accept: application/json + Content-Length: "19" + Content-Type: application/json; charset=utf-8 + Host: 127.0.0.1:8000 + User-Agent: curl/7.81.0 + body: '{"name": "Titanic"}' + timestamp: 2024-06-26T01:16:35.890538161+05:30 + resp: + status_code: 200 + header: + Alt-Svc: "" + Connection: keep-alive + Content-Length: "51" + Content-Type: application/json + body: '{"_id":"667b1e9bd71cb97567de07c7","name":"Titanic"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-06-26T01:16:37.940966466+05:30 + objects: [] + assertions: + noise: {} + created: 1719344797 +curl: |- + curl --request POST \ + --url http://127.0.0.1:8000/add_movie \ + --header 'Accept: application/json' \ + --header 'Content-Type: application/json; charset=utf-8' \ + --header 'Host: 127.0.0.1:8000' \ + --header 'User-Agent: curl/7.81.0' \ + --data '{"name": "Titanic"}' diff --git a/sanic-mongo/keploy/test-set-0/tests/test-4.yaml b/sanic-mongo/keploy/test-set-0/tests/test-4.yaml new file mode 100644 index 0000000..f69d270 --- /dev/null +++ b/sanic-mongo/keploy/test-set-0/tests/test-4.yaml @@ -0,0 +1,40 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-4 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://127.0.0.1:8000/movies + header: + Accept: application/json + Content-Type: application/json; charset=utf-8 + Host: 127.0.0.1:8000 + User-Agent: curl/7.81.0 + body: "" + timestamp: 2024-06-26T01:16:42.071382334+05:30 + resp: + status_code: 200 + header: + Alt-Svc: "" + Connection: keep-alive + Content-Length: "211" + Content-Type: application/json + body: '[{"_id":"667b1e6d33a7849da6520cea","name":"Whiplash"},{"_id":"667b1e8fd71cb97567de07c5","name":"Whiplash"},{"_id":"667b1e95d71cb97567de07c6","name":"Chappie"},{"_id":"667b1e9bd71cb97567de07c7","name":"Titanic"}]' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-06-26T01:16:44.167252247+05:30 + objects: [] + assertions: + noise: {} + created: 1719344804 +curl: | + curl --request GET \ + --url http://127.0.0.1:8000/movies \ + --header 'Host: 127.0.0.1:8000' \ + --header 'User-Agent: curl/7.81.0' \ + --header 'Accept: application/json' \ + --header 'Content-Type: application/json; charset=utf-8' \ diff --git a/sanic-mongo/keploy/test-set-0/tests/test-5.yaml b/sanic-mongo/keploy/test-set-0/tests/test-5.yaml new file mode 100644 index 0000000..198d464 --- /dev/null +++ b/sanic-mongo/keploy/test-set-0/tests/test-5.yaml @@ -0,0 +1,38 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-5 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://127.0.0.1:8000/movies + header: + Accept: application/json + Content-Type: application/json; charset=utf-8 + Host: 127.0.0.1:8000 + User-Agent: curl/7.81.0 + body: "" + timestamp: 2024-06-26T01:16:51.200010582+05:30 + resp: + status_code: 204 + header: + Alt-Svc: "" + Connection: keep-alive + body: "" + status_message: No Content + proto_major: 0 + proto_minor: 0 + timestamp: 2024-06-26T01:16:53.208616296+05:30 + objects: [] + assertions: + noise: {} + created: 1719344813 +curl: | + curl --request DELETE \ + --url http://127.0.0.1:8000/movies \ + --header 'Content-Type: application/json; charset=utf-8' \ + --header 'Host: 127.0.0.1:8000' \ + --header 'User-Agent: curl/7.81.0' \ + --header 'Accept: application/json' \ diff --git a/sanic-mongo/requirements.txt b/sanic-mongo/requirements.txt new file mode 100644 index 0000000..04a5484 --- /dev/null +++ b/sanic-mongo/requirements.txt @@ -0,0 +1,3 @@ +pymongo==4.6.3 +sanic==23.12.1 +sanic_motor==0.7.0 \ No newline at end of file diff --git a/sanic-mongo/server.py b/sanic-mongo/server.py new file mode 100644 index 0000000..c05998d --- /dev/null +++ b/sanic-mongo/server.py @@ -0,0 +1,60 @@ +from sanic import Sanic, text +from sanic.response import json as json_response +from sanic.exceptions import NotFound +from sanic_motor import BaseModel +from bson import ObjectId + +app = Sanic(__name__) + +settings = dict( + MOTOR_URI='mongodb://localhost:27017/myapp', LOGO=None +) + +app.config.update(settings) + +BaseModel.init_app(app) + +class Movie(BaseModel): + __coll__ = "movies" + +@app.route("/add_movie", methods=["POST"]) +async def add_movie(request): + movie = request.json + movie["_id"] = str(ObjectId()) + + new_movie = await Movie.insert_one(movie) + created_movie = await Movie.find_one({"_id": new_movie.inserted_id}, as_raw=True) + return json_response(created_movie) + + +@app.route("/movies", methods=["GET"]) +async def list_movies(request): + movies = await Movie.find(as_raw=True) + return json_response(movies.objects) + + + +@app.route("/movies/", methods=["GET"]) +async def get_movie(request, id): + if (movies := await Movie.find_one({"_id": id}, as_raw=True)) is not None: + return json_response(movies) + + raise NotFound(f"Movie {id} not found") + + +@app.route("/movies/", methods=["DELETE"]) +async def delete_movie(request, id): + delete_result = await Movie.delete_one({"_id": id}) + + if delete_result.deleted_count == 1: + return json_response({}, status=204) + + raise NotFound(f"Movie {id} not found") + +@app.route("/movies", methods=["DELETE"]) +async def delete_all_movies(request): + await Movie.delete_many({}) + return json_response({}, status=204) + +if __name__ == "__main__": + app.run(host="127.0.0.1", port=8000, debug=True) \ No newline at end of file diff --git a/sanic-postgres/.env b/sanic-postgres/.env new file mode 100644 index 0000000..151c5cd --- /dev/null +++ b/sanic-postgres/.env @@ -0,0 +1,2 @@ +FLASK_ENV=development +DATABASE_URL=postgresql://myuser:mypassword@localhost:5432/mydatabase diff --git a/sanic-postgres/.gitignore b/sanic-postgres/.gitignore new file mode 100644 index 0000000..43513b1 --- /dev/null +++ b/sanic-postgres/.gitignore @@ -0,0 +1 @@ +myenv/ \ No newline at end of file diff --git a/sanic-postgres/README.md b/sanic-postgres/README.md new file mode 100644 index 0000000..391b4c4 --- /dev/null +++ b/sanic-postgres/README.md @@ -0,0 +1,127 @@ +# Employee Management API + +This application is a simple employee management API built using Python's Sanic framework and PostgreSQL for data storage. It allows you to perform basic CRUD (Create, Read, Update, Delete) operations on employee records. + +## Table of Contents + +- [Introduction](#introduction) +- [Pre-Requisites](#pre-requisites) +- [Installation](#installation) +- [API Endpoints](#api-endpoints) + - [Create Employee](#create-employee) + - [Get All Employees](#get-all-employees) + - [Get Employee by ID](#get-employee-by-id) + - [Update Employee](#update-employee) + - [Delete Employee](#delete-employee) +- [Testing](#testing) +- [Wrapping it up](#wrapping-it-up) + +## Introduction + +🪄 Dive into the world of Employee Management and see how seamlessly Keploy integrated with Sanic and PostgreSQL. Buckle up, it's gonna be a fun ride! 🎢 + +## Pre-Requisites 🛠️ + +Before you begin, ensure you have the following installed: + +- **Python 3.x**: The programming language used for this application. You can download it from [python.org](https://www.python.org/downloads/). +- **PostgreSQL**: The database system used for storing employee data. You can download it from [postgresql.org](https://www.postgresql.org/download/). + +## Installation 📥 + +Once you have the prerequisites set up, follow these steps: + +1. Clone the repository: + + ```bash + git clone https://github.com/keploy/sample-python.git + cd sample-python +Install the required Python packages: + +```bash +pip install -r requirements.txt +``` + +Set up your PostgreSQL database and update the connection settings in your application as needed. + +Install the latest Keploy binary: + +```bash +curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp +sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy +``` +Add alias for Keploy: + +```bash +alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy' +``` +Install the dependencies: + +```bash +pip3 install -r requirements.txt +``` +API Endpoints +Create Employee +To add a new employee: + +```bash +curl -X POST http://localhost:8000/employees \ +-H "Content-Type: application/json" \ +-d '{ + "first_name": "John", + "last_name": "Doe", + "email": "john.doe@example.com", + "position": "Developer", + "salary": 60000 +}' +``` +Get All Employees +To retrieve all employees: + +```bash +curl -X GET http://localhost:8000/employees +``` + +Get Employee by ID +To retrieve a specific employee by ID: + +```bash +curl -X GET http://localhost:8000/employees/1 +``` +Update Employee +To update an existing employee's details: + +```bash +curl -X PUT http://localhost:8000/employees/1 \ +-H "Content-Type: application/json" \ +-d '{ + "first_name": "Jane", + "last_name": "Doe", + "email": "jane.doe@example.com", + "position": "Senior Developer", + "salary": 80000 +}' +``` +Delete Employee +To delete an employee: + +```bash +curl -X DELETE http://localhost:8000/employees/1 +``` +Testing +Capture Test Cases +Capture the test cases using Keploy: + +```bash +keploy record -c "python3 server.py" +``` +Run Tests +Run the tests: + +```bash +keploy test -c "python3 server.py" +``` +Wrapping it up 🎉 +Congrats on the journey so far! You've seen how to manage employees seamlessly with Keploy, Sanic, and PostgreSQL. Keep exploring, innovating, and creating! With the right tools, anything's possible. 😊🚀 + +Happy coding! ✨👩‍💻👨‍💻✨ \ No newline at end of file diff --git a/sanic-postgres/keploy.yml b/sanic-postgres/keploy.yml new file mode 100755 index 0000000..2e0604c --- /dev/null +++ b/sanic-postgres/keploy.yml @@ -0,0 +1,61 @@ +path: "" +appId: 0 +appName: sanic-postgres +command: python3 server.py +templatize: + testSets: [] +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: "" +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + test-sets: {} + delay: 5 + host: "" + port: 0 + apiTimeout: 5 + skipCoverage: false + coverageReportPath: "" + ignoreOrdering: true + mongoPassword: default@123 + language: "" + removeUnusedMocks: false + fallBackOnMiss: false + jacocoAgentPath: "" + basePath: "" + mocking: true + ignoredTests: {} + disableLineCoverage: false + disableMockUpload: true + useLocalMock: false + updateTemplate: false +record: + filters: [] + recordTimer: 0s +configPath: "" +bypassRules: [] +generateGithubActions: false +keployContainer: keploy-v2 +keployNetwork: keploy-network +cmdType: native +contract: + services: [] + tests: [] + path: "" + download: false + generate: false + driven: consumer + mappings: + servicesMapping: {} + self: "" +inCi: false + +# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file. diff --git a/sanic-postgres/keploy/.gitignore b/sanic-postgres/keploy/.gitignore new file mode 100644 index 0000000..5137843 --- /dev/null +++ b/sanic-postgres/keploy/.gitignore @@ -0,0 +1,2 @@ + +/reports/ diff --git a/sanic-postgres/keploy/test-set-0/mocks.yaml b/sanic-postgres/keploy/test-set-0/mocks.yaml new file mode 100755 index 0000000..f6b10d5 --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/mocks.yaml @@ -0,0 +1,1752 @@ +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-0 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.083972836+05:30 + restimestampmock: 2024-11-02T00:24:00.084164389+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-1 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.167614021+05:30 + restimestampmock: 2024-11-02T00:24:00.17718867+05:30 +connectionId: "2" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-2 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.165411429+05:30 + restimestampmock: 2024-11-02T00:24:00.17710596+05:30 +connectionId: "4" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-3 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.177715308+05:30 + restimestampmock: 2024-11-02T00:24:00.18145664+05:30 +connectionId: "8" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-4 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.168265524+05:30 + restimestampmock: 2024-11-02T00:24:00.177743076+05:30 +connectionId: "6" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-5 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.177654462+05:30 + restimestampmock: 2024-11-02T00:24:00.199354838+05:30 +connectionId: "10" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-6 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.177594935+05:30 + restimestampmock: 2024-11-02T00:24:00.199162814+05:30 +connectionId: "12" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-7 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.198469406+05:30 + restimestampmock: 2024-11-02T00:24:00.234040088+05:30 +connectionId: "16" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-8 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.177518008+05:30 + restimestampmock: 2024-11-02T00:24:00.208708798+05:30 +connectionId: "14" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-9 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.19854718+05:30 + restimestampmock: 2024-11-02T00:24:00.223360105+05:30 +connectionId: "18" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-10 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAQQADAABjbGllbnRfZW5jb2RpbmcAJ3V0Zi04JwB1c2VyAG15dXNlcgBkYXRhYmFzZQBteWRhdGFiYXNlAAA= + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 56033 + secret_key: 3037226085 + parameter_status: + - name: in_hot_standby + value: "off" + - name: integer_datetimes + value: "on" + - name: TimeZone + value: Asia/Kolkata + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "off" + - name: application_name + value: "" + - name: default_transaction_read_only + value: "off" + - name: scram_iterations + value: "4096" + - name: DateStyle + value: ISO, MDY + - name: standard_conforming_strings + value: "on" + - name: session_authorization + value: myuser + - name: client_encoding + value: UTF8 + - name: server_version + value: "16.3" + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.103776338+05:30 + restimestampmock: 2024-11-02T00:24:00.103914002+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-11 +spec: + metadata: + type: config + postgresrequests: + - header: [P, D] + identifier: ClientRequest + length: 8 + payload: UAAAAHxfX2FzeW5jcGdfc3RtdF8xX18ASU5TRVJUIElOVE8gZW1wbG95ZWVzIChmaXJzdF9uYW1lLCBsYXN0X25hbWUsIGVtYWlsLCBwb3NpdGlvbiwgc2FsYXJ5KSBWQUxVRVMgKCQxLCAkMiwgJDMsICQ0LCAkNSkAAABEAAAAGFNfX2FzeW5jcGdfc3RtdF8xX18ASAAAAAQ= + describe: + object_type: 83 + name: __asyncpg_stmt_1__ + parse: + - name: __asyncpg_stmt_1__ + query: INSERT INTO employees (first_name, last_name, email, position, salary) VALUES ($1, $2, $3, $4, $5) + parameter_oids: [] + msg_type: 68 + auth_type: 0 + postgresresponses: + - header: ["1", t] + identifier: ServerResponse + length: 8 + payload: MQAAAAR0AAAAGgAFAAAEEwAABBMAAAQTAAAEEwAABqRuAAAABA== + authentication_md5_password: + salt: [0, 0, 0, 0] + parameter_description: + parameteroids: + - 1043 + - 1043 + - 1043 + - 1043 + - 1700 + msg_type: 116 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:11.553896163+05:30 + restimestampmock: 2024-11-02T00:24:11.554038629+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-12 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAHoAX19hc3luY3BnX3N0bXRfMV9fAAAFAAEAAQABAAEAAQAFAAAAA0JvYgAAAAdKb2huc29uAAAAF2JvYi5qb2huc29uQGV4YW1wbGUuY29tAAAAD1Byb2plY3QgTWFuYWdlcgAAAAwAAgABAAAAAAAHE4gAAQABRQAAAAkAAAAAAFMAAAAE + bind: + - prepared_statement: __asyncpg_stmt_1__ + parameter_format_codes: [1, 1, 1, 1, 1] + parameters: [[66, 111, 98], [74, 111, 104, 110, 115, 111, 110], [98, 111, 98, 46, 106, 111, 104, 110, 115, 111, 110, 64, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109], [80, 114, 111, 106, 101, 99, 116, 32, 77, 97, 110, 97, 103, 101, 114], [0, 2, 0, 1, 0, 0, 0, 0, 0, 7, 19, 136]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: INSERT 0 1 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:11.580492915+05:30 + restimestampmock: 2024-11-02T00:24:11.581306226+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-13 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL; + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, C, C, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + - command_tag_type: CLOSE CURSOR ALL + - command_tag_type: UNLISTEN + - command_tag_type: RESET + data_row: [{row_values: [""]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: pg_advisory_unlock_all, table_oid: 0, table_attribute_number: 0, data_type_oid: 2278, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:11.586699965+05:30 + restimestampmock: 2024-11-02T00:24:11.588399417+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-14 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAHsAX19hc3luY3BnX3N0bXRfMV9fAAAFAAEAAQABAAEAAQAFAAAAB0NoYXJsaWUAAAAFQnJvd24AAAAZY2hhcmxpZS5icm93bkBleGFtcGxlLmNvbQAAAAxEYXRhIEFuYWx5c3QAAAAMAAIAAQAAAAAABROIAAEAAUUAAAAJAAAAAABTAAAABA== + bind: + - prepared_statement: __asyncpg_stmt_1__ + parameter_format_codes: [1, 1, 1, 1, 1] + parameters: [[67, 104, 97, 114, 108, 105, 101], [66, 114, 111, 119, 110], [99, 104, 97, 114, 108, 105, 101, 46, 98, 114, 111, 119, 110, 64, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109], [68, 97, 116, 97, 32, 65, 110, 97, 108, 121, 115, 116], [0, 2, 0, 1, 0, 0, 0, 0, 0, 5, 19, 136]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: INSERT 0 1 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:24.631061378+05:30 + restimestampmock: 2024-11-02T00:24:24.631153695+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-15 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL; + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, C, C, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + - command_tag_type: CLOSE CURSOR ALL + - command_tag_type: UNLISTEN + - command_tag_type: RESET + data_row: [{row_values: [""]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: pg_advisory_unlock_all, table_oid: 0, table_attribute_number: 0, data_type_oid: 2278, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:24.634474685+05:30 + restimestampmock: 2024-11-02T00:24:24.634607459+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-16 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAHgAX19hc3luY3BnX3N0bXRfMV9fAAAFAAEAAQABAAEAAQAFAAAABURpYW5hAAAABlByaW5jZQAAABhkaWFuYS5wcmluY2VAZXhhbXBsZS5jb20AAAALVVggRGVzaWduZXIAAAAMAAIAAQAAAAAABwAAAAEAAUUAAAAJAAAAAABTAAAABA== + bind: + - prepared_statement: __asyncpg_stmt_1__ + parameter_format_codes: [1, 1, 1, 1, 1] + parameters: [[68, 105, 97, 110, 97], [80, 114, 105, 110, 99, 101], [100, 105, 97, 110, 97, 46, 112, 114, 105, 110, 99, 101, 64, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109], [85, 88, 32, 68, 101, 115, 105, 103, 110, 101, 114], [0, 2, 0, 1, 0, 0, 0, 0, 0, 7, 0, 0]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: INSERT 0 1 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:34.337791555+05:30 + restimestampmock: 2024-11-02T00:24:34.337858813+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-17 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL; + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, C, C, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + - command_tag_type: CLOSE CURSOR ALL + - command_tag_type: UNLISTEN + - command_tag_type: RESET + data_row: [{row_values: [""]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: pg_advisory_unlock_all, table_oid: 0, table_attribute_number: 0, data_type_oid: 2278, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:34.341253861+05:30 + restimestampmock: 2024-11-02T00:24:34.341390263+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-18 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAH4AX19hc3luY3BnX3N0bXRfMV9fAAAFAAEAAQABAAEAAQAFAAAABUV0aGFuAAAABEh1bnQAAAAWZXRoYW4uaHVudEBleGFtcGxlLmNvbQAAABVOZXR3b3JrIEFkbWluaXN0cmF0b3IAAAAMAAIAAQAAAAAABgAAAAEAAUUAAAAJAAAAAABTAAAABA== + bind: + - prepared_statement: __asyncpg_stmt_1__ + parameter_format_codes: [1, 1, 1, 1, 1] + parameters: [[69, 116, 104, 97, 110], [72, 117, 110, 116], [101, 116, 104, 97, 110, 46, 104, 117, 110, 116, 64, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109], [78, 101, 116, 119, 111, 114, 107, 32, 65, 100, 109, 105, 110, 105, 115, 116, 114, 97, 116, 111, 114], [0, 2, 0, 1, 0, 0, 0, 0, 0, 6, 0, 0]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: INSERT 0 1 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:41.07876865+05:30 + restimestampmock: 2024-11-02T00:24:41.078836668+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-19 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL; + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, C, C, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + - command_tag_type: CLOSE CURSOR ALL + - command_tag_type: UNLISTEN + - command_tag_type: RESET + data_row: [{row_values: [""]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: pg_advisory_unlock_all, table_oid: 0, table_attribute_number: 0, data_type_oid: 2278, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:41.08021433+05:30 + restimestampmock: 2024-11-02T00:24:41.08029966+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-20 +spec: + metadata: + type: config + postgresrequests: + - header: [P, D] + identifier: ClientRequest + length: 8 + payload: UAAAAPZfX2FzeW5jcGdfc3RtdF8yX18ACiAgICAgICAgICAgIFVQREFURSBlbXBsb3llZXMKICAgICAgICAgICAgU0VUIGZpcnN0X25hbWUgPSAkMSwKICAgICAgICAgICAgICAgIGxhc3RfbmFtZSA9ICQyLAogICAgICAgICAgICAgICAgZW1haWwgPSAkMywKICAgICAgICAgICAgICAgIHBvc2l0aW9uID0gJDQsCiAgICAgICAgICAgICAgICBzYWxhcnkgPSAkNQogICAgICAgICAgICBXSEVSRSBpZCA9ICQ2CiAgICAgICAgICAgIAAAAEQAAAAYU19fYXN5bmNwZ19zdG10XzJfXwBIAAAABA== + describe: + object_type: 83 + name: __asyncpg_stmt_2__ + parse: + - name: __asyncpg_stmt_2__ + query: ' UPDATE employees SET first_name = $1, last_name = $2, email = $3, position = $4, salary = $5 WHERE id = $6 ' + parameter_oids: [] + msg_type: 68 + auth_type: 0 + postgresresponses: + - header: ["1", t] + identifier: ServerResponse + length: 8 + payload: MQAAAAR0AAAAHgAGAAAEEwAABBMAAAQTAAAEEwAABqQAAAAXbgAAAAQ= + authentication_md5_password: + salt: [0, 0, 0, 0] + parameter_description: + parameteroids: + - 1043 + - 1043 + - 1043 + - 1043 + - 1700 + - 23 + msg_type: 116 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:25:47.4085832+05:30 + restimestampmock: 2024-11-02T00:25:47.415893588+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-21 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAIoAX19hc3luY3BnX3N0bXRfMl9fAAAGAAEAAQABAAEAAQABAAYAAAAFRnJhbmsAAAAGQ2FzdGxlAAAAGGZyYW5rLmNhc3RsZUBleGFtcGxlLmNvbQAAABNTZWN1cml0eSBTcGVjaWFsaXN0AAAADAACAAEAAAAAAAgAAAAAAAQAAAABAAEAAUUAAAAJAAAAAABTAAAABA== + bind: + - prepared_statement: __asyncpg_stmt_2__ + parameter_format_codes: [1, 1, 1, 1, 1, 1] + parameters: [[70, 114, 97, 110, 107], [67, 97, 115, 116, 108, 101], [102, 114, 97, 110, 107, 46, 99, 97, 115, 116, 108, 101, 64, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109], [83, 101, 99, 117, 114, 105, 116, 121, 32, 83, 112, 101, 99, 105, 97, 108, 105, 115, 116], [0, 2, 0, 1, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 1]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: UPDATE 0 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:25:47.460065945+05:30 + restimestampmock: 2024-11-02T00:25:47.460193217+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-22 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL; + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, C, C, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + - command_tag_type: CLOSE CURSOR ALL + - command_tag_type: UNLISTEN + - command_tag_type: RESET + data_row: [{row_values: [""]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: pg_advisory_unlock_all, table_oid: 0, table_attribute_number: 0, data_type_oid: 2278, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:25:47.463869372+05:30 + restimestampmock: 2024-11-02T00:25:47.463997714+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-23 +spec: + metadata: + type: config + postgresrequests: + - header: [P, D] + identifier: ClientRequest + length: 8 + payload: UAAAAD9fX2FzeW5jcGdfc3RtdF8zX18AU0VMRUNUICogRlJPTSBlbXBsb3llZXMgV0hFUkUgaWQgPSAkMQAAAEQAAAAYU19fYXN5bmNwZ19zdG10XzNfXwBIAAAABA== + describe: + object_type: 83 + name: __asyncpg_stmt_3__ + parse: + - name: __asyncpg_stmt_3__ + query: SELECT * FROM employees WHERE id = $1 + parameter_oids: [] + msg_type: 68 + auth_type: 0 + postgresresponses: + - header: ["1", t, T] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + parameter_description: + parameteroids: + - 23 + row_description: {fields: [{field_name: id, table_oid: 16386, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {field_name: first_name, table_oid: 16386, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: 54, format: 0}, {field_name: last_name, table_oid: 16386, table_attribute_number: 3, data_type_oid: 1043, data_type_size: -1, type_modifier: 54, format: 0}, {field_name: email, table_oid: 16386, table_attribute_number: 4, data_type_oid: 1043, data_type_size: -1, type_modifier: 104, format: 0}, {field_name: position, table_oid: 16386, table_attribute_number: 5, data_type_oid: 1043, data_type_size: -1, type_modifier: 54, format: 0}, {field_name: salary, table_oid: 16386, table_attribute_number: 6, data_type_oid: 1700, data_type_size: -1, type_modifier: 655366, format: 0}, {field_name: date_hired, table_oid: 16386, table_attribute_number: 7, data_type_oid: 1082, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 84 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:25:57.958411237+05:30 + restimestampmock: 2024-11-02T00:25:57.958479842+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-24 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAACoAX19hc3luY3BnX3N0bXRfM19fAAABAAEAAQAAAAQAAAABAAEAAUUAAAAJAAAAAAFTAAAABA== + bind: + - prepared_statement: __asyncpg_stmt_3__ + parameter_format_codes: [1] + parameters: [[0, 0, 0, 1]] + result_format_codes: [1] + execute: + - max_rows: 1 + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 0 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:25:57.964307531+05:30 + restimestampmock: 2024-11-02T00:25:57.964414402+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-25 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL; + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, C, C, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + - command_tag_type: CLOSE CURSOR ALL + - command_tag_type: UNLISTEN + - command_tag_type: RESET + data_row: [{row_values: [""]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: pg_advisory_unlock_all, table_oid: 0, table_attribute_number: 0, data_type_oid: 2278, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:25:57.967177613+05:30 + restimestampmock: 2024-11-02T00:25:57.967355116+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-26 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAACoAX19hc3luY3BnX3N0bXRfM19fAAABAAEAAQAAAAQAAAADAAEAAUUAAAAJAAAAAAFTAAAABA== + bind: + - prepared_statement: __asyncpg_stmt_3__ + parameter_format_codes: [1] + parameters: [[0, 0, 0, 3]] + result_format_codes: [1] + execute: + - max_rows: 1 + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 0 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:26:02.277859505+05:30 + restimestampmock: 2024-11-02T00:26:02.278156136+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-27 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL; + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, C, C, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + - command_tag_type: CLOSE CURSOR ALL + - command_tag_type: UNLISTEN + - command_tag_type: RESET + data_row: [{row_values: [""]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: pg_advisory_unlock_all, table_oid: 0, table_attribute_number: 0, data_type_oid: 2278, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:26:02.281179011+05:30 + restimestampmock: 2024-11-02T00:26:02.281388742+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-28 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAACoAX19hc3luY3BnX3N0bXRfM19fAAABAAEAAQAAAAQAAAACAAEAAUUAAAAJAAAAAAFTAAAABA== + bind: + - prepared_statement: __asyncpg_stmt_3__ + parameter_format_codes: [1] + parameters: [[0, 0, 0, 2]] + result_format_codes: [1] + execute: + - max_rows: 1 + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", D, s, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + data_row: [{row_values: ['b64:AAAAAg==', Dhruv, slashexx, slashexx@example.com, Developer, 'b64:AAEAAQAAAAIABg==', 'b64:AAAjbw==']}] + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:26:04.963927809+05:30 + restimestampmock: 2024-11-02T00:26:04.965198376+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-29 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL; + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, C, C, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + - command_tag_type: CLOSE CURSOR ALL + - command_tag_type: UNLISTEN + - command_tag_type: RESET + data_row: [{row_values: [""]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: pg_advisory_unlock_all, table_oid: 0, table_attribute_number: 0, data_type_oid: 2278, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:26:04.970818229+05:30 + restimestampmock: 2024-11-02T00:26:04.971874274+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-30 +spec: + metadata: + type: config + postgresrequests: + - header: [P, D] + identifier: ClientRequest + length: 8 + payload: UAAAADtfX2FzeW5jcGdfc3RtdF80X18AREVMRVRFIEZST00gZW1wbG95ZWVzIFdIRVJFIGlkPSQxAAAARAAAABhTX19hc3luY3BnX3N0bXRfNF9fAEgAAAAE + describe: + object_type: 83 + name: __asyncpg_stmt_4__ + parse: + - name: __asyncpg_stmt_4__ + query: DELETE FROM employees WHERE id=$1 + parameter_oids: [] + msg_type: 68 + auth_type: 0 + postgresresponses: + - header: ["1", t] + identifier: ServerResponse + length: 8 + payload: MQAAAAR0AAAACgABAAAAF24AAAAE + authentication_md5_password: + salt: [0, 0, 0, 0] + parameter_description: + parameteroids: + - 23 + msg_type: 116 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:26:18.473156914+05:30 + restimestampmock: 2024-11-02T00:26:18.47327845+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-31 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAACoAX19hc3luY3BnX3N0bXRfNF9fAAABAAEAAQAAAAQAAAAFAAEAAUUAAAAJAAAAAABTAAAABA== + bind: + - prepared_statement: __asyncpg_stmt_4__ + parameter_format_codes: [1] + parameters: [[0, 0, 0, 5]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: DELETE 0 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:26:18.479261843+05:30 + restimestampmock: 2024-11-02T00:26:18.479381902+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-32 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL; + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, C, C, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + - command_tag_type: CLOSE CURSOR ALL + - command_tag_type: UNLISTEN + - command_tag_type: RESET + data_row: [{row_values: [""]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: pg_advisory_unlock_all, table_oid: 0, table_attribute_number: 0, data_type_oid: 2278, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:26:18.48461228+05:30 + restimestampmock: 2024-11-02T00:26:18.484716818+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-33 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAACoAX19hc3luY3BnX3N0bXRfNF9fAAABAAEAAQAAAAQAAAAIAAEAAUUAAAAJAAAAAABTAAAABA== + bind: + - prepared_statement: __asyncpg_stmt_4__ + parameter_format_codes: [1] + parameters: [[0, 0, 0, 8]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: DELETE 0 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:26:42.826314398+05:30 + restimestampmock: 2024-11-02T00:26:42.826364365+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-34 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL; + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, C, C, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + - command_tag_type: CLOSE CURSOR ALL + - command_tag_type: UNLISTEN + - command_tag_type: RESET + data_row: [{row_values: [""]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: pg_advisory_unlock_all, table_oid: 0, table_attribute_number: 0, data_type_oid: 2278, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:26:42.829870394+05:30 + restimestampmock: 2024-11-02T00:26:42.829976758+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-35 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAACoAX19hc3luY3BnX3N0bXRfNF9fAAABAAEAAQAAAAQAAAACAAEAAUUAAAAJAAAAAABTAAAABA== + bind: + - prepared_statement: __asyncpg_stmt_4__ + parameter_format_codes: [1] + parameters: [[0, 0, 0, 2]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: DELETE 1 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:26:45.439361257+05:30 + restimestampmock: 2024-11-02T00:26:45.439457915+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-36 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAQQADAABjbGllbnRfZW5jb2RpbmcAJ3V0Zi04JwB1c2VyAG15dXNlcgBkYXRhYmFzZQBteWRhdGFiYXNlAAA= + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 56036 + secret_key: 2072059547 + parameter_status: + - name: in_hot_standby + value: "off" + - name: integer_datetimes + value: "on" + - name: TimeZone + value: Asia/Kolkata + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "off" + - name: application_name + value: "" + - name: default_transaction_read_only + value: "off" + - name: scram_iterations + value: "4096" + - name: DateStyle + value: ISO, MDY + - name: standard_conforming_strings + value: "on" + - name: session_authorization + value: myuser + - name: client_encoding + value: UTF8 + - name: server_version + value: "16.3" + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.198788779+05:30 + restimestampmock: 2024-11-02T00:24:00.206849467+05:30 +connectionId: "4" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-37 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAQQADAABjbGllbnRfZW5jb2RpbmcAJ3V0Zi04JwB1c2VyAG15dXNlcgBkYXRhYmFzZQBteWRhdGFiYXNlAAA= + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 56042 + secret_key: 1801189782 + parameter_status: + - name: in_hot_standby + value: "off" + - name: integer_datetimes + value: "on" + - name: TimeZone + value: Asia/Kolkata + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "off" + - name: application_name + value: "" + - name: default_transaction_read_only + value: "off" + - name: scram_iterations + value: "4096" + - name: DateStyle + value: ISO, MDY + - name: standard_conforming_strings + value: "on" + - name: session_authorization + value: myuser + - name: client_encoding + value: UTF8 + - name: server_version + value: "16.3" + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.234047956+05:30 + restimestampmock: 2024-11-02T00:24:00.234128761+05:30 +connectionId: "10" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-38 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAQQADAABjbGllbnRfZW5jb2RpbmcAJ3V0Zi04JwB1c2VyAG15dXNlcgBkYXRhYmFzZQBteWRhdGFiYXNlAAA= + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 56043 + secret_key: 620349829 + parameter_status: + - name: in_hot_standby + value: "off" + - name: integer_datetimes + value: "on" + - name: TimeZone + value: Asia/Kolkata + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "off" + - name: application_name + value: "" + - name: default_transaction_read_only + value: "off" + - name: scram_iterations + value: "4096" + - name: DateStyle + value: ISO, MDY + - name: standard_conforming_strings + value: "on" + - name: session_authorization + value: myuser + - name: client_encoding + value: UTF8 + - name: server_version + value: "16.3" + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.223511405+05:30 + restimestampmock: 2024-11-02T00:24:00.223563224+05:30 +connectionId: "12" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-39 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAQQADAABjbGllbnRfZW5jb2RpbmcAJ3V0Zi04JwB1c2VyAG15dXNlcgBkYXRhYmFzZQBteWRhdGFiYXNlAAA= + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 56044 + secret_key: 3570427540 + parameter_status: + - name: in_hot_standby + value: "off" + - name: integer_datetimes + value: "on" + - name: TimeZone + value: Asia/Kolkata + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "off" + - name: application_name + value: "" + - name: default_transaction_read_only + value: "off" + - name: scram_iterations + value: "4096" + - name: DateStyle + value: ISO, MDY + - name: standard_conforming_strings + value: "on" + - name: session_authorization + value: myuser + - name: client_encoding + value: UTF8 + - name: server_version + value: "16.3" + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.246393386+05:30 + restimestampmock: 2024-11-02T00:24:00.246505351+05:30 +connectionId: "14" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-40 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL; + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, C, C, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + - command_tag_type: CLOSE CURSOR ALL + - command_tag_type: UNLISTEN + - command_tag_type: RESET + data_row: [{row_values: [""]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: pg_advisory_unlock_all, table_oid: 0, table_attribute_number: 0, data_type_oid: 2278, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:26:45.440448264+05:30 + restimestampmock: 2024-11-02T00:26:45.440621975+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-41 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAQQADAABjbGllbnRfZW5jb2RpbmcAJ3V0Zi04JwB1c2VyAG15dXNlcgBkYXRhYmFzZQBteWRhdGFiYXNlAAA= + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 56046 + secret_key: 3378630764 + parameter_status: + - name: in_hot_standby + value: "off" + - name: integer_datetimes + value: "on" + - name: TimeZone + value: Asia/Kolkata + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "off" + - name: application_name + value: "" + - name: default_transaction_read_only + value: "off" + - name: scram_iterations + value: "4096" + - name: DateStyle + value: ISO, MDY + - name: standard_conforming_strings + value: "on" + - name: session_authorization + value: myuser + - name: client_encoding + value: UTF8 + - name: server_version + value: "16.3" + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.254902613+05:30 + restimestampmock: 2024-11-02T00:24:00.255027369+05:30 +connectionId: "16" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-42 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAQQADAABjbGllbnRfZW5jb2RpbmcAJ3V0Zi04JwB1c2VyAG15dXNlcgBkYXRhYmFzZQBteWRhdGFiYXNlAAA= + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 56045 + secret_key: 3087317218 + parameter_status: + - name: in_hot_standby + value: "off" + - name: integer_datetimes + value: "on" + - name: TimeZone + value: Asia/Kolkata + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "off" + - name: application_name + value: "" + - name: default_transaction_read_only + value: "off" + - name: scram_iterations + value: "4096" + - name: DateStyle + value: ISO, MDY + - name: standard_conforming_strings + value: "on" + - name: session_authorization + value: myuser + - name: client_encoding + value: UTF8 + - name: server_version + value: "16.3" + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.251125068+05:30 + restimestampmock: 2024-11-02T00:24:00.25123582+05:30 +connectionId: "18" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-43 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAQQADAABjbGllbnRfZW5jb2RpbmcAJ3V0Zi04JwB1c2VyAG15dXNlcgBkYXRhYmFzZQBteWRhdGFiYXNlAAA= + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 56037 + secret_key: 3109363849 + parameter_status: + - name: in_hot_standby + value: "off" + - name: integer_datetimes + value: "on" + - name: TimeZone + value: Asia/Kolkata + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "off" + - name: application_name + value: "" + - name: default_transaction_read_only + value: "off" + - name: scram_iterations + value: "4096" + - name: DateStyle + value: ISO, MDY + - name: standard_conforming_strings + value: "on" + - name: session_authorization + value: myuser + - name: client_encoding + value: UTF8 + - name: server_version + value: "16.3" + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.22321499+05:30 + restimestampmock: 2024-11-02T00:24:00.223318321+05:30 +connectionId: "6" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-44 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAQQADAABjbGllbnRfZW5jb2RpbmcAJ3V0Zi04JwB1c2VyAG15dXNlcgBkYXRhYmFzZQBteWRhdGFiYXNlAAA= + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 56035 + secret_key: 3366720961 + parameter_status: + - name: in_hot_standby + value: "off" + - name: integer_datetimes + value: "on" + - name: TimeZone + value: Asia/Kolkata + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "off" + - name: application_name + value: "" + - name: default_transaction_read_only + value: "off" + - name: scram_iterations + value: "4096" + - name: DateStyle + value: ISO, MDY + - name: standard_conforming_strings + value: "on" + - name: session_authorization + value: myuser + - name: client_encoding + value: UTF8 + - name: server_version + value: "16.3" + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.199235016+05:30 + restimestampmock: 2024-11-02T00:24:00.199320268+05:30 +connectionId: "2" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-45 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAQQADAABjbGllbnRfZW5jb2RpbmcAJ3V0Zi04JwB1c2VyAG15dXNlcgBkYXRhYmFzZQBteWRhdGFiYXNlAAA= + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 56038 + secret_key: 2167216798 + parameter_status: + - name: in_hot_standby + value: "off" + - name: integer_datetimes + value: "on" + - name: TimeZone + value: Asia/Kolkata + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "off" + - name: application_name + value: "" + - name: default_transaction_read_only + value: "off" + - name: scram_iterations + value: "4096" + - name: DateStyle + value: ISO, MDY + - name: standard_conforming_strings + value: "on" + - name: session_authorization + value: myuser + - name: client_encoding + value: UTF8 + - name: server_version + value: "16.3" + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + - name: server_encoding + value: UTF8 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-11-02T00:24:00.223405003+05:30 + restimestampmock: 2024-11-02T00:24:00.22346753+05:30 +connectionId: "8" diff --git a/sanic-postgres/keploy/test-set-0/tests/test-1.yaml b/sanic-postgres/keploy/test-set-0/tests/test-1.yaml new file mode 100755 index 0000000..cafa157 --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/tests/test-1.yaml @@ -0,0 +1,48 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/employees + header: + Accept: '*/*' + Content-Length: "151" + Content-Type: application/json + Host: localhost:8000 + User-Agent: curl/8.10.1 + body: |- + { + "first_name": "Bob", + "last_name": "Johnson", + "email": "bob.johnson@example.com", + "position": "Project Manager", + "salary": 75000 + } + timestamp: 2024-11-02T00:24:11.530933247+05:30 + resp: + status_code: 201 + header: + Connection: keep-alive + Content-Length: "27" + Content-Type: application/json + body: '{"status":"Employee added"}' + status_message: Created + proto_major: 0 + proto_minor: 0 + timestamp: 2024-11-02T00:24:13.635103945+05:30 + objects: [] + assertions: + noise: {} + created: 1730487253 +curl: |- + curl --request POST \ + --url http://localhost:8000/employees \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/8.10.1' \ + --header 'Accept: */*' \ + --header 'Content-Type: application/json' \ + --data "{\n \"first_name\": \"Bob\",\n \"last_name\": \"Johnson\",\n \"email\": \"bob.johnson@example.com\",\n \"position\": \"Project Manager\",\n \"salary\": 75000\n}" diff --git a/sanic-postgres/keploy/test-set-0/tests/test-10.yaml b/sanic-postgres/keploy/test-set-0/tests/test-10.yaml new file mode 100755 index 0000000..72fe3cb --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/tests/test-10.yaml @@ -0,0 +1,37 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-10 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/employees/8 + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/8.10.1 + body: "" + timestamp: 2024-11-02T00:26:42.824245581+05:30 + resp: + status_code: 404 + header: + Connection: keep-alive + Content-Length: "31" + Content-Type: application/json + body: '{"status":"Employee not found"}' + status_message: Not Found + proto_major: 0 + proto_minor: 0 + timestamp: 2024-11-02T00:26:44.916426565+05:30 + objects: [] + assertions: + noise: {} + created: 1730487404 +curl: | + curl --request DELETE \ + --url http://localhost:8000/employees/8 \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/8.10.1' \ + --header 'Accept: */*' \ diff --git a/sanic-postgres/keploy/test-set-0/tests/test-11.yaml b/sanic-postgres/keploy/test-set-0/tests/test-11.yaml new file mode 100755 index 0000000..c601433 --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/tests/test-11.yaml @@ -0,0 +1,37 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-11 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/employees/2 + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/8.10.1 + body: "" + timestamp: 2024-11-02T00:26:45.433382637+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "29" + Content-Type: application/json + body: '{"status":"Employee deleted"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-11-02T00:26:47.530880511+05:30 + objects: [] + assertions: + noise: {} + created: 1730487407 +curl: | + curl --request DELETE \ + --url http://localhost:8000/employees/2 \ + --header 'User-Agent: curl/8.10.1' \ + --header 'Accept: */*' \ + --header 'Host: localhost:8000' \ diff --git a/sanic-postgres/keploy/test-set-0/tests/test-2.yaml b/sanic-postgres/keploy/test-set-0/tests/test-2.yaml new file mode 100755 index 0000000..6e02f3d --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/tests/test-2.yaml @@ -0,0 +1,48 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-2 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/employees + header: + Accept: '*/*' + Content-Length: "152" + Content-Type: application/json + Host: localhost:8000 + User-Agent: curl/8.10.1 + body: |- + { + "first_name": "Charlie", + "last_name": "Brown", + "email": "charlie.brown@example.com", + "position": "Data Analyst", + "salary": 55000 + } + timestamp: 2024-11-02T00:24:24.621246547+05:30 + resp: + status_code: 201 + header: + Connection: keep-alive + Content-Length: "27" + Content-Type: application/json + body: '{"status":"Employee added"}' + status_message: Created + proto_major: 0 + proto_minor: 0 + timestamp: 2024-11-02T00:24:26.732572815+05:30 + objects: [] + assertions: + noise: {} + created: 1730487266 +curl: |- + curl --request POST \ + --url http://localhost:8000/employees \ + --header 'Accept: */*' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/8.10.1' \ + --data "{\n \"first_name\": \"Charlie\",\n \"last_name\": \"Brown\",\n \"email\": \"charlie.brown@example.com\",\n \"position\": \"Data Analyst\",\n \"salary\": 55000\n}" diff --git a/sanic-postgres/keploy/test-set-0/tests/test-3.yaml b/sanic-postgres/keploy/test-set-0/tests/test-3.yaml new file mode 100755 index 0000000..be9e26f --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/tests/test-3.yaml @@ -0,0 +1,48 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-3 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/employees + header: + Accept: '*/*' + Content-Length: "149" + Content-Type: application/json + Host: localhost:8000 + User-Agent: curl/8.10.1 + body: |- + { + "first_name": "Diana", + "last_name": "Prince", + "email": "diana.prince@example.com", + "position": "UX Designer", + "salary": 70000 + } + timestamp: 2024-11-02T00:24:34.32675721+05:30 + resp: + status_code: 201 + header: + Connection: keep-alive + Content-Length: "27" + Content-Type: application/json + body: '{"status":"Employee added"}' + status_message: Created + proto_major: 0 + proto_minor: 0 + timestamp: 2024-11-02T00:24:36.388946121+05:30 + objects: [] + assertions: + noise: {} + created: 1730487276 +curl: |- + curl --request POST \ + --url http://localhost:8000/employees \ + --header 'User-Agent: curl/8.10.1' \ + --header 'Accept: */*' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:8000' \ + --data "{\n \"first_name\": \"Diana\",\n \"last_name\": \"Prince\",\n \"email\": \"diana.prince@example.com\",\n \"position\": \"UX Designer\",\n \"salary\": 70000\n}" diff --git a/sanic-postgres/keploy/test-set-0/tests/test-4.yaml b/sanic-postgres/keploy/test-set-0/tests/test-4.yaml new file mode 100755 index 0000000..90d4570 --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/tests/test-4.yaml @@ -0,0 +1,48 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-4 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/employees + header: + Accept: '*/*' + Content-Length: "155" + Content-Type: application/json + Host: localhost:8000 + User-Agent: curl/8.10.1 + body: |- + { + "first_name": "Ethan", + "last_name": "Hunt", + "email": "ethan.hunt@example.com", + "position": "Network Administrator", + "salary": 60000 + } + timestamp: 2024-11-02T00:24:41.068808434+05:30 + resp: + status_code: 201 + header: + Connection: keep-alive + Content-Length: "27" + Content-Type: application/json + body: '{"status":"Employee added"}' + status_message: Created + proto_major: 0 + proto_minor: 0 + timestamp: 2024-11-02T00:24:43.124788378+05:30 + objects: [] + assertions: + noise: {} + created: 1730487283 +curl: |- + curl --request POST \ + --url http://localhost:8000/employees \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/8.10.1' \ + --header 'Accept: */*' \ + --header 'Content-Type: application/json' \ + --data "{\n \"first_name\": \"Ethan\",\n \"last_name\": \"Hunt\",\n \"email\": \"ethan.hunt@example.com\",\n \"position\": \"Network Administrator\",\n \"salary\": 60000\n}" diff --git a/sanic-postgres/keploy/test-set-0/tests/test-5.yaml b/sanic-postgres/keploy/test-set-0/tests/test-5.yaml new file mode 100755 index 0000000..441d38f --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/tests/test-5.yaml @@ -0,0 +1,48 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-5 +spec: + metadata: {} + req: + method: PUT + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/employees/1 + header: + Accept: '*/*' + Content-Length: "157" + Content-Type: application/json + Host: localhost:8000 + User-Agent: curl/8.10.1 + body: |- + { + "first_name": "Frank", + "last_name": "Castle", + "email": "frank.castle@example.com", + "position": "Security Specialist", + "salary": 80000 + } + timestamp: 2024-11-02T00:25:47.343116345+05:30 + resp: + status_code: 404 + header: + Connection: keep-alive + Content-Length: "31" + Content-Type: application/json + body: '{"status":"Employee not found"}' + status_message: Not Found + proto_major: 0 + proto_minor: 0 + timestamp: 2024-11-02T00:25:49.52236244+05:30 + objects: [] + assertions: + noise: {} + created: 1730487349 +curl: |- + curl --request PUT \ + --url http://localhost:8000/employees/1 \ + --header 'User-Agent: curl/8.10.1' \ + --header 'Accept: */*' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:8000' \ + --data "{\n \"first_name\": \"Frank\",\n \"last_name\": \"Castle\",\n \"email\": \"frank.castle@example.com\",\n \"position\": \"Security Specialist\",\n \"salary\": 80000\n}" diff --git a/sanic-postgres/keploy/test-set-0/tests/test-6.yaml b/sanic-postgres/keploy/test-set-0/tests/test-6.yaml new file mode 100755 index 0000000..acd2791 --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/tests/test-6.yaml @@ -0,0 +1,37 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-6 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/employees/1 + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/8.10.1 + body: "" + timestamp: 2024-11-02T00:25:57.955879435+05:30 + resp: + status_code: 404 + header: + Connection: keep-alive + Content-Length: "31" + Content-Type: application/json + body: '{"status":"Employee not found"}' + status_message: Not Found + proto_major: 0 + proto_minor: 0 + timestamp: 2024-11-02T00:25:59.977751505+05:30 + objects: [] + assertions: + noise: {} + created: 1730487359 +curl: | + curl --request GET \ + --url http://localhost:8000/employees/1 \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/8.10.1' \ + --header 'Accept: */*' \ diff --git a/sanic-postgres/keploy/test-set-0/tests/test-7.yaml b/sanic-postgres/keploy/test-set-0/tests/test-7.yaml new file mode 100755 index 0000000..3fff7c8 --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/tests/test-7.yaml @@ -0,0 +1,37 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-7 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/employees/3 + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/8.10.1 + body: "" + timestamp: 2024-11-02T00:26:02.274891841+05:30 + resp: + status_code: 404 + header: + Connection: keep-alive + Content-Length: "31" + Content-Type: application/json + body: '{"status":"Employee not found"}' + status_message: Not Found + proto_major: 0 + proto_minor: 0 + timestamp: 2024-11-02T00:26:04.302597857+05:30 + objects: [] + assertions: + noise: {} + created: 1730487364 +curl: | + curl --request GET \ + --url http://localhost:8000/employees/3 \ + --header 'Accept: */*' \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/8.10.1' \ diff --git a/sanic-postgres/keploy/test-set-0/tests/test-8.yaml b/sanic-postgres/keploy/test-set-0/tests/test-8.yaml new file mode 100755 index 0000000..7d23d7f --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/tests/test-8.yaml @@ -0,0 +1,38 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-8 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/employees/2 + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/8.10.1 + body: "" + timestamp: 2024-11-02T00:26:04.960388094+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "162" + Content-Type: application/json + body: '{"employee":{"id":2,"first_name":"Dhruv","last_name":"slashexx","email":"slashexx@example.com","position":"Developer","salary":60000.0,"date_hired":"2024-11-01"}}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-11-02T00:26:07.014944126+05:30 + objects: [] + assertions: + noise: + body.employee.date_hired: [] + created: 1730487367 +curl: | + curl --request GET \ + --url http://localhost:8000/employees/2 \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/8.10.1' \ + --header 'Accept: */*' \ diff --git a/sanic-postgres/keploy/test-set-0/tests/test-9.yaml b/sanic-postgres/keploy/test-set-0/tests/test-9.yaml new file mode 100755 index 0000000..28f8605 --- /dev/null +++ b/sanic-postgres/keploy/test-set-0/tests/test-9.yaml @@ -0,0 +1,37 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-9 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/employees/5 + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/8.10.1 + body: "" + timestamp: 2024-11-02T00:26:18.470028007+05:30 + resp: + status_code: 404 + header: + Connection: keep-alive + Content-Length: "31" + Content-Type: application/json + body: '{"status":"Employee not found"}' + status_message: Not Found + proto_major: 0 + proto_minor: 0 + timestamp: 2024-11-02T00:26:20.586858053+05:30 + objects: [] + assertions: + noise: {} + created: 1730487380 +curl: | + curl --request DELETE \ + --url http://localhost:8000/employees/5 \ + --header 'User-Agent: curl/8.10.1' \ + --header 'Accept: */*' \ + --header 'Host: localhost:8000' \ diff --git a/sanic-postgres/requirements.txt b/sanic-postgres/requirements.txt new file mode 100644 index 0000000..7543908 --- /dev/null +++ b/sanic-postgres/requirements.txt @@ -0,0 +1,43 @@ +attrs==23.2.1.dev0 +autocommand==2.2.2 +beautifulsoup4==4.12.3 +cffi==1.16.0 +charset-normalizer==3.3.2 +configobj==5.0.8 +cryptography==42.0.7 +dbus-python==1.3.2 +fastjsonschema==2.20.0 +filelock==3.13.3 +httplib2==0.22.0 +idna==3.8 +jaraco.context==5.3.0 +jaraco.functools==4.0.2 +jaraco.text==4.0.0 +libtorrent==2.0.10 +lxml==5.3.0 +Mako==1.3.5.dev0 +Markdown==3.7 +MarkupSafe==2.1.5 +more-itertools==10.3.0 +ordered-set==4.1.0 +packaging==24.1 +pillow==10.4.0 +platformdirs==4.3.6 +pwquality==1.4.5 +pycairo==1.27.0 +pycparser==2.22 +pycurl==7.45.3 +PyGObject==3.50.0 +pyparsing==3.1.2 +Reflector==2023.6.28.0.36.1 +requests==2.32.3 +setuptools==69.5.1 +six==1.16.0 +soupsieve==2.6 +tomli==2.0.1 +trove-classifiers==2024.10.21.16 +urllib3==1.26.20 +validate==5.0.8 +validate-pyproject==0.21 +variety==0.8.12 +wheel==0.44.0 diff --git a/sanic-postgres/server.py b/sanic-postgres/server.py new file mode 100644 index 0000000..b28eb6f --- /dev/null +++ b/sanic-postgres/server.py @@ -0,0 +1,123 @@ +from sanic import Sanic, response +from asyncpg import create_pool +import os +from dotenv import load_dotenv + +app = Sanic("EmployeeManagementApp") + +load_dotenv() +DB_URL = os.getenv("DATABASE_URL") + +DB_CONFIG = { + "dsn": DB_URL, +} + +@app.listener("before_server_start") +async def setup_db(app, loop): + app.ctx.db_pool = await create_pool(**DB_CONFIG, loop=loop) + +@app.listener("after_server_stop") +async def close_db(app, loop): + await app.ctx.db_pool.close() + +@app.route("/employees", methods=["POST"]) +async def add_employee(request): + data = request.json + async with app.ctx.db_pool.acquire() as connection: + await connection.execute( + "INSERT INTO employees (first_name, last_name, email, position, salary) VALUES ($1, $2, $3, $4, $5)", + data["first_name"], data["last_name"], data["email"], data["position"], data["salary"] + ) + return response.json({"status": "Employee added"}, status=201) + +@app.route("/employees", methods=["GET"]) +async def get_employees(request): + async with app.ctx.db_pool.acquire() as connection: + rows = await connection.fetch("SELECT * FROM employees") + employees = [{"id": row["id"], "first_name": row["first_name"], "last_name": row["last_name"], + "email": row["email"], "position": row["position"], "salary": row["salary"], + "date_hired": row["date_hired"].isoformat()} for row in rows] + return response.json({"employees": employees}) + +@app.route("/employees/", methods=["GET"]) +async def get_employee(request, employee_id): + try: + employee_id = int(employee_id) + except ValueError: + return response.json({"status": "Invalid employee ID"}, status=400) + + async with app.ctx.db_pool.acquire() as connection: + row = await connection.fetchrow("SELECT * FROM employees WHERE id = $1", employee_id) + + if row is None: + return response.json({"status": "Employee not found"}, status=404) + + employee = { + "id": row["id"], + "first_name": row["first_name"], + "last_name": row["last_name"], + "email": row["email"], + "position": row["position"], + "salary": row["salary"], + "date_hired": row["date_hired"].isoformat() if row["date_hired"] else None + } + + return response.json({"employee": employee}) + +@app.route("/employees/", methods=["PUT"]) +async def update_employee(request, employee_id): + try: + employee_id = int(employee_id) + except ValueError: + return response.json({"status": "Invalid employee ID"}, status=400) + + updated_data = request.json + required_fields = ["first_name", "last_name", "email", "position", "salary"] + for field in required_fields: + if field not in updated_data: + return response.json({"status": f"Missing field: {field}"}, status=400) + + async with app.ctx.db_pool.acquire() as connection: + result = await connection.execute( + """ + UPDATE employees + SET first_name = $1, + last_name = $2, + email = $3, + position = $4, + salary = $5 + WHERE id = $6 + """, + updated_data["first_name"], + updated_data["last_name"], + updated_data["email"], + updated_data["position"], + float(updated_data["salary"]), + employee_id + ) + + if result == "UPDATE 0": + return response.json({"status": "Employee not found"}, status=404) + + return response.json({"status": "Employee updated"}) + +# Function to delete an employee +@app.route("/employees/", methods=["DELETE"]) +async def delete_employee(request, employee_id): + try: + employee_id = int(employee_id) + except ValueError: + return response.json({"status": "Invalid employee ID"}, status=400) + + async with app.ctx.db_pool.acquire() as connection: + result = await connection.execute( + "DELETE FROM employees WHERE id=$1", employee_id + ) + + if result == "DELETE 0": + return response.json({"status": "Employee not found"}, status=404) + + return response.json({"status": "Employee deleted"}) + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8000)