Header Assertion
Header Assertion: Submit your API response header to receive the corresponding tests for the response using both SDKs and REST APIs.
Usage 🚀
Refer to Setup Guide for installing dependecies for both Java and Python.
JAVA
There are 2 clients available with the Java SDK: SyncClient and AsyncClient
Java Client Code
# for async client
import org.qyrus.ai_sdk.Clients.AsyncClient;
AsyncClient client = new AsyncClient(<API_TOKEN>, null);
# for sync client
import org.qyrus.ai_sdk.Clients.SyncClient;
SyncClient client = new SyncClient(<API_TOKEN>, null);Using SyncClient
Here's an example of utilizing Header Assertion with SyncClient.
Java SyncClient Code
private static void testHeaderAssertion() {
Dotenv dotenv = Dotenv.load();
String QYRUS_AI_SDK_API_TOKEN = dotenv.get("QYRUS_AI_SDK_API_TOKEN");
SyncClient client = new SyncClient(QYRUS_AI_SDK_API_TOKEN, null);
String responseHeaders = "Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: * Content-Length: 166 Content-Type: application/json Date: Wed, 12 Jun 2024 10:29:06 GMT Server: awselb/2.0";
long startTime = System.currentTimeMillis();
int numberOfRequests = 2;
for (int i = 0; i < numberOfRequests; i++) {
try {
// Assuming `client.header_assertion` is available and `assert` method matches the described input
HeaderAssertion.HeaderAssertionResponse response = client.api_assertions.headers.create(responseHeaders);
// Process and print the assertions
for (HeaderAssertion.HeaderAssertionItem item : response.getHeaderAssertions()) {
System.out.println(item.getAssertHeaderKey());
System.out.println(item.getAssertHeaderValue());
System.out.println(item.getAssertionDescription());
}
} catch (Exception e) {
e.printStackTrace();
}
}
long endTime = System.currentTimeMillis();
System.out.println("Synchronous Total time for Header Assertion request: " + (endTime - startTime) + " ms");
}Using AsyncClient
Here's an example of utilizing Header Assertion with AsyncClient.
PYTHON
There are two clients available with the Python SDK: SyncQyrusAI and AsyncQyrusAI.
Using SyncQyrusAI
Here's an example of utilizing Header Assertion with SyncQyrusAI.
Using AsyncQyrusAI
Here's an example of utilizing Header Assertion with AsyncQyrusAI.
REST APIs
This API allows users to create test based on provided API resonse header.
Endpoint
URL : POST {{GATEWAY_URL}}/api-assertion-gpt-sdk/v1/api/assertion/headers
Headers
Authorization: [Your Authorization Token]
Custom: [Your Custom Header Value]
Request Body: { "headers": "Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: * Content-Length: 166 Content-Type: application/json Date: Wed, 12 Jun 2024 10:29:06 GMT Server: awselb/2.0" }
Response:
Last updated