{"info":{"_postman_id":"b075cfee-0a90-4dea-9fea-d96b5fd31749","name":"Postman API Testing","description":"<html><head></head><body><h3 id=\"learning-advanced-features-of-postman-emphasizing-its-capabilities-beyond-basic-requests-and-encourages-viewers-to-explore-its-full-potential\"><em>Learning advanced features of Postman, emphasizing its capabilities beyond basic requests, and encourages viewers to explore its full potential.</em></h3>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"33792038","collectionId":"b075cfee-0a90-4dea-9fea-d96b5fd31749","publishedId":"2sAXqzWyFN","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"FF6C37"},"publishDate":"2024-09-30T02:01:20.000Z"},"item":[{"name":"Auth","item":[{"name":"Register User Random","event":[{"listen":"prerequest","script":{"id":"0c5b8303-4145-469c-b506-12d02843f0d0","exec":["function getRandomRoles(){\r","    const roles = [\"ADMIN\", \"USER\"]\r","    return roles[Math.floor(Math.random() * roles.length)]\r","}\r","\r","function getRandomUsername(){\r","    const letters = \"abcdefghijklmopqrstuvwxyz\"\r","    let username = \"\"\r","    for (let i = 0; i < 8; i++){\r","        username += letters.charAt(Math.floor(Math.random() * letters.length))\r","    }\r","\r","    return username\r","}\r","\r","pm.environment.set(\"randomRole\", getRandomRoles())\r","pm.environment.set(\"randomUsername\", getRandomUsername())"],"type":"text/javascript","packages":{}}},{"listen":"test","script":{"exec":["pm.test(\"Response status code is 201\", function () {","    pm.expect(pm.response.code).to.equal(201);","});","","","pm.test(\"Data object is present in the response\", function () {","    const responseData = pm.response.json();","    ","    pm.expect(responseData.data).to.exist;","});","","","pm.test(\"User object is present within the data object\", function () {","  const responseData = pm.response.json();","  ","  pm.expect(responseData).to.have.property('data');","  pm.expect(responseData.data).to.have.property('user');","});","","","pm.test(\"Email and username are non-empty strings\", function () {","    const responseData = pm.response.json();","    ","    pm.expect(responseData).to.be.an('object');","    pm.expect(responseData.data.user.email).to.be.a('string').and.to.have.lengthOf.at.least(1, \"Email should not be empty\");","    pm.expect(responseData.data.user.username).to.be.a('string').and.to.have.lengthOf.at.least(1, \"Username should not be empty\");","});","","","pm.test(\"Avatar object contains url, localPath, and _id fields within the user object\", function () {","    const responseData = pm.response.json();","    ","    pm.expect(responseData).to.be.an('object');","    pm.expect(responseData.data.user.avatar).to.be.an('object');","    pm.expect(responseData.data.user.avatar.url).to.be.a('string');","    pm.expect(responseData.data.user.avatar.localPath).to.be.a('string');","    pm.expect(responseData.data.user.avatar._id).to.be.a('string');","});"],"type":"text/javascript"}}],"id":"3774e1d6-accf-4da0-a1b4-5edeceb12e48","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n  \"email\": \"Christophe.Frami13@gmail.com\",\r\n  \"password\": \"test@123\",\r\n  \"role\": \"{{randomRole}}\",\r\n  \"username\": \"{{randomUsername}}\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://api.freeapi.app/api/v1/users/register","description":"<h3 id=\"register-user\">Register User</h3>\n<p>This endpoint allows you to register a new user.</p>\n<h4 id=\"request-body\">Request Body</h4>\n<ul>\n<li><p>email (text, required): The email of the user.</p>\n</li>\n<li><p>password (text, required): The password for the user account.</p>\n</li>\n<li><p>role (text, required): The role of the user.</p>\n</li>\n<li><p>username (text, required): The username of the user.</p>\n</li>\n</ul>\n<h4 id=\"response\">Response</h4>\n<p>The response will be a JSON object with the following schema:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"type\": \"object\",\n  \"properties\": {\n    \"statusCode\": {\n      \"type\": \"number\"\n    },\n    \"data\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"user\": {\n          \"type\": \"object\",\n          \"properties\": {\n            \"_id\": {\n              \"type\": \"string\"\n            },\n            \"avatar\": {\n              \"type\": \"object\",\n              \"properties\": {\n                \"url\": {\n                  \"type\": \"string\"\n                },\n                \"localPath\": {\n                  \"type\": \"string\"\n                },\n                \"_id\": {\n                  \"type\": \"string\"\n                }\n              }\n            },\n            \"username\": {\n              \"type\": \"string\"\n            },\n            \"email\": {\n              \"type\": \"string\"\n            },\n            \"role\": {\n              \"type\": \"string\"\n            },\n            \"loginType\": {\n              \"type\": \"string\"\n            },\n            \"isEmailVerified\": {\n              \"type\": \"boolean\"\n            },\n            \"createdAt\": {\n              \"type\": \"string\"\n            },\n            \"updatedAt\": {\n              \"type\": \"string\"\n            },\n            \"__v\": {\n              \"type\": \"number\"\n            }\n          }\n        },\n        \"message\": {\n          \"type\": \"string\"\n        },\n        \"success\": {\n          \"type\": \"boolean\"\n        }\n      }\n    }\n  }\n}\n\n</code></pre>\n","urlObject":{"path":["users","register"],"host":["https://api.freeapi.app/api/v1"],"query":[],"variable":[]}},"response":[],"_postman_id":"3774e1d6-accf-4da0-a1b4-5edeceb12e48"}],"id":"d35659c0-ea10-4672-b7ae-e069321ae3d4","_postman_id":"d35659c0-ea10-4672-b7ae-e069321ae3d4","description":""},{"name":"Public","item":[{"name":"Get Random Joke","event":[{"listen":"test","script":{"exec":["pm.test(\"Response status code is 200\", function () {","    pm.expect(pm.response.to.have.status(200));","});","","","pm.test(\"Data object is present in the response\", function () {","    const responseData = pm.response.json();","    ","    pm.expect(responseData.data).to.exist;","});","","","pm.test(\"Categories array should be empty\", function () {","    const responseData = pm.response.json();","    ","    pm.expect(responseData).to.be.an('object');","    pm.expect(responseData.data.categories).to.be.an('array').that.is.empty;","});","","","pm.test(\"Id is a non-negative number\", function () {","    const responseData = pm.response.json();","    ","    pm.expect(responseData).to.be.an('object');","    pm.expect(responseData.data.id).to.be.a('number').and.to.satisfy(id => id >= 0, \"Id should be a non-negative number\");","});","","","pm.test(\"Content is a non-empty string\", function () {","    const responseData = pm.response.json();","","    pm.expect(responseData).to.be.an('object');","    pm.expect(responseData.data.content).to.be.a('string').and.to.have.lengthOf.at.least(1, \"Content should not be empty\");","});"],"type":"text/javascript"}}],"id":"37a7f7e9-1ef7-458b-a159-a60eee89f878","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"https://api.freeapi.app/api/v1/public/randomjokes/joke/random","description":"<h3 id=\"get-publicrandomjokesjokerandom\">GET /public/randomjokes/joke/random</h3>\n<p>This endpoint retrieves a random joke from the public collection.</p>\n<h4 id=\"request-body\">Request Body</h4>\n<p>This endpoint does not require a request body.</p>\n<h4 id=\"response\">Response</h4>\n<ul>\n<li><p>Status: 200</p>\n</li>\n<li><p>Content-Type: application/json</p>\n</li>\n</ul>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"statusCode\": 0,\n    \"data\": {\n        \"categories\": [],\n        \"id\": 0,\n        \"content\": \"\"\n    },\n    \"message\": \"\",\n    \"success\": true\n}\n\n</code></pre>\n<p>The response contains the following fields:</p>\n<ul>\n<li><p><code>statusCode</code> (number): The status code of the response.</p>\n</li>\n<li><p><code>data</code> (object): An object containing the joke details.</p>\n<ul>\n<li><p><code>categories</code> (array): An array of categories associated with the joke.</p>\n</li>\n<li><p><code>id</code> (number): The ID of the joke.</p>\n</li>\n<li><p><code>content</code> (string): The content of the joke.</p>\n</li>\n</ul>\n</li>\n<li><p><code>message</code> (string): Any additional message from the server.</p>\n</li>\n<li><p><code>success</code> (boolean): Indicates if the request was successful.</p>\n</li>\n</ul>\n","urlObject":{"path":["public","randomjokes","joke","random"],"host":["https://api.freeapi.app/api/v1"],"query":[],"variable":[]}},"response":[],"_postman_id":"37a7f7e9-1ef7-458b-a159-a60eee89f878"}],"id":"f5661bd0-9f60-42b1-ac25-fb2a7516fc4c","_postman_id":"f5661bd0-9f60-42b1-ac25-fb2a7516fc4c","description":""}],"variable":[{"key":"freeapi","value":"https://api.freeapi.app/api/v1"}]}