Skip to content

Instantly share code, notes, and snippets.

@ad3n
Created August 21, 2019 09:56
Show Gist options
  • Save ad3n/d01033cd843266ff91a1cd2987b5a81b to your computer and use it in GitHub Desktop.
Save ad3n/d01033cd843266ff91a1cd2987b5a81b to your computer and use it in GitHub Desktop.
Postman Test Collection
{
"info": {
"_postman_id": "8a23a3b2-39aa-4a4e-a4ee-8a099c1ac209",
"name": "CMS_ADMIN",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Admin_Manage_Content",
"item": [
{
"name": "Content_Get_Types",
"event": [
{
"listen": "prerequest",
"script": {
"id": "281b45b2-9915-4a2c-b2e9-14bcdd1344c9",
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"id": "a773165f-d48a-45bb-9485-b79883f38748",
"exec": [
"pm.test('Get Types', function () {",
" pm.response.to.have.status(200);",
" pm.response.to.be.json;",
" ",
" let response = pm.response.json();",
" pm.expect(response.contentType.length).to.equal(9);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{token}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": []
},
"url": {
"raw": "{{API}}/content/type",
"host": [
"{{API}}"
],
"path": [
"content",
"type"
]
}
},
"response": []
},
{
"name": "Content_Add_New",
"event": [
{
"listen": "prerequest",
"script": {
"id": "281b45b2-9915-4a2c-b2e9-14bcdd1344c9",
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"id": "a773165f-d48a-45bb-9485-b79883f38748",
"exec": [
"pm.test('Get Types', function () {",
" pm.response.to.have.status(200);",
" pm.response.to.be.json;",
" ",
" let response = pm.response.json();",
" ",
" pm.expect(response.contentType).to.equal(pm.variables.get('Content_Type'));",
" pm.expect(response.contentTitle).to.equal('Test Postman');",
" pm.expect(response.contentTitleEn).to.equal('Test Postman');",
" pm.expect(response.contentSummary).to.equal('Test Postman');",
" pm.expect(response.contentSummaryEn).to.equal('Test Postman');",
" pm.expect(response.contentImgUrl).to.equal('https://google.com/logo.png');",
" pm.expect(response.contentDetail).to.equal('Test Postman');",
" pm.expect(response.contentDetailEn).to.equal('Test Postman');",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{token}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "content[contentType]",
"value": "{{Content_Type}}",
"type": "text"
},
{
"key": "content[contentTitle]",
"value": "Test Postman",
"type": "text"
},
{
"key": "content[contentTitleEN]",
"value": "Test Postman",
"type": "text"
},
{
"key": "content[contentSummary]",
"value": "Test Postman",
"type": "text"
},
{
"key": "content[contentSummaryEN]",
"value": "Test Postman",
"type": "text"
},
{
"key": "content[contentImgUrl]",
"value": "https://google.com/logo.png",
"type": "text"
},
{
"key": "content[contentDetail]",
"value": "Test Postman",
"type": "text"
},
{
"key": "content[contentDetailEN]",
"value": "Test Postman",
"type": "text"
}
]
},
"url": {
"raw": "{{API}}/content/add",
"host": [
"{{API}}"
],
"path": [
"content",
"add"
]
}
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"id": "92a0df5d-dfbe-45b6-8bcd-afdb57a34015",
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"id": "eb912eb3-4633-4769-8bf4-9d92890f3c16",
"type": "text/javascript",
"exec": [
""
]
}
}
]
}
],
"event": [
{
"listen": "prerequest",
"script": {
"id": "00381e34-e9d2-4ebf-8b7e-4b4d21dd8f6f",
"type": "text/javascript",
"exec": [
"if (!pm.variables.get('token')) {",
" pm.sendRequest({",
" url: pm.variables.get('API') + '/admin/login_check',",
" method: 'POST',",
" header: 'Content-Type:application/x-www-form-urlencoded',",
" body: {",
" 'mode': 'urlencoded',",
" 'urlencoded': [",
" {",
" 'key': '_username',",
" 'value': 'admin',",
" 'type': 'text'",
" },",
" {",
" 'key': '_password',",
" 'value': 'open',",
" 'type': 'text'",
" }",
" ]",
" }",
" }, function (error, response) {",
" pm.variables.set('token', response.json().token);",
" }); ",
"}",
""
]
}
},
{
"listen": "test",
"script": {
"id": "aae21682-288e-4371-9bd2-28395d4ed524",
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"id": "8ee1ee0e-3489-499b-ad88-0df5de3662cb",
"key": "API",
"value": "http://openloyalty.localhost/app_dev.php/api",
"type": "string"
},
{
"id": "b0084d7c-3eba-4c47-86d0-fb4d1ff6d53d",
"key": "Content_Type",
"value": "Article",
"type": "string"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment