{ "info": { "_postman_id": "0574ad8a-a525-43ae-8e1e-5fd9756037f4", "name": "Conduit", "description": "Collection for testing the Conduit API\n\nhttps://github.com/realworld-apps/realworld", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "Auth", "item": [ { "name": "Register", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "if (!(environment.isIntegrationTest)) {", "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"user\" property'] = responseJSON.hasOwnProperty('user');", "", "var user = responseJSON.user || {};", "", "tests['User has \"email\" property'] = user.hasOwnProperty('email');", "tests['User has \"username\" property'] = user.hasOwnProperty('username');", "tests['User has \"bio\" property'] = user.hasOwnProperty('bio');", "tests['User has \"image\" property'] = user.hasOwnProperty('image');", "tests['User has \"token\" property'] = user.hasOwnProperty('token');", "}", "" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"{{EMAIL}}\", \"password\":\"{{PASSWORD}}\", \"username\":\"{{USERNAME}}\"}}" }, "url": { "raw": "{{APIURL}}/users", "host": [ "{{APIURL}}" ], "path": [ "users" ] } }, "response": [] }, { "name": "Login", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"user\" property'] = responseJSON.hasOwnProperty('user');", "", "var user = responseJSON.user || {};", "", "tests['User has \"email\" property'] = user.hasOwnProperty('email');", "tests['User has \"username\" property'] = user.hasOwnProperty('username');", "tests['User has \"bio\" property'] = user.hasOwnProperty('bio');", "tests['User has \"image\" property'] = user.hasOwnProperty('image');", "tests['User has \"token\" property'] = user.hasOwnProperty('token');", "" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"{{EMAIL}}\", \"password\":\"{{PASSWORD}}\"}}" }, "url": { "raw": "{{APIURL}}/users/login", "host": [ "{{APIURL}}" ], "path": [ "users", "login" ] } }, "response": [] }, { "name": "Login and Remember Token", "event": [ { "listen": "test", "script": { "id": "a7674032-bf09-4ae7-8224-4afa2fb1a9f9", "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"user\" property'] = responseJSON.hasOwnProperty('user');", "", "var user = responseJSON.user || {};", "", "tests['User has \"email\" property'] = user.hasOwnProperty('email');", "tests['User has \"username\" property'] = user.hasOwnProperty('username');", "tests['User has \"bio\" property'] = user.hasOwnProperty('bio');", "tests['User has \"image\" property'] = user.hasOwnProperty('image');", "tests['User has \"token\" property'] = user.hasOwnProperty('token');", "", "if(tests['User has \"token\" property']){", " pm.globals.set('token', user.token);", "}", "", "tests['Global variable \"token\" has been set'] = pm.globals.get('token') === user.token;", "" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"{{EMAIL}}\", \"password\":\"{{PASSWORD}}\"}}" }, "url": { "raw": "{{APIURL}}/users/login", "host": [ "{{APIURL}}" ], "path": [ "users", "login" ] } }, "response": [] }, { "name": "Current User", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"user\" property'] = responseJSON.hasOwnProperty('user');", "", "var user = responseJSON.user || {};", "", "tests['User has \"email\" property'] = user.hasOwnProperty('email');", "tests['User has \"username\" property'] = user.hasOwnProperty('username');", "tests['User has \"bio\" property'] = user.hasOwnProperty('bio');", "tests['User has \"image\" property'] = user.hasOwnProperty('image');", "tests['User has \"token\" property'] = user.hasOwnProperty('token');", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/user", "host": [ "{{APIURL}}" ], "path": [ "user" ] } }, "response": [] }, { "name": "Update User", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"user\" property'] = responseJSON.hasOwnProperty('user');", "", "var user = responseJSON.user || {};", "", "tests['User has \"email\" property'] = user.hasOwnProperty('email');", "tests['User has \"username\" property'] = user.hasOwnProperty('username');", "tests['User has \"bio\" property'] = user.hasOwnProperty('bio');", "tests['User has \"image\" property'] = user.hasOwnProperty('image');", "tests['User has \"token\" property'] = user.hasOwnProperty('token');", "" ] } } ], "request": { "method": "PUT", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"{{EMAIL}}\"}}" }, "url": { "raw": "{{APIURL}}/user", "host": [ "{{APIURL}}" ], "path": [ "user" ] } }, "response": [] }, { "name": "Verify Update User Persisted", "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/user", "host": [ "{{APIURL}}" ], "path": [ "user" ] } }, "response": [], "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "pm.test('Response code is 200', function() {", " pm.response.to.have.status(200);", "});", "pm.test('User email matches updated value', function() {", " pm.expect(responseJSON.user.email).to.eql(pm.globals.get('EMAIL'));", "});", "" ] } } ] } ] }, { "name": "Articles", "item": [ { "name": "All Articles", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", "", " if(responseJSON.articles.length){", " var article = responseJSON.articles[0];", "", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", " } else {", " tests['articlesCount is 0 when feed is empty'] = responseJSON.articlesCount === 0;", " }", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "Articles by Author", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", "", " if(responseJSON.articles.length){", " var article = responseJSON.articles[0];", "", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", " } else {", " tests['articlesCount is 0 when feed is empty'] = responseJSON.articlesCount === 0;", " }", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles?author=johnjacob", "host": [ "{{APIURL}}" ], "path": [ "articles" ], "query": [ { "key": "author", "value": "johnjacob" } ] } }, "response": [] }, { "name": "Articles Favorited by Username", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", " ", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", "", " if(responseJSON.articles.length){", " var article = responseJSON.articles[0];", "", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", " } else {", " tests['articlesCount is 0 when feed is empty'] = responseJSON.articlesCount === 0;", " }", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles?favorited={{USERNAME}}", "host": [ "{{APIURL}}" ], "path": [ "articles" ], "query": [ { "key": "favorited", "value": "{{USERNAME}}" } ] } }, "response": [] }, { "name": "Articles by Tag", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", "", " if(responseJSON.articles.length){", " var article = responseJSON.articles[0];", "", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", " } else {", " tests['articlesCount is 0 when feed is empty'] = responseJSON.articlesCount === 0;", " }", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles?tag=dragons", "host": [ "{{APIURL}}" ], "path": [ "articles" ], "query": [ { "key": "tag", "value": "dragons" } ] } }, "response": [] } ] }, { "name": "Articles, Favorite, Comments", "item": [ { "name": "Create Article", "event": [ { "listen": "test", "script": { "id": "e711dbf8-8065-4ba8-8b74-f1639a7d8208", "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"article\" property'] = responseJSON.hasOwnProperty('article');", "", "var article = responseJSON.article || {};", "", "tests['Article has \"title\" property'] = article.hasOwnProperty('title');", "tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", "pm.globals.set('slug', article.slug);", "", "tests['Article has \"body\" property'] = article.hasOwnProperty('body');", "tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", "tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", "tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", "tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", "tests['Article has \"description\" property'] = article.hasOwnProperty('description');", "tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", "tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", "tests['Article has \"author\" property'] = article.hasOwnProperty('author');", "tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", "tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", "tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", "" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"title\":\"How to train your dragon\", \"description\":\"Ever wonder how?\", \"body\":\"Very carefully.\", \"tagList\":[\"training\", \"dragons\"]}}" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "Create Second Article", "event": [ { "listen": "test", "script": { "id": "e711dbf8-8065-4ba8-8b74-f1639a7d8208", "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"article\" property'] = responseJSON.hasOwnProperty('article');", "", "var article = responseJSON.article || {};", "", "tests['Article has \"title\" property'] = article.hasOwnProperty('title');", "tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", "pm.globals.set('slug2', article.slug);" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\n \"article\": {\n \"title\": \"Second article for pagination test\",\n \"description\": \"A second article to test articlesCount\",\n \"body\": \"This article exists to verify pagination counts\",\n \"tagList\": [\n \"testing\"\n ]\n }\n}" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "All Articles with limit (articlesCount pagination check)", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", "", " // Core pagination test: limit=1 but total articles == 2", " // articlesCount MUST be the total, not the page size", " tests['Only 1 article returned (limit=1)'] = responseJSON.articles.length === 1;", " tests['articlesCount is exactly 2 (total, not page size)'] = responseJSON.articlesCount === 2;", "}" ] } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{APIURL}}/articles?limit=1", "host": [ "{{APIURL}}" ], "path": [ "articles" ], "query": [ { "key": "limit", "value": "1" } ] } } }, { "name": "All Articles with offset (articlesCount still total)", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " // offset=1, limit=1 with 2 total articles: should get 1 article back, count still 2", " tests['Only 1 article returned'] = responseJSON.articles.length === 1;", " tests['articlesCount is still 2 despite offset'] = responseJSON.articlesCount === 2;", "}" ] } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{APIURL}}/articles?limit=1&offset=1", "host": [ "{{APIURL}}" ], "path": [ "articles" ], "query": [ { "key": "limit", "value": "1" }, { "key": "offset", "value": "1" } ] } } }, { "name": "Delete Second Article (pagination cleanup)", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 204 or 200'] = responseCode.code === 204 || responseCode.code === 200;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Token {{token}}" } ], "url": { "raw": "{{APIURL}}/articles/{{slug2}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug2}}" ] } } }, { "name": "Feed", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", " tests['articlesCount equals articles.length when no pagination'] = responseJSON.articlesCount === responseJSON.articles.length;", "", " if(responseJSON.articles.length){", " var article = responseJSON.articles[0];", "", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", " } else {", " tests['articlesCount is 0 when feed is empty'] = responseJSON.articlesCount === 0;", " }", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/feed", "host": [ "{{APIURL}}" ], "path": [ "articles", "feed" ] } }, "response": [] }, { "name": "All Articles", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", " tests['articlesCount equals articles.length when no pagination'] = responseJSON.articlesCount === responseJSON.articles.length;", "", " if(responseJSON.articles.length){", " var article = responseJSON.articles[0];", "", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", " } else {", " tests['articlesCount is 0 when feed is empty'] = responseJSON.articlesCount === 0;", " }", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "All Articles with auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", " tests['articlesCount equals articles.length when no pagination'] = responseJSON.articlesCount === responseJSON.articles.length;", "", " if(responseJSON.articles.length){", " var article = responseJSON.articles[0];", "", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", " } else {", " tests['articlesCount is 0 when feed is empty'] = responseJSON.articlesCount === 0;", " }", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "Articles by Author", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", "", " if(responseJSON.articles.length){", " var article = responseJSON.articles[0];", "", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", " } else {", " tests['articlesCount is 0 when feed is empty'] = responseJSON.articlesCount === 0;", " }", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles?author={{USERNAME}}", "host": [ "{{APIURL}}" ], "path": [ "articles" ], "query": [ { "key": "author", "value": "{{USERNAME}}" } ] } }, "response": [] }, { "name": "Articles by Author with auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", "", " if(responseJSON.articles.length){", " var article = responseJSON.articles[0];", "", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", " } else {", " tests['articlesCount is 0 when feed is empty'] = responseJSON.articlesCount === 0;", " }", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles?author={{USERNAME}}", "host": [ "{{APIURL}}" ], "path": [ "articles" ], "query": [ { "key": "author", "value": "{{USERNAME}}" } ] } }, "response": [] }, { "name": "Single Article by slug", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"article\" property'] = responseJSON.hasOwnProperty('article');", "", "var article = responseJSON.article || {};", "", "tests['Article has \"title\" property'] = article.hasOwnProperty('title');", "tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", "tests['Article has \"body\" property'] = article.hasOwnProperty('body');", "tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", "tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", "tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", "tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", "tests['Article has \"description\" property'] = article.hasOwnProperty('description');", "tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", "tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", "tests['Article has \"author\" property'] = article.hasOwnProperty('author');", "tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", "tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", "tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/{{slug}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug}}" ] } }, "response": [] }, { "name": "Articles by Tag", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", " var article = responseJSON.articles[0];", " tests['An article was returned'] = article !== undefined;", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['The first tag is dragons'] = article.tagList[0] === 'dragons';", " tests['The second tag is training'] = article.tagList[1] === 'training';", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles?tag=dragons", "host": [ "{{APIURL}}" ], "path": [ "articles" ], "query": [ { "key": "tag", "value": "dragons" } ] } }, "response": [] }, { "name": "Update Article", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "if (!(environment.isIntegrationTest)) {", "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"article\" property'] = responseJSON.hasOwnProperty('article');", "", "var article = responseJSON.article || {};", "", "tests['Article has \"title\" property'] = article.hasOwnProperty('title');", "tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", "tests['Article has \"body\" property'] = article.hasOwnProperty('body');", "tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", "tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", "tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", "tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", "tests['Article has \"description\" property'] = article.hasOwnProperty('description');", "tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", "tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", "tests['Article has \"author\" property'] = article.hasOwnProperty('author');", "tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", "tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", "tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", "}", "" ] } } ], "request": { "method": "PUT", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"body\":\"With two hands\"}}" }, "url": { "raw": "{{APIURL}}/articles/{{slug}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug}}" ] } }, "response": [] }, { "name": "Favorite Article", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"article\" property'] = responseJSON.hasOwnProperty('article');", "", "var article = responseJSON.article || {};", "", "tests['Article has \"title\" property'] = article.hasOwnProperty('title');", "tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", "tests['Article has \"body\" property'] = article.hasOwnProperty('body');", "tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", "tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", "tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", "tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", "tests['Article has \"description\" property'] = article.hasOwnProperty('description');", "tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", "tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", "tests['Article has \"author\" property'] = article.hasOwnProperty('author');", "tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", "tests[\"Article's 'favorited' property is true\"] = article.favorited === true;", "tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", "tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", "tests[\"Article's 'favoritesCount' property is greater than 0\"] = article.favoritesCount > 0;", "" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/{{slug}}/favorite", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug}}", "favorite" ] } }, "response": [] }, { "name": "Articles Favorited by Username", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", " article = responseJSON.articles[0];", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is 1'] = article.favoritesCount === 1;", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles?favorited={{USERNAME}}", "host": [ "{{APIURL}}" ], "path": [ "articles" ], "query": [ { "key": "favorited", "value": "{{USERNAME}}" } ] } }, "response": [] }, { "name": "Articles Favorited by Username with auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", " article = responseJSON.articles[0];", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", " tests['articlesCount is an integer'] = Number.isInteger(responseJSON.articlesCount);", " tests['Article has \"title\" property'] = article.hasOwnProperty('title');", " tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", " tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", " tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", " tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", " tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", " tests['Article has \"description\" property'] = article.hasOwnProperty('description');", " tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", " tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", " tests['Article has \"author\" property'] = article.hasOwnProperty('author');", " tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", " tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", " tests['favoritesCount is 1'] = article.favoritesCount === 1;", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles?favorited={{USERNAME}}", "host": [ "{{APIURL}}" ], "path": [ "articles" ], "query": [ { "key": "favorited", "value": "{{USERNAME}}" } ] } }, "response": [] }, { "name": "Unfavorite Article", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"article\" property'] = responseJSON.hasOwnProperty('article');", "", "var article = responseJSON.article || {};", "", "tests['Article has \"title\" property'] = article.hasOwnProperty('title');", "tests['Article has \"slug\" property'] = article.hasOwnProperty('slug');", "tests['Article has \"body\" property'] = article.hasOwnProperty('body');", "tests['Article has \"createdAt\" property'] = article.hasOwnProperty('createdAt');", "tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.createdAt);", "tests['Article has \"updatedAt\" property'] = article.hasOwnProperty('updatedAt');", "tests['Article\\'s \"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(article.updatedAt);", "tests['Article has \"description\" property'] = article.hasOwnProperty('description');", "tests['Article has \"tagList\" property'] = article.hasOwnProperty('tagList');", "tests['Article\\'s \"tagList\" property is an Array'] = Array.isArray(article.tagList);", "tests['Article has \"author\" property'] = article.hasOwnProperty('author');", "tests['Article has \"favorited\" property'] = article.hasOwnProperty('favorited');", "tests['Article has \"favoritesCount\" property'] = article.hasOwnProperty('favoritesCount');", "tests['favoritesCount is an integer'] = Number.isInteger(article.favoritesCount);", "tests[\"Article's \\\"favorited\\\" property is false\"] = article.favorited === false;", "" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/{{slug}}/favorite", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug}}", "favorite" ] } }, "response": [] }, { "name": "Verify Unfavorite Persisted", "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/{{slug}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug}}" ] } }, "response": [], "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "pm.test('Response code is 200', function() {", " pm.response.to.have.status(200);", "});", "pm.test('Article is no longer favorited', function() {", " pm.expect(responseJSON.article.favorited).to.eql(false);", "});", "pm.test('Favorites count is 0', function() {", " pm.expect(responseJSON.article.favoritesCount).to.eql(0);", "});", "" ] } } ] }, { "name": "Create Comment for Article", "event": [ { "listen": "test", "script": { "id": "9f90c364-cc68-4728-961a-85eb00197d7b", "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"comment\" property'] = responseJSON.hasOwnProperty('comment');", "", "var comment = responseJSON.comment || {};", "", "tests['Comment has \"id\" property'] = comment.hasOwnProperty('id');", "pm.globals.set('commentId', comment.id);", "", "tests['Comment has \"body\" property'] = comment.hasOwnProperty('body');", "tests['Comment has \"createdAt\" property'] = comment.hasOwnProperty('createdAt');", "tests['\"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(comment.createdAt);", "tests['Comment has \"updatedAt\" property'] = comment.hasOwnProperty('updatedAt');", "tests['\"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(comment.updatedAt);", "tests['Comment has \"author\" property'] = comment.hasOwnProperty('author');", "tests['Comment body is correct'] = comment.body === 'Thank you so much!';", "tests['Comment author username is correct'] = comment.author && comment.author.username === pm.globals.get('USERNAME');", "" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"comment\":{\"body\":\"Thank you so much!\"}}" }, "url": { "raw": "{{APIURL}}/articles/{{slug}}/comments", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug}}", "comments" ] } }, "response": [] }, { "name": "All Comments for Article", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"comments\" property'] = responseJSON.hasOwnProperty('comments');", "", " if(responseJSON.comments.length){", " var comment = responseJSON.comments[0];", "", " tests['Comment has \"id\" property'] = comment.hasOwnProperty('id');", " tests['Comment has \"body\" property'] = comment.hasOwnProperty('body');", " tests['Comment has \"createdAt\" property'] = comment.hasOwnProperty('createdAt');", " tests['\"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(comment.createdAt);", " tests['Comment has \"updatedAt\" property'] = comment.hasOwnProperty('updatedAt');", " tests['\"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(comment.updatedAt);", " tests['Comment has \"author\" property'] = comment.hasOwnProperty('author');", " }", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/{{slug}}/comments", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug}}", "comments" ] } }, "response": [] }, { "name": "All Comments for Article without login", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"comments\" property'] = responseJSON.hasOwnProperty('comments');", "", " if(responseJSON.comments.length){", " var comment = responseJSON.comments[0];", "", " tests['Comment has \"id\" property'] = comment.hasOwnProperty('id');", " tests['Comment has \"body\" property'] = comment.hasOwnProperty('body');", " tests['Comment has \"createdAt\" property'] = comment.hasOwnProperty('createdAt');", " tests['\"createdAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(comment.createdAt);", " tests['Comment has \"updatedAt\" property'] = comment.hasOwnProperty('updatedAt');", " tests['\"updatedAt\" property is an ISO 8601 timestamp'] = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/.test(comment.updatedAt);", " tests['Comment has \"author\" property'] = comment.hasOwnProperty('author');", " }", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/{{slug}}/comments", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug}}", "comments" ] } }, "response": [] }, { "name": "Delete Comment for Article", "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/{{slug}}/comments/{{commentId}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug}}", "comments", "{{commentId}}" ] } }, "response": [], "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 204'] = responseCode.code === 204;", "" ] } } ] }, { "name": "Verify Comment Deleted", "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/{{slug}}/comments", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug}}", "comments" ] } }, "response": [], "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "pm.test('Response code is 200', function() {", " pm.response.to.have.status(200);", "});", "pm.test('No comments remain', function() {", " pm.expect(responseJSON.comments).to.be.an('array');", " pm.expect(responseJSON.comments.length).to.eql(0);", "});", "" ] } } ] }, { "name": "Delete Article", "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/{{slug}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{slug}}" ] } }, "response": [], "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 204'] = responseCode.code === 204;", "" ] } } ] } ], "event": [ { "listen": "prerequest", "script": { "id": "67853a4a-e972-4573-a295-dad12a46a9d7", "type": "text/javascript", "exec": [ "" ] } }, { "listen": "test", "script": { "id": "3057f989-15e4-484e-b8fa-a041043d0ac0", "type": "text/javascript", "exec": [ "" ] } } ] }, { "name": "Profiles", "item": [ { "name": "Register Celeb", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "if (!(environment.isIntegrationTest)) {", "var responseJSON = JSON.parse(responseBody);", "", "tests['Response contains \"user\" property'] = responseJSON.hasOwnProperty('user');", "", "var user = responseJSON.user || {};", "", "tests['User has \"email\" property'] = user.hasOwnProperty('email');", "tests['User has \"username\" property'] = user.hasOwnProperty('username');", "tests['User has \"bio\" property'] = user.hasOwnProperty('bio');", "tests['User has \"image\" property'] = user.hasOwnProperty('image');", "tests['User has \"token\" property'] = user.hasOwnProperty('token');", "}", "" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"celeb_{{EMAIL}}\", \"password\":\"{{PASSWORD}}\", \"username\":\"celeb_{{USERNAME}}\"}}" }, "url": { "raw": "{{APIURL}}/users", "host": [ "{{APIURL}}" ], "path": [ "users" ] } }, "response": [] }, { "name": "Profile", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "if (!(environment.isIntegrationTest)) {", "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"profile\" property'] = responseJSON.hasOwnProperty('profile');", " ", " var profile = responseJSON.profile || {};", " ", " tests['Profile has \"username\" property'] = profile.hasOwnProperty('username');", " tests['Profile has \"bio\" property'] = profile.hasOwnProperty('bio');", " tests['Profile has \"image\" property'] = profile.hasOwnProperty('image');", " tests['Profile has \"following\" property'] = profile.hasOwnProperty('following');", "", " tests['Profile username is celeb_USERNAME'] = profile.username === 'celeb_' + pm.globals.get('USERNAME');", " tests['Profile bio is null'] = profile.bio === null;", " tests['Profile image is null'] = profile.image === null;", " tests['Profile following is false'] = profile.following === false;", "}", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/profiles/celeb_{{USERNAME}}", "host": [ "{{APIURL}}" ], "path": [ "profiles", "celeb_{{USERNAME}}" ] } }, "response": [] }, { "name": "Follow Profile", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "if (!(environment.isIntegrationTest)) {", "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"profile\" property'] = responseJSON.hasOwnProperty('profile');", " ", " var profile = responseJSON.profile || {};", " ", " tests['Profile has \"username\" property'] = profile.hasOwnProperty('username');", " tests['Profile has \"bio\" property'] = profile.hasOwnProperty('bio');", " tests['Profile has \"image\" property'] = profile.hasOwnProperty('image');", " tests['Profile has \"following\" property'] = profile.hasOwnProperty('following');", " tests['Profile\\'s \"following\" property is true'] = profile.following === true;", "}", "}", "" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"{{EMAIL}}\"}}" }, "url": { "raw": "{{APIURL}}/profiles/celeb_{{USERNAME}}/follow", "host": [ "{{APIURL}}" ], "path": [ "profiles", "celeb_{{USERNAME}}", "follow" ] } }, "response": [] }, { "name": "Unfollow Profile", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "if (!(environment.isIntegrationTest)) {", "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"profile\" property'] = responseJSON.hasOwnProperty('profile');", " ", " var profile = responseJSON.profile || {};", " ", " tests['Profile has \"username\" property'] = profile.hasOwnProperty('username');", " tests['Profile has \"bio\" property'] = profile.hasOwnProperty('bio');", " tests['Profile has \"image\" property'] = profile.hasOwnProperty('image');", " tests['Profile has \"following\" property'] = profile.hasOwnProperty('following');", " tests['Profile\\'s \"following\" property is false'] = profile.following === false;", "}", "}", "" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/profiles/celeb_{{USERNAME}}/follow", "host": [ "{{APIURL}}" ], "path": [ "profiles", "celeb_{{USERNAME}}", "follow" ] } }, "response": [] }, { "name": "Verify Unfollow Persisted", "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/profiles/celeb_{{USERNAME}}", "host": [ "{{APIURL}}" ], "path": [ "profiles", "celeb_{{USERNAME}}" ] } }, "response": [], "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "pm.test('Response code is 200', function() {", " pm.response.to.have.status(200);", "});", "pm.test('Unfollow persisted - following is false', function() {", " pm.expect(responseJSON.profile.following).to.eql(false);", "});", "" ] } } ] } ] }, { "name": "Pagination", "item": [ { "name": "Follow celeb for feed test", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 200 OK'] = responseCode.code === 200;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Token {{token}}" } ], "url": { "raw": "{{APIURL}}/profiles/celeb_{{USERNAME}}/follow", "host": [ "{{APIURL}}" ], "path": [ "profiles", "celeb_{{USERNAME}}", "follow" ] } } }, { "name": "Celeb login", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "tests['Response contains user'] = responseJSON.hasOwnProperty('user');", "pm.globals.set('celeb_token', responseJSON.user.token);" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\"user\": {\"email\": \"celeb_{{EMAIL}}\", \"password\": \"{{PASSWORD}}\"}}" }, "url": { "raw": "{{APIURL}}/users/login", "host": [ "{{APIURL}}" ], "path": [ "users", "login" ] } } }, { "name": "Celeb creates article 1", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "tests['Article created'] = responseCode.code === 201;", "pm.globals.set('celeb_slug1', responseJSON.article.slug);" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Token {{celeb_token}}" } ], "body": { "mode": "raw", "raw": "{\"article\": {\"title\": \"Celeb article one\", \"description\": \"First celeb article for feed pagination\", \"body\": \"Content one\"}}" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } } }, { "name": "Celeb creates article 2", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "tests['Article created'] = responseCode.code === 201;", "pm.globals.set('celeb_slug2', responseJSON.article.slug);" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Token {{celeb_token}}" } ], "body": { "mode": "raw", "raw": "{\"article\": {\"title\": \"Celeb article two\", \"description\": \"Second celeb article for feed pagination\", \"body\": \"Content two\"}}" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } } }, { "name": "Feed with limit (pagination check)", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " tests['Response contains \"articles\" property'] = responseJSON.hasOwnProperty('articles');", " tests['Response contains \"articlesCount\" property'] = responseJSON.hasOwnProperty('articlesCount');", "", " // Feed pagination: limit=1 but celeb has 2 articles", " tests['Only 1 article returned (limit=1)'] = responseJSON.articles.length === 1;", " tests['articlesCount is exactly 2 (total feed, not page size)'] = responseJSON.articlesCount === 2;", "", " // Verify feed content: articles come from followed celeb user", " var firstArticle = responseJSON.articles[0];", " tests['Feed article author is celeb'] = firstArticle.author.username === 'celeb_' + pm.globals.get('USERNAME');", " tests['Feed article author.following is true'] = firstArticle.author.following === true;", "}" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Token {{token}}" } ], "url": { "raw": "{{APIURL}}/articles/feed?limit=1", "host": [ "{{APIURL}}" ], "path": [ "articles", "feed" ], "query": [ { "key": "limit", "value": "1" } ] } } }, { "name": "Feed with offset (pagination check)", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", "", " // offset=1, limit=1: get 1 article back, total still 2", " tests['Only 1 article returned'] = responseJSON.articles.length === 1;", " tests['articlesCount is still 2 despite offset'] = responseJSON.articlesCount === 2;", "}" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Token {{token}}" } ], "url": { "raw": "{{APIURL}}/articles/feed?limit=1&offset=1", "host": [ "{{APIURL}}" ], "path": [ "articles", "feed" ], "query": [ { "key": "limit", "value": "1" }, { "key": "offset", "value": "1" } ] } } }, { "name": "Celeb delete article 1", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Deleted'] = responseCode.code === 204 || responseCode.code === 200;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Token {{celeb_token}}" } ], "url": { "raw": "{{APIURL}}/articles/{{celeb_slug1}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{celeb_slug1}}" ] } } }, { "name": "Celeb delete article 2", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Deleted'] = responseCode.code === 204 || responseCode.code === 200;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Token {{celeb_token}}" } ], "url": { "raw": "{{APIURL}}/articles/{{celeb_slug2}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{celeb_slug2}}" ] } } }, { "name": "Unfollow celeb (cleanup)", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 200 OK'] = responseCode.code === 200;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Token {{token}}" } ], "url": { "raw": "{{APIURL}}/profiles/celeb_{{USERNAME}}/follow", "host": [ "{{APIURL}}" ], "path": [ "profiles", "celeb_{{USERNAME}}", "follow" ] } } } ] }, { "name": "Tags", "item": [ { "name": "All Tags", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var is200Response = responseCode.code === 200;", "", "tests['Response code is 200 OK'] = is200Response;", "", "if(is200Response){", " var responseJSON = JSON.parse(responseBody);", " ", " tests['Response contains \"tags\" property'] = responseJSON.hasOwnProperty('tags');", " tests['\"tags\" property returned as array'] = Array.isArray(responseJSON.tags);", "}", "" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/tags", "host": [ "{{APIURL}}" ], "path": [ "tags" ] } }, "response": [] } ] }, { "name": "Error Cases - Auth", "item": [ { "name": "Register - empty username", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 422'] = responseCode.code === 422;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"neg@test.com\",\"password\":\"negpass\",\"username\":\"\"}}" }, "url": { "raw": "{{APIURL}}/users", "host": [ "{{APIURL}}" ], "path": [ "users" ] } }, "response": [] }, { "name": "Register - empty email", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 422'] = responseCode.code === 422;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"\",\"password\":\"negpass\",\"username\":\"neguser\"}}" }, "url": { "raw": "{{APIURL}}/users", "host": [ "{{APIURL}}" ], "path": [ "users" ] } }, "response": [] }, { "name": "Register - empty password", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 422'] = responseCode.code === 422;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"neg@test.com\",\"password\":\"\",\"username\":\"neguser\"}}" }, "url": { "raw": "{{APIURL}}/users", "host": [ "{{APIURL}}" ], "path": [ "users" ] } }, "response": [] }, { "name": "Register - duplicate credentials", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 409'] = responseCode.code === 409;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"{{EMAIL}}\",\"password\":\"anything\",\"username\":\"{{USERNAME}}\"}}" }, "url": { "raw": "{{APIURL}}/users", "host": [ "{{APIURL}}" ], "path": [ "users" ] } }, "response": [] }, { "name": "Login - empty email", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 422'] = responseCode.code === 422;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"\",\"password\":\"pass\"}}" }, "url": { "raw": "{{APIURL}}/users/login", "host": [ "{{APIURL}}" ], "path": [ "users", "login" ] } }, "response": [] }, { "name": "Login - empty password", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 422'] = responseCode.code === 422;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"{{EMAIL}}\",\"password\":\"\"}}" }, "url": { "raw": "{{APIURL}}/users/login", "host": [ "{{APIURL}}" ], "path": [ "users", "login" ] } }, "response": [] }, { "name": "Login - wrong password", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "tests['Response code is 401'] = responseCode.code === 401;", "tests['Error message is incorrect credentials'] = responseJSON.detail[0].msg === 'incorrect credentials';" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"{{EMAIL}}\",\"password\":\"wrongpassword123\"}}" }, "url": { "raw": "{{APIURL}}/users/login", "host": [ "{{APIURL}}" ], "path": [ "users", "login" ] } }, "response": [] }, { "name": "Current User - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/user", "host": [ "{{APIURL}}" ], "path": [ "user" ] } }, "response": [] }, { "name": "Update User - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "PUT", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"x@test.com\"}}" }, "url": { "raw": "{{APIURL}}/user", "host": [ "{{APIURL}}" ], "path": [ "user" ] } }, "response": [] } ] }, { "name": "Error Cases - Articles & Comments", "item": [ { "name": "Create Article - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"title\":\"No Auth Article\",\"description\":\"desc\",\"body\":\"body\",\"tagList\":[]}}" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "Create Article - empty title", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 422'] = responseCode.code === 422;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"title\":\"\",\"description\":\"desc\",\"body\":\"body\",\"tagList\":[]}}" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "Create Article - empty description", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 422'] = responseCode.code === 422;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"title\":\"Some Title\",\"description\":\"\",\"body\":\"body\",\"tagList\":[]}}" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "Create Article - empty body", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 422'] = responseCode.code === 422;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"title\":\"Some Title\",\"description\":\"desc\",\"body\":\"\",\"tagList\":[]}}" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "Setup: Create test article", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "tests['Response code is 201'] = responseCode.code === 201;", "if (responseJSON.article) { pm.globals.set('neg_slug', responseJSON.article.slug); }" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"title\":\"Negative Test Article\",\"description\":\"For error testing\",\"body\":\"Test body content\",\"tagList\":[\"test\"]}}" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "Create Article - duplicate title", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 409'] = responseCode.code === 409;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"title\":\"Negative Test Article\",\"description\":\"duplicate\",\"body\":\"duplicate body\",\"tagList\":[]}}" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "Get Article - unknown slug", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 404'] = responseCode.code === 404;" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/nonexistent-slug-xxx", "host": [ "{{APIURL}}" ], "path": [ "articles", "nonexistent-slug-xxx" ] } }, "response": [] }, { "name": "Update Article - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "PUT", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"body\":\"updated body\"}}" }, "url": { "raw": "{{APIURL}}/articles/{{neg_slug}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{neg_slug}}" ] } }, "response": [] }, { "name": "Update Article - unknown slug", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 404'] = responseCode.code === 404;" ] } } ], "request": { "method": "PUT", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"body\":\"updated body\"}}" }, "url": { "raw": "{{APIURL}}/articles/nonexistent-slug-xxx", "host": [ "{{APIURL}}" ], "path": [ "articles", "nonexistent-slug-xxx" ] } }, "response": [] }, { "name": "Delete Article - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "url": { "raw": "{{APIURL}}/articles/{{neg_slug}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{neg_slug}}" ] } }, "response": [] }, { "name": "Delete Article - unknown slug", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 404'] = responseCode.code === 404;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "url": { "raw": "{{APIURL}}/articles/nonexistent-slug-xxx", "host": [ "{{APIURL}}" ], "path": [ "articles", "nonexistent-slug-xxx" ] } }, "response": [] }, { "name": "Get Feed - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/feed", "host": [ "{{APIURL}}" ], "path": [ "articles", "feed" ] } }, "response": [] }, { "name": "Favorite - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/articles/{{neg_slug}}/favorite", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{neg_slug}}", "favorite" ] } }, "response": [] }, { "name": "Unfavorite - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "url": { "raw": "{{APIURL}}/articles/{{neg_slug}}/favorite", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{neg_slug}}", "favorite" ] } }, "response": [] }, { "name": "Post Comment - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"comment\":{\"body\":\"No auth comment\"}}" }, "url": { "raw": "{{APIURL}}/articles/{{neg_slug}}/comments", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{neg_slug}}", "comments" ] } }, "response": [] }, { "name": "Post Comment - empty body", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 422'] = responseCode.code === 422;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"comment\":{\"body\":\"\"}}" }, "url": { "raw": "{{APIURL}}/articles/{{neg_slug}}/comments", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{neg_slug}}", "comments" ] } }, "response": [] }, { "name": "Setup: Create test comment", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "tests['Response code is 201'] = responseCode.code === 201;", "if (responseJSON.comment) { pm.globals.set('neg_comment_id', responseJSON.comment.id); }" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"comment\":{\"body\":\"Test comment for error cases\"}}" }, "url": { "raw": "{{APIURL}}/articles/{{neg_slug}}/comments", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{neg_slug}}", "comments" ] } }, "response": [] }, { "name": "Delete Comment - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "url": { "raw": "{{APIURL}}/articles/{{neg_slug}}/comments/{{neg_comment_id}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{neg_slug}}", "comments", "{{neg_comment_id}}" ] } }, "response": [] }, { "name": "Delete Comment - unknown article", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 404'] = responseCode.code === 404;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "url": { "raw": "{{APIURL}}/articles/nonexistent-slug-xxx/comments/1", "host": [ "{{APIURL}}" ], "path": [ "articles", "nonexistent-slug-xxx", "comments", "1" ] } }, "response": [] }, { "name": "Cleanup: Delete article", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 204'] = responseCode.code === 204;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "url": { "raw": "{{APIURL}}/articles/{{neg_slug}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{neg_slug}}" ] } }, "response": [] } ] }, { "name": "Error Cases - Profiles & Authorization", "item": [ { "name": "Get Profile - unknown user", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 404'] = responseCode.code === 404;" ] } } ], "request": { "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/profiles/nonexistent-user-xxx", "host": [ "{{APIURL}}" ], "path": [ "profiles", "nonexistent-user-xxx" ] } }, "response": [] }, { "name": "Follow - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{APIURL}}/profiles/celeb_{{USERNAME}}/follow", "host": [ "{{APIURL}}" ], "path": [ "profiles", "celeb_{{USERNAME}}", "follow" ] } }, "response": [] }, { "name": "Unfollow - no auth", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 401'] = responseCode.code === 401;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "url": { "raw": "{{APIURL}}/profiles/celeb_{{USERNAME}}/follow", "host": [ "{{APIURL}}" ], "path": [ "profiles", "celeb_{{USERNAME}}", "follow" ] } }, "response": [] }, { "name": "Setup: Celeb login", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "tests['Response code is 200'] = responseCode.code === 200;", "if (responseJSON.user) { pm.globals.set('celeb_token', responseJSON.user.token); }" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" } ], "body": { "mode": "raw", "raw": "{\"user\":{\"email\":\"celeb_{{EMAIL}}\",\"password\":\"{{PASSWORD}}\"}}" }, "url": { "raw": "{{APIURL}}/users/login", "host": [ "{{APIURL}}" ], "path": [ "users", "login" ] } }, "response": [] }, { "name": "Setup: Celeb creates article", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "var responseJSON = JSON.parse(responseBody);", "tests['Response code is 201'] = responseCode.code === 201;", "if (responseJSON.article) { pm.globals.set('celeb_neg_slug', responseJSON.article.slug); }" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{celeb_token}}" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"title\":\"Celeb Neg Test Article\",\"description\":\"Celeb article for auth testing\",\"body\":\"Celeb body content\",\"tagList\":[\"test\"]}}" }, "url": { "raw": "{{APIURL}}/articles", "host": [ "{{APIURL}}" ], "path": [ "articles" ] } }, "response": [] }, { "name": "Delete Article - wrong author", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 403'] = responseCode.code === 403;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "url": { "raw": "{{APIURL}}/articles/{{celeb_neg_slug}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{celeb_neg_slug}}" ] } }, "response": [] }, { "name": "Update Article - wrong author", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 403'] = responseCode.code === 403;" ] } } ], "request": { "method": "PUT", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{token}}" } ], "body": { "mode": "raw", "raw": "{\"article\":{\"body\":\"hijacked body\"}}" }, "url": { "raw": "{{APIURL}}/articles/{{celeb_neg_slug}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{celeb_neg_slug}}" ] } }, "response": [] }, { "name": "Cleanup: Celeb deletes article", "event": [ { "listen": "test", "script": { "type": "text/javascript", "exec": [ "tests['Response code is 204'] = responseCode.code === 204;" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "X-Requested-With", "value": "XMLHttpRequest" }, { "key": "Authorization", "value": "Token {{celeb_token}}" } ], "url": { "raw": "{{APIURL}}/articles/{{celeb_neg_slug}}", "host": [ "{{APIURL}}" ], "path": [ "articles", "{{celeb_neg_slug}}" ] } }, "response": [] } ] } ] }