File size: 22,437 Bytes
b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 5407d4c b8cffa7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
{
"info": {
"_postman_id": "7e5f2c6b-3e5d-4e40-a8f6-abc9f0c92a72",
"name": "Email Classification API Tests",
"description": "Tests for the Email Classification API hosted on Hugging Face Spaces",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"variable": [
{
"key": "baseUrl",
"value": "https://sparkonix-email-classification-model.hf.space",
"type": "string"
},
{
"key": "maskedEmailWithPII",
"value": "",
"type": "string"
},
{
"key": "accessKey",
"value": "local_dev_secure_access_key_20240516",
"type": "string"
}
],
"item": [
{
"name": "Health Check",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/health",
"host": [
"{{baseUrl}}"
],
"path": [
"health"
]
},
"description": "Check if the API is running"
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check if the response status is 200 OK",
"pm.test(\"Status code is 200\", function() {",
" pm.response.to.have.status(200);",
"});",
"",
"// Check if the health check returns the correct structure",
"pm.test(\"Health check returns correct structure\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"status\");",
" pm.expect(jsonData).to.have.property(\"message\");",
" pm.expect(jsonData.status).to.eql(\"healthy\");",
"});"
],
"type": "text/javascript"
}
}
],
"response": []
},
{
"name": "Basic Email Classification",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"input_email_body\": \"Hi, I am experiencing a problem with my login. The system is showing an error when I try to log in. Please help.\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/classify",
"host": [
"{{baseUrl}}"
],
"path": [
"classify"
]
},
"description": "Basic email classification test"
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check if the response status is 200 OK",
"pm.test(\"Status code is 200\", function() {",
" pm.response.to.have.status(200);",
"});",
"",
"// Check if the response structure is correct",
"pm.test(\"Response has correct structure\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"input_email_body\");",
" pm.expect(jsonData).to.have.property(\"masked_email\");",
" pm.expect(jsonData).to.have.property(\"list_of_masked_entities\");",
" pm.expect(jsonData).to.have.property(\"category_of_the_email\");",
"});",
"",
"// Check if the input email matches what we sent",
"pm.test(\"Input email matches request\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.input_email_body).to.eql(",
" \"Hi, I am experiencing a problem with my login. The system is showing an error when I try to log in. Please help.\"",
" );",
"});",
"",
"// Check if the category is one of the expected values",
"pm.test(\"Category is valid\", function() {",
" var jsonData = pm.response.json();",
" pm.expect([\"Incident\", \"Request\", \"Change\", \"Problem\"]).to.include(jsonData.category_of_the_email);",
"});"
],
"type": "text/javascript"
}
}
],
"response": []
},
{
"name": "Email with PII Classification",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"input_email_body\": \"Hello, my name is John Smith and my email is john.smith@example.com. I am having issues with my account. My phone number is 555-123-4567 and my credit card ending in 1234 seems to have been charged twice. Please help.\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/classify",
"host": [
"{{baseUrl}}"
],
"path": [
"classify"
]
},
"description": "Email classification with PII masking test"
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check if the response status is 200 OK",
"pm.test(\"Status code is 200\", function() {",
" pm.response.to.have.status(200);",
"});",
"",
"// Check if PII is being masked",
"pm.test(\"PII is masked properly\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.masked_email).to.not.include(\"John Smith\");",
" pm.expect(jsonData.masked_email).to.not.include(\"john.smith@example.com\");",
" pm.expect(jsonData.masked_email).to.not.include(\"555-123-4567\");",
" pm.expect(jsonData.masked_email).to.not.include(\"1234\");",
"});",
"",
"// Check if masked entities list is populated",
"pm.test(\"Masked entities list is populated\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.list_of_masked_entities).to.be.an(\"array\").that.is.not.empty;",
"});",
"",
"// Store the masked email for later unmasking test",
"var responseJson = pm.response.json();",
"pm.collectionVariables.set(\"maskedEmailWithPII\", responseJson.masked_email);",
"console.log(\"Stored masked email for unmasking tests\");"
],
"type": "text/javascript"
}
}
],
"response": []
},
{
"name": "Incident Email Classification",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"input_email_body\": \"URGENT: The application is down. None of our users can access the system. This is causing severe business impact and we need immediate attention. Our customer operations are halted.\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/classify",
"host": [
"{{baseUrl}}"
],
"path": [
"classify"
]
},
"description": "Test for incident classification"
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check if the response status is 200 OK",
"pm.test(\"Status code is 200\", function() {",
" pm.response.to.have.status(200);",
"});",
"",
"// This should likely be classified as an Incident",
"pm.test(\"Should be classified as an Incident\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.category_of_the_email).to.eql(\"Incident\");",
"});"
],
"type": "text/javascript"
}
}
],
"response": []
},
{
"name": "Request Email Classification",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"input_email_body\": \"I would like to request access to the financial reporting system for my new team member. Their details are as follows: Name: Jane Doe, Department: Finance, Employee ID: 12345. Please provide access by end of week.\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/classify",
"host": [
"{{baseUrl}}"
],
"path": [
"classify"
]
},
"description": "Test for request classification"
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check if the response status is 200 OK",
"pm.test(\"Status code is 200\", function() {",
" pm.response.to.have.status(200);",
"});",
"",
"// This should likely be classified as a Request",
"pm.test(\"Should be classified as a Request\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.category_of_the_email).to.eql(\"Request\");",
"});",
"",
"// Check if PII is masked",
"pm.test(\"Name should be masked\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.masked_email).to.not.include(\"Jane Doe\");",
"});"
],
"type": "text/javascript"
}
}
],
"response": []
},
{
"name": "Change Email Classification",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"input_email_body\": \"We need to change the configuration of the production server to increase memory allocation. Please schedule this change for the next maintenance window this Sunday at 2 AM. Approval has been granted by the IT Director.\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/classify",
"host": [
"{{baseUrl}}"
],
"path": [
"classify"
]
},
"description": "Test for change classification"
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check if the response status is 200 OK",
"pm.test(\"Status code is 200\", function() {",
" pm.response.to.have.status(200);",
"});",
"",
"// This should likely be classified as a Change",
"pm.test(\"Should be classified as a Change\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.category_of_the_email).to.eql(\"Change\");",
"});"
],
"type": "text/javascript"
}
}
],
"response": []
},
{
"name": "Problem Email Classification",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"input_email_body\": \"We have noticed that the application has been running slow for the past week. This happens consistently during peak hours (10 AM - 2 PM). Can you investigate the root cause of this ongoing performance issue?\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/classify",
"host": [
"{{baseUrl}}"
],
"path": [
"classify"
]
},
"description": "Test for problem classification"
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check if the response status is 200 OK",
"pm.test(\"Status code is 200\", function() {",
" pm.response.to.have.status(200);",
"});",
"",
"// This should likely be classified as a Problem",
"pm.test(\"Should be classified as a Problem\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.category_of_the_email).to.eql(\"Problem\");",
"});"
],
"type": "text/javascript"
}
}
],
"response": []
},
{
"name": "Empty Email Test",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"input_email_body\": \"\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/classify",
"host": [
"{{baseUrl}}"
],
"path": [
"classify"
]
},
"description": "Test with empty email body"
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// The API should either return an error or a classification",
"pm.test(\"Response status is valid\", function() {",
" pm.expect(pm.response.code).to.be.oneOf([200, 400, 422, 500]);",
" ",
" if (pm.response.code === 200) {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"category_of_the_email\");",
" } else {",
" // If it is an error response, make sure it has a proper structure",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"detail\");",
" }",
"});"
],
"type": "text/javascript"
}
}
],
"response": []
},
{
"name": "Unmask Email by Content",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"masked_email\": \"{{maskedEmailWithPII}}\",\n \"access_key\": \"{{accessKey}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/unmask-email",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"unmask-email"
]
},
"description": "Retrieve the original unmasked email using the masked content"
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check if the response status is 200 OK",
"pm.test(\"Status code is 200\", function() {",
" pm.response.to.have.status(200);",
"});",
"",
"// Check if the response has the correct structure",
"pm.test(\"Response has correct structure\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"status\");",
" pm.expect(jsonData).to.have.property(\"data\");",
" pm.expect(jsonData).to.have.property(\"message\");",
" pm.expect(jsonData.status).to.eql(\"success\");",
"});",
"",
"// Check if the data contains the original email with PII",
"pm.test(\"Data contains original email with PII\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.data).to.have.property(\"original_email\");",
" pm.expect(jsonData.data).to.have.property(\"masked_email\");",
" pm.expect(jsonData.data).to.have.property(\"masked_entities\");",
" ",
" // Check that the original email contains the PII",
" var maskedEmailWithPII = pm.collectionVariables.get(\"maskedEmailWithPII\");",
" if (maskedEmailWithPII) {",
" pm.expect(jsonData.data.original_email).to.include(\"John Smith\");",
" pm.expect(jsonData.data.original_email).to.include(\"john.smith@example.com\");",
" pm.expect(jsonData.data.original_email).to.include(\"555-123-4567\");",
" }",
"});"
],
"type": "text/javascript"
}
}
],
"response": []
},
{
"name": "Unmask Email with Invalid Access Key",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"masked_email\": \"{{maskedEmailWithPII}}\",\n \"access_key\": \"invalid_access_key_123456\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/unmask-email",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"unmask-email"
]
},
"description": "Test security by attempting to unmask email with invalid access key"
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check that we get an error (401) for invalid access key",
"pm.test(\"Should return error for invalid access key\", function() {",
" pm.expect(pm.response.code).to.equal(401);",
"});",
"",
"// Check error message",
"pm.test(\"Response contains appropriate error message\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"detail\");",
" pm.expect(jsonData.detail).to.include(\"Invalid access key\");",
"});"
],
"type": "text/javascript"
}
}
],
"response": []
},
{
"name": "Unmask with Non-existent Email Content",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"masked_email\": \"This is a masked email that does not exist in the database [FULL_NAME].\",\n \"access_key\": \"{{accessKey}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/unmask-email",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"unmask-email"
]
},
"description": "Test error handling when masked email content doesn't exist"
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check that we get a 404 error for non-existent email content",
"pm.test(\"Should return 404 for non-existent email content\", function() {",
" pm.expect(pm.response.code).to.equal(404);",
"});",
"",
"// Check error message",
"pm.test(\"Response contains appropriate error message\", function() {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"detail\");",
" pm.expect(jsonData.detail).to.include(\"not found\");",
"});"
],
"type": "text/javascript"
}
}
],
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"// Reset the tests passed flag before each request",
"pm.variables.set(\"testsPassed\", true);"
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"// Update the tests passed flag if any tests failed",
"if (pm.test.allTests.filter(test => !test.passed).length > 0) {",
" pm.variables.set(\"testsPassed\", false);",
"}"
]
}
}
]
} |