Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Roost-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# RoostGPT generated pytest code for API Testing

RoostGPT generats code in `tests` folder within given project path.
Dependency file i.e. `requirements-roost.txt` is also created in the given project path

Below are the sample steps to run the generated tests. Sample commands contains use of package manager i.e. `uv`. Alternatively python and pip can be used directly.
1. ( Optional ) Create virtual Env .
2. Install dependencies
```
uv venv // Create virtual Env
uv pip install -r requirements-roost.txt // Install all dependencies

```

Test configurations and test_data is loaded from config.yml. e.g. API HOST, auth, common path parameters of endpoint.
Either set defalt value in this config.yml file OR use ENV. e.g. export API_HOST="https://example.com/api/v2"

Once configuration values are set, use below commands to run the tests.
```
// Run generated tests
uv run pytest -m smoke // Run only smoke tests
uv run pytest -s tests/generated-test.py // Run specific test file
```

62 changes: 62 additions & 0 deletions requirements-roost.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

agentocr
beautifulsoup4
boto3
botocore
chromedriver_binary
click
django_recaptcha
dlib
dnspython
emoji
exifread
ffmpeg
ffpyplayer
Flask
flask_sqlalchemy
geopy
googletrans
gtts
img2pdf
jsonschema
keras
lxml
matplotlib
nltk
numpy
pandas
pil
Pillow
psutil
pyautogui
pycryptodome
pycryptodomex
PyDictionary
pygame
pymysql
pynotifier
PyPDF2
pytest
python-telegram-bot
pyttsx3
pywhatkit
PyYAML
qrcode
referencing
Requests
rich
scikit_learn
selenium
sumeval
sumy
tensorflow
textblob
tqdm
tweepy
urllib3
webdriver_manager
wechaty
wechaty_puppet
wikipedia
wordcloud
xmltodict
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"openapi":"3.0.3","info":{"version":"1.0.0","title":"Guice Grizzly Jersey Openapi Swagger Example API","description":"OpenAPI swagger configuration example in sample project that uses Guice, Grizzly, Jersey. This is an extended sample API (users, products, orders, auth) for demonstration purposes.","contact":{"email":"jayeshmaheshpatel@gmail.com"},"license":{"name":"MIT License","url":"https://en.wikipedia.org/wiki/MIT_License"}},"servers":[{"url":"http://localhost:8080/OpenAPIExample/","description":"Guice Grizzly Jersey Openapi Swagger Example API server"}],"tags":[{"name":"auth","description":"Authentication endpoints (register, login)"},{"name":"users","description":"User management"},{"name":"products","description":"Product catalog"},{"name":"orders","description":"Order processing"}],"paths":{"/auth/register":{"post":{"tags":["auth"],"summary":"Register a new user","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserCreate"},"examples":{"newUser":{"summary":"New user example","value":{"username":"jdoe","email":"jdoe@example.com","password":"P@ssw0rd!"}}}}}},"responses":{"201":{"description":"User created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/auth/login":{"post":{"tags":["auth"],"summary":"Authenticate user and return JWT","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"},"examples":{"login":{"summary":"Login example","value":{"username":"jdoe","password":"P@ssw0rd!"}}}}}},"responses":{"200":{"description":"Authentication successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/users":{"get":{"tags":["users"],"summary":"List users (paginated)","parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1},"description":"Page number"},{"name":"size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"description":"Page size"}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"A paginated list of users","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedUsers"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["users"],"summary":"Create a user","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserCreate"}}}},"responses":{"201":{"description":"User created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/users/{userId}":{"get":{"tags":["users"],"summary":"Get user by ID","parameters":[{"name":"userId","in":"path","required":true,"schema":{"type":"string"}}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"User found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["users"],"summary":"Update user","parameters":[{"name":"userId","in":"path","required":true,"schema":{"type":"string"}}],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserUpdate"}}}},"responses":{"200":{"description":"User updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["users"],"summary":"Delete user","parameters":[{"name":"userId","in":"path","required":true,"schema":{"type":"string"}}],"security":[{"bearerAuth":[]}],"responses":{"204":{"description":"User deleted (no content)"},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/products":{"get":{"tags":["products"],"summary":"List products (paginated)","parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}},{"name":"q","in":"query","schema":{"type":"string"},"description":"Search query (name/description)"}],"responses":{"200":{"description":"Paginated products","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedProducts"}}}}}},"post":{"tags":["products"],"summary":"Create a product","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductCreate"}}}},"responses":{"201":{"description":"Product created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/products/{productId}":{"get":{"tags":["products"],"summary":"Get product by ID","parameters":[{"name":"productId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Product found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"404":{"description":"Product not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["products"],"summary":"Update product","security":[{"bearerAuth":[]}],"parameters":[{"name":"productId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductUpdate"}}}},"responses":{"200":{"description":"Product updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"404":{"description":"Product not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["products"],"summary":"Delete product","security":[{"bearerAuth":[]}],"parameters":[{"name":"productId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Product deleted"},"404":{"description":"Product not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders":{"get":{"tags":["orders"],"summary":"List orders for authenticated user","security":[{"bearerAuth":[]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}}],"responses":{"200":{"description":"Paginated orders","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedOrders"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["orders"],"summary":"Create an order","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderCreate"}}}},"responses":{"201":{"description":"Order created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders/{orderId}":{"get":{"tags":["orders"],"summary":"Get order by ID (owner or admin only)","security":[{"bearerAuth":[]}],"parameters":[{"name":"orderId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Order found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Order not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\""}},"schemas":{"UserCreate":{"type":"object","required":["username","email","password"],"properties":{"username":{"type":"string","example":"jdoe"},"email":{"type":"string","format":"email","example":"jdoe@example.com"},"password":{"type":"string","format":"password","example":"P@ssw0rd!"}}},"UserUpdate":{"type":"object","properties":{"username":{"type":"string"},"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"}}},"UserResponse":{"type":"object","properties":{"id":{"type":"string","example":"user_12345"},"username":{"type":"string","example":"jdoe"},"email":{"type":"string","format":"email","example":"jdoe@example.com"},"firstName":{"type":"string"},"lastName":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"PaginatedUsers":{"type":"object","properties":{"page":{"type":"integer"},"size":{"type":"integer"},"total":{"type":"integer"},"items":{"type":"array","items":{"$ref":"#/components/schemas/UserResponse"}}}},"LoginRequest":{"type":"object","required":["username","password"],"properties":{"username":{"type":"string"},"password":{"type":"string","format":"password"}}},"AuthResponse":{"type":"object","properties":{"token":{"type":"string","example":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."},"expiresIn":{"type":"integer","example":3600}}},"Product":{"type":"object","properties":{"id":{"type":"string","example":"prod_12345"},"name":{"type":"string","example":"Wireless Mouse"},"description":{"type":"string"},"price":{"type":"number","format":"float","example":29.99},"currency":{"type":"string","example":"USD"},"available":{"type":"boolean","example":true},"createdAt":{"type":"string","format":"date-time"}}},"ProductCreate":{"type":"object","required":["name","price"],"properties":{"name":{"type":"string"},"description":{"type":"string"},"price":{"type":"number","format":"float"},"currency":{"type":"string","default":"USD"},"available":{"type":"boolean","default":true}}},"ProductUpdate":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"price":{"type":"number","format":"float"},"currency":{"type":"string"},"available":{"type":"boolean"}}},"PaginatedProducts":{"type":"object","properties":{"page":{"type":"integer"},"size":{"type":"integer"},"total":{"type":"integer"},"items":{"type":"array","items":{"$ref":"#/components/schemas/Product"}}}},"OrderItem":{"type":"object","required":["productId","quantity"],"properties":{"productId":{"type":"string"},"quantity":{"type":"integer","minimum":1},"unitPrice":{"type":"number","format":"float"}}},"OrderCreate":{"type":"object","required":["items","shippingAddress"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/OrderItem"}},"shippingAddress":{"$ref":"#/components/schemas/Address"},"notes":{"type":"string"}}},"Order":{"type":"object","properties":{"id":{"type":"string","example":"order_98765"},"userId":{"type":"string"},"items":{"type":"array","items":{"$ref":"#/components/schemas/OrderItem"}},"subtotal":{"type":"number","format":"float"},"shipping":{"type":"number","format":"float"},"total":{"type":"number","format":"float"},"currency":{"type":"string","example":"USD"},"status":{"type":"string","example":"PENDING"},"shippingAddress":{"$ref":"#/components/schemas/Address"},"createdAt":{"type":"string","format":"date-time"}}},"PaginatedOrders":{"type":"object","properties":{"page":{"type":"integer"},"size":{"type":"integer"},"total":{"type":"integer"},"items":{"type":"array","items":{"$ref":"#/components/schemas/Order"}}}},"Address":{"type":"object","properties":{"line1":{"type":"string"},"line2":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"postalCode":{"type":"string"},"country":{"type":"string"}}},"Error":{"type":"object","properties":{"code":{"type":"integer","example":400},"message":{"type":"string","example":"Invalid request"},"details":{"type":"array","items":{"type":"string"}}}}}},"security":[{"bearerAuth":[]}],"externalDocs":{"description":"Project README / docs","url":"http://localhost:8080/OpenAPIExample/docs"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[
{
"username": "jdoe",
"email": "jdoe@example.com",
"statusCode": 201,
"scenario": "Successful responses: Created"
},
{
"username": "msmith",
"email": "msmith@company.org",
"firstName": "Michael",
"lastName": "Smith",
"statusCode": 201,
"scenario": "Successful responses: Created"
},
{
"username": "agarcia",
"email": "agarcia@domain.net",
"firstName": "Ana",
"lastName": "Garcia",
"statusCode": 201,
"scenario": "Successful responses: Created"
},
{
"email": "missing_username@test.com",
"firstName": "Test",
"lastName": "User",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"username": "noEmailUser",
"firstName": "John",
"lastName": "Doe",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"username": "invalidEmail",
"email": "not-a-valid-email",
"firstName": "Invalid",
"lastName": "Email",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"username": "",
"email": "empty_username@test.com",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"username": "specialChars!@#",
"email": "special@test.com",
"firstName": "Special",
"lastName": "Characters",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"username": "validuser123",
"email": "validuser123@email.com",
"statusCode": 201,
"scenario": "Successful responses: Created"
},
{
"username": "fullprofile",
"email": "fullprofile@example.com",
"firstName": "Full",
"lastName": "Profile",
"statusCode": 201,
"scenario": "Successful responses: Created"
}
]
22 changes: 22 additions & 0 deletions tests/GUICE_GRIZZLY_JERSEY_OPENAPI_SWAGGER_EXAMPLE_API/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# This config.yml contains user provided data for api testing. Allows to define values here or use ENV to load values. e.g. ENV[API_HOST] = "https://exampl2.com"
# api:
# host: "${API_HOST:-https://example.com/api/v2}" # includes base path
# auth:
# api_key: "${API_KEY:-}"
# api_key_header: "${KEYNAME:-DefaultValue}" # openapi.spec.security.KEY_NAME
# basic_auth: "${username:-}:${password:-}"
# test_data:
# id: "${TEST_ID:-282739-1238371-219393-2833}" # Any test data key value pair e.g. GET /api/v1/cart/:id
# context-id: "${TEST_context-id:-}" # GET /api/v1/{context-id}/summary



api:
host: "${API_HOST:-http://localhost:8080/OpenAPIExample/}"
auth:
bearerAuth: "${BEARER_TOKEN:-}"
test_data:
userId: "${TEST_userId:-}"
productId: "${TEST_productId:-}"
orderId: "${TEST_orderId:-}"
Loading