5519 lines
238 KiB
JSON
5519 lines
238 KiB
JSON
{
|
||
"info": {
|
||
"_postman_id": "5f01a459-2226-46ba-b69b-7b15e31810dc",
|
||
"name": "PROD round 2: secret tests",
|
||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||
},
|
||
"item": [
|
||
{
|
||
"name": "01/ping",
|
||
"item": [
|
||
{
|
||
"name": "Ping",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"",
|
||
"pm.test(\"PING server\", function () {",
|
||
" pm.sendRequest(pm.variables.get(\"base_url\") + \"/ping\", function (err, response) {",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" });",
|
||
"});",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"name": "02/countries",
|
||
"item": [
|
||
{
|
||
"name": "List all countries",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"array\",",
|
||
" \"items\": {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о стране из стандарта ISO 3166\",",
|
||
" \"properties\": {",
|
||
" \"name\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Полное название страны\",",
|
||
" \"maxLength\": 100",
|
||
" },",
|
||
" \"alpha2\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"alpha3\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Трехбуквенный код страны\",",
|
||
" \"maxLength\": 3,",
|
||
" \"pattern\": \"[a-zA-Z]{3}\"",
|
||
" },",
|
||
" \"region\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Географический регион, к которому относится страна\",",
|
||
" \"enum\": [",
|
||
" \"Europe\",",
|
||
" \"Africa\",",
|
||
" \"Americas\",",
|
||
" \"Oceania\",",
|
||
" \"Asia\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"name\",",
|
||
" \"alpha2\",",
|
||
" \"alpha3\"",
|
||
" ]",
|
||
" },",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"const countries = [{\"name\":\"Afghanistan\",\"alpha2\":\"AF\",\"alpha3\":\"AFG\",\"region\":\"Asia\"},{\"name\":\"Åland Islands\",\"alpha2\":\"AX\",\"alpha3\":\"ALA\",\"region\":\"Europe\"},{\"name\":\"Albania\",\"alpha2\":\"AL\",\"alpha3\":\"ALB\",\"region\":\"Europe\"},{\"name\":\"Algeria\",\"alpha2\":\"DZ\",\"alpha3\":\"DZA\",\"region\":\"Africa\"},{\"name\":\"American Samoa\",\"alpha2\":\"AS\",\"alpha3\":\"ASM\",\"region\":\"Oceania\"},{\"name\":\"Andorra\",\"alpha2\":\"AD\",\"alpha3\":\"AND\",\"region\":\"Europe\"},{\"name\":\"Angola\",\"alpha2\":\"AO\",\"alpha3\":\"AGO\",\"region\":\"Africa\"},{\"name\":\"Anguilla\",\"alpha2\":\"AI\",\"alpha3\":\"AIA\",\"region\":\"Americas\"},{\"name\":\"Antigua and Barbuda\",\"alpha2\":\"AG\",\"alpha3\":\"ATG\",\"region\":\"Americas\"},{\"name\":\"Argentina\",\"alpha2\":\"AR\",\"alpha3\":\"ARG\",\"region\":\"Americas\"},{\"name\":\"Armenia\",\"alpha2\":\"AM\",\"alpha3\":\"ARM\",\"region\":\"Asia\"},{\"name\":\"Aruba\",\"alpha2\":\"AW\",\"alpha3\":\"ABW\",\"region\":\"Americas\"},{\"name\":\"Australia\",\"alpha2\":\"AU\",\"alpha3\":\"AUS\",\"region\":\"Oceania\"},{\"name\":\"Austria\",\"alpha2\":\"AT\",\"alpha3\":\"AUT\",\"region\":\"Europe\"},{\"name\":\"Azerbaijan\",\"alpha2\":\"AZ\",\"alpha3\":\"AZE\",\"region\":\"Asia\"},{\"name\":\"Bahamas\",\"alpha2\":\"BS\",\"alpha3\":\"BHS\",\"region\":\"Americas\"},{\"name\":\"Bahrain\",\"alpha2\":\"BH\",\"alpha3\":\"BHR\",\"region\":\"Asia\"},{\"name\":\"Bangladesh\",\"alpha2\":\"BD\",\"alpha3\":\"BGD\",\"region\":\"Asia\"},{\"name\":\"Barbados\",\"alpha2\":\"BB\",\"alpha3\":\"BRB\",\"region\":\"Americas\"},{\"name\":\"Belarus\",\"alpha2\":\"BY\",\"alpha3\":\"BLR\",\"region\":\"Europe\"},{\"name\":\"Belgium\",\"alpha2\":\"BE\",\"alpha3\":\"BEL\",\"region\":\"Europe\"},{\"name\":\"Belize\",\"alpha2\":\"BZ\",\"alpha3\":\"BLZ\",\"region\":\"Americas\"},{\"name\":\"Benin\",\"alpha2\":\"BJ\",\"alpha3\":\"BEN\",\"region\":\"Africa\"},{\"name\":\"Bermuda\",\"alpha2\":\"BM\",\"alpha3\":\"BMU\",\"region\":\"Americas\"},{\"name\":\"Bhutan\",\"alpha2\":\"BT\",\"alpha3\":\"BTN\",\"region\":\"Asia\"},{\"name\":\"Bolivia (Plurinational State of)\",\"alpha2\":\"BO\",\"alpha3\":\"BOL\",\"region\":\"Americas\"},{\"name\":\"Bonaire, Sint Eustatius and Saba\",\"alpha2\":\"BQ\",\"alpha3\":\"BES\",\"region\":\"Americas\"},{\"name\":\"Bosnia and Herzegovina\",\"alpha2\":\"BA\",\"alpha3\":\"BIH\",\"region\":\"Europe\"},{\"name\":\"Botswana\",\"alpha2\":\"BW\",\"alpha3\":\"BWA\",\"region\":\"Africa\"},{\"name\":\"Bouvet Island\",\"alpha2\":\"BV\",\"alpha3\":\"BVT\",\"region\":\"Americas\"},{\"name\":\"Brazil\",\"alpha2\":\"BR\",\"alpha3\":\"BRA\",\"region\":\"Americas\"},{\"name\":\"British Indian Ocean Territory\",\"alpha2\":\"IO\",\"alpha3\":\"IOT\",\"region\":\"Africa\"},{\"name\":\"Brunei Darussalam\",\"alpha2\":\"BN\",\"alpha3\":\"BRN\",\"region\":\"Asia\"},{\"name\":\"Bulgaria\",\"alpha2\":\"BG\",\"alpha3\":\"BGR\",\"region\":\"Europe\"},{\"name\":\"Burkina Faso\",\"alpha2\":\"BF\",\"alpha3\":\"BFA\",\"region\":\"Africa\"},{\"name\":\"Burundi\",\"alpha2\":\"BI\",\"alpha3\":\"BDI\",\"region\":\"Africa\"},{\"name\":\"Cabo Verde\",\"alpha2\":\"CV\",\"alpha3\":\"CPV\",\"region\":\"Africa\"},{\"name\":\"Cambodia\",\"alpha2\":\"KH\",\"alpha3\":\"KHM\",\"region\":\"Asia\"},{\"name\":\"Cameroon\",\"alpha2\":\"CM\",\"alpha3\":\"CMR\",\"region\":\"Africa\"},{\"name\":\"Canada\",\"alpha2\":\"CA\",\"alpha3\":\"CAN\",\"region\":\"Americas\"},{\"name\":\"Cayman Islands\",\"alpha2\":\"KY\",\"alpha3\":\"CYM\",\"region\":\"Americas\"},{\"name\":\"Central African Republic\",\"alpha2\":\"CF\",\"alpha3\":\"CAF\",\"region\":\"Africa\"},{\"name\":\"Chad\",\"alpha2\":\"TD\",\"alpha3\":\"TCD\",\"region\":\"Africa\"},{\"name\":\"Chile\",\"alpha2\":\"CL\",\"alpha3\":\"CHL\",\"region\":\"Americas\"},{\"name\":\"China\",\"alpha2\":\"CN\",\"alpha3\":\"CHN\",\"region\":\"Asia\"},{\"name\":\"Christmas Island\",\"alpha2\":\"CX\",\"alpha3\":\"CXR\",\"region\":\"Oceania\"},{\"name\":\"Cocos (Keeling) Islands\",\"alpha2\":\"CC\",\"alpha3\":\"CCK\",\"region\":\"Oceania\"},{\"name\":\"Colombia\",\"alpha2\":\"CO\",\"alpha3\":\"COL\",\"region\":\"Americas\"},{\"name\":\"Comoros\",\"alpha2\":\"KM\",\"alpha3\":\"COM\",\"region\":\"Africa\"},{\"name\":\"Congo\",\"alpha2\":\"CG\",\"alpha3\":\"COG\",\"region\":\"Africa\"},{\"name\":\"Congo, Democratic Republic of the\",\"alpha2\":\"CD\",\"alpha3\":\"COD\",\"region\":\"Africa\"},{\"name\":\"Cook Islands\",\"alpha2\":\"CK\",\"alpha3\":\"COK\",\"region\":\"Oceania\"},{\"name\":\"Costa Rica\",\"alpha2\":\"CR\",\"alpha3\":\"CRI\",\"region\":\"Americas\"},{\"name\":\"Croatia\",\"alpha2\":\"HR\",\"alpha3\":\"HRV\",\"region\":\"Europe\"},{\"name\":\"Cuba\",\"alpha2\":\"CU\",\"alpha3\":\"CUB\",\"region\":\"Americas\"},{\"name\":\"Curaçao\",\"alpha2\":\"CW\",\"alpha3\":\"CUW\",\"region\":\"Americas\"},{\"name\":\"Cyprus\",\"alpha2\":\"CY\",\"alpha3\":\"CYP\",\"region\":\"Asia\"},{\"name\":\"Czechia\",\"alpha2\":\"CZ\",\"alpha3\":\"CZE\",\"region\":\"Europe\"},{\"name\":\"Denmark\",\"alpha2\":\"DK\",\"alpha3\":\"DNK\",\"region\":\"Europe\"},{\"name\":\"Djibouti\",\"alpha2\":\"DJ\",\"alpha3\":\"DJI\",\"region\":\"Africa\"},{\"name\":\"Dominica\",\"alpha2\":\"DM\",\"alpha3\":\"DMA\",\"region\":\"Americas\"},{\"name\":\"Dominican Republic\",\"alpha2\":\"DO\",\"alpha3\":\"DOM\",\"region\":\"Americas\"},{\"name\":\"Ecuador\",\"alpha2\":\"EC\",\"alpha3\":\"ECU\",\"region\":\"Americas\"},{\"name\":\"Egypt\",\"alpha2\":\"EG\",\"alpha3\":\"EGY\",\"region\":\"Africa\"},{\"name\":\"El Salvador\",\"alpha2\":\"SV\",\"alpha3\":\"SLV\",\"region\":\"Americas\"},{\"name\":\"Equatorial Guinea\",\"alpha2\":\"GQ\",\"alpha3\":\"GNQ\",\"region\":\"Africa\"},{\"name\":\"Eritrea\",\"alpha2\":\"ER\",\"alpha3\":\"ERI\",\"region\":\"Africa\"},{\"name\":\"Estonia\",\"alpha2\":\"EE\",\"alpha3\":\"EST\",\"region\":\"Europe\"},{\"name\":\"Eswatini\",\"alpha2\":\"SZ\",\"alpha3\":\"SWZ\",\"region\":\"Africa\"},{\"name\":\"Ethiopia\",\"alpha2\":\"ET\",\"alpha3\":\"ETH\",\"region\":\"Africa\"},{\"name\":\"Falkland Islands (Malvinas)\",\"alpha2\":\"FK\",\"alpha3\":\"FLK\",\"region\":\"Americas\"},{\"name\":\"Faroe Islands\",\"alpha2\":\"FO\",\"alpha3\":\"FRO\",\"region\":\"Europe\"},{\"name\":\"Fiji\",\"alpha2\":\"FJ\",\"alpha3\":\"FJI\",\"region\":\"Oceania\"},{\"name\":\"Finland\",\"alpha2\":\"FI\",\"alpha3\":\"FIN\",\"region\":\"Europe\"},{\"name\":\"France\",\"alpha2\":\"FR\",\"alpha3\":\"FRA\",\"region\":\"Europe\"},{\"name\":\"French Guiana\",\"alpha2\":\"GF\",\"alpha3\":\"GUF\",\"region\":\"Americas\"},{\"name\":\"French Polynesia\",\"alpha2\":\"PF\",\"alpha3\":\"PYF\",\"region\":\"Oceania\"},{\"name\":\"French Southern Territories\",\"alpha2\":\"TF\",\"alpha3\":\"ATF\",\"region\":\"Africa\"},{\"name\":\"Gabon\",\"alpha2\":\"GA\",\"alpha3\":\"GAB\",\"region\":\"Africa\"},{\"name\":\"Gambia\",\"alpha2\":\"GM\",\"alpha3\":\"GMB\",\"region\":\"Africa\"},{\"name\":\"Georgia\",\"alpha2\":\"GE\",\"alpha3\":\"GEO\",\"region\":\"Asia\"},{\"name\":\"Germany\",\"alpha2\":\"DE\",\"alpha3\":\"DEU\",\"region\":\"Europe\"},{\"name\":\"Ghana\",\"alpha2\":\"GH\",\"alpha3\":\"GHA\",\"region\":\"Africa\"},{\"name\":\"Gibraltar\",\"alpha2\":\"GI\",\"alpha3\":\"GIB\",\"region\":\"Europe\"},{\"name\":\"Greece\",\"alpha2\":\"GR\",\"alpha3\":\"GRC\",\"region\":\"Europe\"},{\"name\":\"Greenland\",\"alpha2\":\"GL\",\"alpha3\":\"GRL\",\"region\":\"Americas\"},{\"name\":\"Grenada\",\"alpha2\":\"GD\",\"alpha3\":\"GRD\",\"region\":\"Americas\"},{\"name\":\"Guadeloupe\",\"alpha2\":\"GP\",\"alpha3\":\"GLP\",\"region\":\"Americas\"},{\"name\":\"Guam\",\"alpha2\":\"GU\",\"alpha3\":\"GUM\",\"region\":\"Oceania\"},{\"name\":\"Guatemala\",\"alpha2\":\"GT\",\"alpha3\":\"GTM\",\"region\":\"Americas\"},{\"name\":\"Guernsey\",\"alpha2\":\"GG\",\"alpha3\":\"GGY\",\"region\":\"Europe\"},{\"name\":\"Guinea\",\"alpha2\":\"GN\",\"alpha3\":\"GIN\",\"region\":\"Africa\"},{\"name\":\"Guinea-Bissau\",\"alpha2\":\"GW\",\"alpha3\":\"GNB\",\"region\":\"Africa\"},{\"name\":\"Guyana\",\"alpha2\":\"GY\",\"alpha3\":\"GUY\",\"region\":\"Americas\"},{\"name\":\"Haiti\",\"alpha2\":\"HT\",\"alpha3\":\"HTI\",\"region\":\"Americas\"},{\"name\":\"Heard Island and McDonald Islands\",\"alpha2\":\"HM\",\"alpha3\":\"HMD\",\"region\":\"Oceania\"},{\"name\":\"Holy See\",\"alpha2\":\"VA\",\"alpha3\":\"VAT\",\"region\":\"Europe\"},{\"name\":\"Honduras\",\"alpha2\":\"HN\",\"alpha3\":\"HND\",\"region\":\"Americas\"},{\"name\":\"Hong Kong\",\"alpha2\":\"HK\",\"alpha3\":\"HKG\",\"region\":\"Asia\"},{\"name\":\"Hungary\",\"alpha2\":\"HU\",\"alpha3\":\"HUN\",\"region\":\"Europe\"},{\"name\":\"Iceland\",\"alpha2\":\"IS\",\"alpha3\":\"ISL\",\"region\":\"Europe\"},{\"name\":\"India\",\"alpha2\":\"IN\",\"alpha3\":\"IND\",\"region\":\"Asia\"},{\"name\":\"Indonesia\",\"alpha2\":\"ID\",\"alpha3\":\"IDN\",\"region\":\"Asia\"},{\"name\":\"Iran (Islamic Republic of)\",\"alpha2\":\"IR\",\"alpha3\":\"IRN\",\"region\":\"Asia\"},{\"name\":\"Iraq\",\"alpha2\":\"IQ\",\"alpha3\":\"IRQ\",\"region\":\"Asia\"},{\"name\":\"Ireland\",\"alpha2\":\"IE\",\"alpha3\":\"IRL\",\"region\":\"Europe\"},{\"name\":\"Isle of Man\",\"alpha2\":\"IM\",\"alpha3\":\"IMN\",\"region\":\"Europe\"},{\"name\":\"Israel\",\"alpha2\":\"IL\",\"alpha3\":\"ISR\",\"region\":\"Asia\"},{\"name\":\"Italy\",\"alpha2\":\"IT\",\"alpha3\":\"ITA\",\"region\":\"Europe\"},{\"name\":\"Jamaica\",\"alpha2\":\"JM\",\"alpha3\":\"JAM\",\"region\":\"Americas\"},{\"name\":\"Japan\",\"alpha2\":\"JP\",\"alpha3\":\"JPN\",\"region\":\"Asia\"},{\"name\":\"Jersey\",\"alpha2\":\"JE\",\"alpha3\":\"JEY\",\"region\":\"Europe\"},{\"name\":\"Jordan\",\"alpha2\":\"JO\",\"alpha3\":\"JOR\",\"region\":\"Asia\"},{\"name\":\"Kazakhstan\",\"alpha2\":\"KZ\",\"alpha3\":\"KAZ\",\"region\":\"Asia\"},{\"name\":\"Kenya\",\"alpha2\":\"KE\",\"alpha3\":\"KEN\",\"region\":\"Africa\"},{\"name\":\"Kiribati\",\"alpha2\":\"KI\",\"alpha3\":\"KIR\",\"region\":\"Oceania\"},{\"name\":\"Korea, Republic of\",\"alpha2\":\"KR\",\"alpha3\":\"KOR\",\"region\":\"Asia\"},{\"name\":\"Kuwait\",\"alpha2\":\"KW\",\"alpha3\":\"KWT\",\"region\":\"Asia\"},{\"name\":\"Kyrgyzstan\",\"alpha2\":\"KG\",\"alpha3\":\"KGZ\",\"region\":\"Asia\"},{\"name\":\"Latvia\",\"alpha2\":\"LV\",\"alpha3\":\"LVA\",\"region\":\"Europe\"},{\"name\":\"Lebanon\",\"alpha2\":\"LB\",\"alpha3\":\"LBN\",\"region\":\"Asia\"},{\"name\":\"Lesotho\",\"alpha2\":\"LS\",\"alpha3\":\"LSO\",\"region\":\"Africa\"},{\"name\":\"Liberia\",\"alpha2\":\"LR\",\"alpha3\":\"LBR\",\"region\":\"Africa\"},{\"name\":\"Libya\",\"alpha2\":\"LY\",\"alpha3\":\"LBY\",\"region\":\"Africa\"},{\"name\":\"Liechtenstein\",\"alpha2\":\"LI\",\"alpha3\":\"LIE\",\"region\":\"Europe\"},{\"name\":\"Lithuania\",\"alpha2\":\"LT\",\"alpha3\":\"LTU\",\"region\":\"Europe\"},{\"name\":\"Luxembourg\",\"alpha2\":\"LU\",\"alpha3\":\"LUX\",\"region\":\"Europe\"},{\"name\":\"Macao\",\"alpha2\":\"MO\",\"alpha3\":\"MAC\",\"region\":\"Asia\"},{\"name\":\"Madagascar\",\"alpha2\":\"MG\",\"alpha3\":\"MDG\",\"region\":\"Africa\"},{\"name\":\"Malawi\",\"alpha2\":\"MW\",\"alpha3\":\"MWI\",\"region\":\"Africa\"},{\"name\":\"Malaysia\",\"alpha2\":\"MY\",\"alpha3\":\"MYS\",\"region\":\"Asia\"},{\"name\":\"Maldives\",\"alpha2\":\"MV\",\"alpha3\":\"MDV\",\"region\":\"Asia\"},{\"name\":\"Mali\",\"alpha2\":\"ML\",\"alpha3\":\"MLI\",\"region\":\"Africa\"},{\"name\":\"Malta\",\"alpha2\":\"MT\",\"alpha3\":\"MLT\",\"region\":\"Europe\"},{\"name\":\"Marshall Islands\",\"alpha2\":\"MH\",\"alpha3\":\"MHL\",\"region\":\"Oceania\"},{\"name\":\"Martinique\",\"alpha2\":\"MQ\",\"alpha3\":\"MTQ\",\"region\":\"Americas\"},{\"name\":\"Mauritania\",\"alpha2\":\"MR\",\"alpha3\":\"MRT\",\"region\":\"Africa\"},{\"name\":\"Mauritius\",\"alpha2\":\"MU\",\"alpha3\":\"MUS\",\"region\":\"Africa\"},{\"name\":\"Mayotte\",\"alpha2\":\"YT\",\"alpha3\":\"MYT\",\"region\":\"Africa\"},{\"name\":\"Mexico\",\"alpha2\":\"MX\",\"alpha3\":\"MEX\",\"region\":\"Americas\"},{\"name\":\"Micronesia (Federated States of)\",\"alpha2\":\"FM\",\"alpha3\":\"FSM\",\"region\":\"Oceania\"},{\"name\":\"Moldova, Republic of\",\"alpha2\":\"MD\",\"alpha3\":\"MDA\",\"region\":\"Europe\"},{\"name\":\"Monaco\",\"alpha2\":\"MC\",\"alpha3\":\"MCO\",\"region\":\"Europe\"},{\"name\":\"Mongolia\",\"alpha2\":\"MN\",\"alpha3\":\"MNG\",\"region\":\"Asia\"},{\"name\":\"Montenegro\",\"alpha2\":\"ME\",\"alpha3\":\"MNE\",\"region\":\"Europe\"},{\"name\":\"Montserrat\",\"alpha2\":\"MS\",\"alpha3\":\"MSR\",\"region\":\"Americas\"},{\"name\":\"Morocco\",\"alpha2\":\"MA\",\"alpha3\":\"MAR\",\"region\":\"Africa\"},{\"name\":\"Mozambique\",\"alpha2\":\"MZ\",\"alpha3\":\"MOZ\",\"region\":\"Africa\"},{\"name\":\"Myanmar\",\"alpha2\":\"MM\",\"alpha3\":\"MMR\",\"region\":\"Asia\"},{\"name\":\"Namibia\",\"alpha2\":\"NA\",\"alpha3\":\"NAM\",\"region\":\"Africa\"},{\"name\":\"Nauru\",\"alpha2\":\"NR\",\"alpha3\":\"NRU\",\"region\":\"Oceania\"},{\"name\":\"Nepal\",\"alpha2\":\"NP\",\"alpha3\":\"NPL\",\"region\":\"Asia\"},{\"name\":\"Netherlands\",\"alpha2\":\"NL\",\"alpha3\":\"NLD\",\"region\":\"Europe\"},{\"name\":\"New Caledonia\",\"alpha2\":\"NC\",\"alpha3\":\"NCL\",\"region\":\"Oceania\"},{\"name\":\"New Zealand\",\"alpha2\":\"NZ\",\"alpha3\":\"NZL\",\"region\":\"Oceania\"},{\"name\":\"Nicaragua\",\"alpha2\":\"NI\",\"alpha3\":\"NIC\",\"region\":\"Americas\"},{\"name\":\"Niger\",\"alpha2\":\"NE\",\"alpha3\":\"NER\",\"region\":\"Africa\"},{\"name\":\"Nigeria\",\"alpha2\":\"NG\",\"alpha3\":\"NGA\",\"region\":\"Africa\"},{\"name\":\"Niue\",\"alpha2\":\"NU\",\"alpha3\":\"NIU\",\"region\":\"Oceania\"},{\"name\":\"Norfolk Island\",\"alpha2\":\"NF\",\"alpha3\":\"NFK\",\"region\":\"Oceania\"},{\"name\":\"North Macedonia\",\"alpha2\":\"MK\",\"alpha3\":\"MKD\",\"region\":\"Europe\"},{\"name\":\"Northern Mariana Islands\",\"alpha2\":\"MP\",\"alpha3\":\"MNP\",\"region\":\"Oceania\"},{\"name\":\"Norway\",\"alpha2\":\"NO\",\"alpha3\":\"NOR\",\"region\":\"Europe\"},{\"name\":\"Oman\",\"alpha2\":\"OM\",\"alpha3\":\"OMN\",\"region\":\"Asia\"},{\"name\":\"Pakistan\",\"alpha2\":\"PK\",\"alpha3\":\"PAK\",\"region\":\"Asia\"},{\"name\":\"Palau\",\"alpha2\":\"PW\",\"alpha3\":\"PLW\",\"region\":\"Oceania\"},{\"name\":\"Palestine, State of\",\"alpha2\":\"PS\",\"alpha3\":\"PSE\",\"region\":\"Asia\"},{\"name\":\"Panama\",\"alpha2\":\"PA\",\"alpha3\":\"PAN\",\"region\":\"Americas\"},{\"name\":\"Papua New Guinea\",\"alpha2\":\"PG\",\"alpha3\":\"PNG\",\"region\":\"Oceania\"},{\"name\":\"Paraguay\",\"alpha2\":\"PY\",\"alpha3\":\"PRY\",\"region\":\"Americas\"},{\"name\":\"Peru\",\"alpha2\":\"PE\",\"alpha3\":\"PER\",\"region\":\"Americas\"},{\"name\":\"Philippines\",\"alpha2\":\"PH\",\"alpha3\":\"PHL\",\"region\":\"Asia\"},{\"name\":\"Pitcairn\",\"alpha2\":\"PN\",\"alpha3\":\"PCN\",\"region\":\"Oceania\"},{\"name\":\"Poland\",\"alpha2\":\"PL\",\"alpha3\":\"POL\",\"region\":\"Europe\"},{\"name\":\"Portugal\",\"alpha2\":\"PT\",\"alpha3\":\"PRT\",\"region\":\"Europe\"},{\"name\":\"Puerto Rico\",\"alpha2\":\"PR\",\"alpha3\":\"PRI\",\"region\":\"Americas\"},{\"name\":\"Qatar\",\"alpha2\":\"QA\",\"alpha3\":\"QAT\",\"region\":\"Asia\"},{\"name\":\"Réunion\",\"alpha2\":\"RE\",\"alpha3\":\"REU\",\"region\":\"Africa\"},{\"name\":\"Romania\",\"alpha2\":\"RO\",\"alpha3\":\"ROU\",\"region\":\"Europe\"},{\"name\":\"Russian Federation\",\"alpha2\":\"RU\",\"alpha3\":\"RUS\",\"region\":\"Europe\"},{\"name\":\"Rwanda\",\"alpha2\":\"RW\",\"alpha3\":\"RWA\",\"region\":\"Africa\"},{\"name\":\"Saint Barthélemy\",\"alpha2\":\"BL\",\"alpha3\":\"BLM\",\"region\":\"Americas\"},{\"name\":\"Saint Helena, Ascension and Tristan da Cunha\",\"alpha2\":\"SH\",\"alpha3\":\"SHN\",\"region\":\"Africa\"},{\"name\":\"Saint Kitts and Nevis\",\"alpha2\":\"KN\",\"alpha3\":\"KNA\",\"region\":\"Americas\"},{\"name\":\"Saint Lucia\",\"alpha2\":\"LC\",\"alpha3\":\"LCA\",\"region\":\"Americas\"},{\"name\":\"Saint Martin (French part)\",\"alpha2\":\"MF\",\"alpha3\":\"MAF\",\"region\":\"Americas\"},{\"name\":\"Saint Pierre and Miquelon\",\"alpha2\":\"PM\",\"alpha3\":\"SPM\",\"region\":\"Americas\"},{\"name\":\"Saint Vincent and the Grenadines\",\"alpha2\":\"VC\",\"alpha3\":\"VCT\",\"region\":\"Americas\"},{\"name\":\"Samoa\",\"alpha2\":\"WS\",\"alpha3\":\"WSM\",\"region\":\"Oceania\"},{\"name\":\"San Marino\",\"alpha2\":\"SM\",\"alpha3\":\"SMR\",\"region\":\"Europe\"},{\"name\":\"Sao Tome and Principe\",\"alpha2\":\"ST\",\"alpha3\":\"STP\",\"region\":\"Africa\"},{\"name\":\"Saudi Arabia\",\"alpha2\":\"SA\",\"alpha3\":\"SAU\",\"region\":\"Asia\"},{\"name\":\"Senegal\",\"alpha2\":\"SN\",\"alpha3\":\"SEN\",\"region\":\"Africa\"},{\"name\":\"Serbia\",\"alpha2\":\"RS\",\"alpha3\":\"SRB\",\"region\":\"Europe\"},{\"name\":\"Seychelles\",\"alpha2\":\"SC\",\"alpha3\":\"SYC\",\"region\":\"Africa\"},{\"name\":\"Sierra Leone\",\"alpha2\":\"SL\",\"alpha3\":\"SLE\",\"region\":\"Africa\"},{\"name\":\"Singapore\",\"alpha2\":\"SG\",\"alpha3\":\"SGP\",\"region\":\"Asia\"},{\"name\":\"Sint Maarten (Dutch part)\",\"alpha2\":\"SX\",\"alpha3\":\"SXM\",\"region\":\"Americas\"},{\"name\":\"Slovakia\",\"alpha2\":\"SK\",\"alpha3\":\"SVK\",\"region\":\"Europe\"},{\"name\":\"Slovenia\",\"alpha2\":\"SI\",\"alpha3\":\"SVN\",\"region\":\"Europe\"},{\"name\":\"Solomon Islands\",\"alpha2\":\"SB\",\"alpha3\":\"SLB\",\"region\":\"Oceania\"},{\"name\":\"Somalia\",\"alpha2\":\"SO\",\"alpha3\":\"SOM\",\"region\":\"Africa\"},{\"name\":\"South Africa\",\"alpha2\":\"ZA\",\"alpha3\":\"ZAF\",\"region\":\"Africa\"},{\"name\":\"South Georgia and the South Sandwich Islands\",\"alpha2\":\"GS\",\"alpha3\":\"SGS\",\"region\":\"Americas\"},{\"name\":\"South Sudan\",\"alpha2\":\"SS\",\"alpha3\":\"SSD\",\"region\":\"Africa\"},{\"name\":\"Spain\",\"alpha2\":\"ES\",\"alpha3\":\"ESP\",\"region\":\"Europe\"},{\"name\":\"Sri Lanka\",\"alpha2\":\"LK\",\"alpha3\":\"LKA\",\"region\":\"Asia\"},{\"name\":\"Sudan\",\"alpha2\":\"SD\",\"alpha3\":\"SDN\",\"region\":\"Africa\"},{\"name\":\"Suriname\",\"alpha2\":\"SR\",\"alpha3\":\"SUR\",\"region\":\"Americas\"},{\"name\":\"Svalbard and Jan Mayen\",\"alpha2\":\"SJ\",\"alpha3\":\"SJM\",\"region\":\"Europe\"},{\"name\":\"Sweden\",\"alpha2\":\"SE\",\"alpha3\":\"SWE\",\"region\":\"Europe\"},{\"name\":\"Switzerland\",\"alpha2\":\"CH\",\"alpha3\":\"CHE\",\"region\":\"Europe\"},{\"name\":\"Syrian Arab Republic\",\"alpha2\":\"SY\",\"alpha3\":\"SYR\",\"region\":\"Asia\"},{\"name\":\"Taiwan, Province of China\",\"alpha2\":\"TW\",\"alpha3\":\"TWN\",\"region\":\"Asia\"},{\"name\":\"Tajikistan\",\"alpha2\":\"TJ\",\"alpha3\":\"TJK\",\"region\":\"Asia\"},{\"name\":\"Tanzania, United Republic of\",\"alpha2\":\"TZ\",\"alpha3\":\"TZA\",\"region\":\"Africa\"},{\"name\":\"Thailand\",\"alpha2\":\"TH\",\"alpha3\":\"THA\",\"region\":\"Asia\"},{\"name\":\"Timor-Leste\",\"alpha2\":\"TL\",\"alpha3\":\"TLS\",\"region\":\"Asia\"},{\"name\":\"Togo\",\"alpha2\":\"TG\",\"alpha3\":\"TGO\",\"region\":\"Africa\"},{\"name\":\"Tokelau\",\"alpha2\":\"TK\",\"alpha3\":\"TKL\",\"region\":\"Oceania\"},{\"name\":\"Tonga\",\"alpha2\":\"TO\",\"alpha3\":\"TON\",\"region\":\"Oceania\"},{\"name\":\"Trinidad and Tobago\",\"alpha2\":\"TT\",\"alpha3\":\"TTO\",\"region\":\"Americas\"},{\"name\":\"Tunisia\",\"alpha2\":\"TN\",\"alpha3\":\"TUN\",\"region\":\"Africa\"},{\"name\":\"Turkey\",\"alpha2\":\"TR\",\"alpha3\":\"TUR\",\"region\":\"Asia\"},{\"name\":\"Turkmenistan\",\"alpha2\":\"TM\",\"alpha3\":\"TKM\",\"region\":\"Asia\"},{\"name\":\"Turks and Caicos Islands\",\"alpha2\":\"TC\",\"alpha3\":\"TCA\",\"region\":\"Americas\"},{\"name\":\"Tuvalu\",\"alpha2\":\"TV\",\"alpha3\":\"TUV\",\"region\":\"Oceania\"},{\"name\":\"Uganda\",\"alpha2\":\"UG\",\"alpha3\":\"UGA\",\"region\":\"Africa\"},{\"name\":\"Ukraine\",\"alpha2\":\"UA\",\"alpha3\":\"UKR\",\"region\":\"Europe\"},{\"name\":\"United Arab Emirates\",\"alpha2\":\"AE\",\"alpha3\":\"ARE\",\"region\":\"Asia\"},{\"name\":\"United Kingdom of Great Britain and Northern Ireland\",\"alpha2\":\"GB\",\"alpha3\":\"GBR\",\"region\":\"Europe\"},{\"name\":\"United States of America\",\"alpha2\":\"US\",\"alpha3\":\"USA\",\"region\":\"Americas\"},{\"name\":\"United States Minor Outlying Islands\",\"alpha2\":\"UM\",\"alpha3\":\"UMI\",\"region\":\"Oceania\"},{\"name\":\"Uruguay\",\"alpha2\":\"UY\",\"alpha3\":\"URY\",\"region\":\"Americas\"},{\"name\":\"Uzbekistan\",\"alpha2\":\"UZ\",\"alpha3\":\"UZB\",\"region\":\"Asia\"},{\"name\":\"Vanuatu\",\"alpha2\":\"VU\",\"alpha3\":\"VUT\",\"region\":\"Oceania\"},{\"name\":\"Venezuela (Bolivarian Republic of)\",\"alpha2\":\"VE\",\"alpha3\":\"VEN\",\"region\":\"Americas\"},{\"name\":\"Viet Nam\",\"alpha2\":\"VN\",\"alpha3\":\"VNM\",\"region\":\"Asia\"},{\"name\":\"Virgin Islands (British)\",\"alpha2\":\"VG\",\"alpha3\":\"VGB\",\"region\":\"Americas\"},{\"name\":\"Virgin Islands (U.S.)\",\"alpha2\":\"VI\",\"alpha3\":\"VIR\",\"region\":\"Americas\"},{\"name\":\"Wallis and Futuna\",\"alpha2\":\"WF\",\"alpha3\":\"WLF\",\"region\":\"Oceania\"},{\"name\":\"Western Sahara\",\"alpha2\":\"EH\",\"alpha3\":\"ESH\",\"region\":\"Africa\"},{\"name\":\"Yemen\",\"alpha2\":\"YE\",\"alpha3\":\"YEM\",\"region\":\"Asia\"},{\"name\":\"Zambia\",\"alpha2\":\"ZM\",\"alpha3\":\"ZMB\",\"region\":\"Africa\"},{\"name\":\"Zimbabwe\",\"alpha2\":\"ZW\",\"alpha3\":\"ZWE\",\"region\":\"Africa\"},{\"name\":\"Byteland PROD\",\"alpha2\":\"YY\",\"alpha3\":\"YYY\",\"region\":\"Europe\"}];",
|
||
"",
|
||
"pm.test(`List all countries`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + `/countries`;",
|
||
"",
|
||
" pm.sendRequest(url, function (err, response) {",
|
||
" pm.test(`Validate response`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" const expected = countries.sort(function(a, b) {",
|
||
" var x = a.alpha2; var y = b.alpha2;",
|
||
" return ((x < y) ? -1 : ((x > y) ? 1 : 0));",
|
||
" });",
|
||
"",
|
||
" console.log(\"got\", resp);",
|
||
" pm.expect(resp).to.have.lengthOf(expected.length, `Invalid response array length`);",
|
||
"",
|
||
" pm.test('Validate if the returned list is sorted by alpha2 code (openapi.yml line #56)', () => {",
|
||
" for (var i = 0; i < expected.length; i++) {",
|
||
" pm.expect(resp[i].alpha2).to.be.eq(expected[i].alpha2, `Invalid alpha2 code of country #${i}`);",
|
||
" pm.expect(resp[i].alpha3).to.be.eq(expected[i].alpha3, `Invalid alpha3 code of country #${i}`);",
|
||
" pm.expect(resp[i].name).to.be.eq(expected[i].name, `Invalid name of country #${i}`);",
|
||
" }",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/countries",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"countries"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "List countries by regions",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"array\",",
|
||
" \"items\": {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о стране из стандарта ISO 3166\",",
|
||
" \"properties\": {",
|
||
" \"name\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Полное название страны\",",
|
||
" \"maxLength\": 100",
|
||
" },",
|
||
" \"alpha2\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"alpha3\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Трехбуквенный код страны\",",
|
||
" \"maxLength\": 3,",
|
||
" \"pattern\": \"[a-zA-Z]{3}\"",
|
||
" },",
|
||
" \"region\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Географический регион, к которому относится страна\",",
|
||
" \"enum\": [",
|
||
" \"Europe\",",
|
||
" \"Africa\",",
|
||
" \"Americas\",",
|
||
" \"Oceania\",",
|
||
" \"Asia\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"name\",",
|
||
" \"alpha2\",",
|
||
" \"alpha3\"",
|
||
" ]",
|
||
" },",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"const countries = [{\"name\":\"Afghanistan\",\"alpha2\":\"AF\",\"alpha3\":\"AFG\",\"region\":\"Asia\"},{\"name\":\"Åland Islands\",\"alpha2\":\"AX\",\"alpha3\":\"ALA\",\"region\":\"Europe\"},{\"name\":\"Albania\",\"alpha2\":\"AL\",\"alpha3\":\"ALB\",\"region\":\"Europe\"},{\"name\":\"Algeria\",\"alpha2\":\"DZ\",\"alpha3\":\"DZA\",\"region\":\"Africa\"},{\"name\":\"American Samoa\",\"alpha2\":\"AS\",\"alpha3\":\"ASM\",\"region\":\"Oceania\"},{\"name\":\"Andorra\",\"alpha2\":\"AD\",\"alpha3\":\"AND\",\"region\":\"Europe\"},{\"name\":\"Angola\",\"alpha2\":\"AO\",\"alpha3\":\"AGO\",\"region\":\"Africa\"},{\"name\":\"Anguilla\",\"alpha2\":\"AI\",\"alpha3\":\"AIA\",\"region\":\"Americas\"},{\"name\":\"Antigua and Barbuda\",\"alpha2\":\"AG\",\"alpha3\":\"ATG\",\"region\":\"Americas\"},{\"name\":\"Argentina\",\"alpha2\":\"AR\",\"alpha3\":\"ARG\",\"region\":\"Americas\"},{\"name\":\"Armenia\",\"alpha2\":\"AM\",\"alpha3\":\"ARM\",\"region\":\"Asia\"},{\"name\":\"Aruba\",\"alpha2\":\"AW\",\"alpha3\":\"ABW\",\"region\":\"Americas\"},{\"name\":\"Australia\",\"alpha2\":\"AU\",\"alpha3\":\"AUS\",\"region\":\"Oceania\"},{\"name\":\"Austria\",\"alpha2\":\"AT\",\"alpha3\":\"AUT\",\"region\":\"Europe\"},{\"name\":\"Azerbaijan\",\"alpha2\":\"AZ\",\"alpha3\":\"AZE\",\"region\":\"Asia\"},{\"name\":\"Bahamas\",\"alpha2\":\"BS\",\"alpha3\":\"BHS\",\"region\":\"Americas\"},{\"name\":\"Bahrain\",\"alpha2\":\"BH\",\"alpha3\":\"BHR\",\"region\":\"Asia\"},{\"name\":\"Bangladesh\",\"alpha2\":\"BD\",\"alpha3\":\"BGD\",\"region\":\"Asia\"},{\"name\":\"Barbados\",\"alpha2\":\"BB\",\"alpha3\":\"BRB\",\"region\":\"Americas\"},{\"name\":\"Belarus\",\"alpha2\":\"BY\",\"alpha3\":\"BLR\",\"region\":\"Europe\"},{\"name\":\"Belgium\",\"alpha2\":\"BE\",\"alpha3\":\"BEL\",\"region\":\"Europe\"},{\"name\":\"Belize\",\"alpha2\":\"BZ\",\"alpha3\":\"BLZ\",\"region\":\"Americas\"},{\"name\":\"Benin\",\"alpha2\":\"BJ\",\"alpha3\":\"BEN\",\"region\":\"Africa\"},{\"name\":\"Bermuda\",\"alpha2\":\"BM\",\"alpha3\":\"BMU\",\"region\":\"Americas\"},{\"name\":\"Bhutan\",\"alpha2\":\"BT\",\"alpha3\":\"BTN\",\"region\":\"Asia\"},{\"name\":\"Bolivia (Plurinational State of)\",\"alpha2\":\"BO\",\"alpha3\":\"BOL\",\"region\":\"Americas\"},{\"name\":\"Bonaire, Sint Eustatius and Saba\",\"alpha2\":\"BQ\",\"alpha3\":\"BES\",\"region\":\"Americas\"},{\"name\":\"Bosnia and Herzegovina\",\"alpha2\":\"BA\",\"alpha3\":\"BIH\",\"region\":\"Europe\"},{\"name\":\"Botswana\",\"alpha2\":\"BW\",\"alpha3\":\"BWA\",\"region\":\"Africa\"},{\"name\":\"Bouvet Island\",\"alpha2\":\"BV\",\"alpha3\":\"BVT\",\"region\":\"Americas\"},{\"name\":\"Brazil\",\"alpha2\":\"BR\",\"alpha3\":\"BRA\",\"region\":\"Americas\"},{\"name\":\"British Indian Ocean Territory\",\"alpha2\":\"IO\",\"alpha3\":\"IOT\",\"region\":\"Africa\"},{\"name\":\"Brunei Darussalam\",\"alpha2\":\"BN\",\"alpha3\":\"BRN\",\"region\":\"Asia\"},{\"name\":\"Bulgaria\",\"alpha2\":\"BG\",\"alpha3\":\"BGR\",\"region\":\"Europe\"},{\"name\":\"Burkina Faso\",\"alpha2\":\"BF\",\"alpha3\":\"BFA\",\"region\":\"Africa\"},{\"name\":\"Burundi\",\"alpha2\":\"BI\",\"alpha3\":\"BDI\",\"region\":\"Africa\"},{\"name\":\"Cabo Verde\",\"alpha2\":\"CV\",\"alpha3\":\"CPV\",\"region\":\"Africa\"},{\"name\":\"Cambodia\",\"alpha2\":\"KH\",\"alpha3\":\"KHM\",\"region\":\"Asia\"},{\"name\":\"Cameroon\",\"alpha2\":\"CM\",\"alpha3\":\"CMR\",\"region\":\"Africa\"},{\"name\":\"Canada\",\"alpha2\":\"CA\",\"alpha3\":\"CAN\",\"region\":\"Americas\"},{\"name\":\"Cayman Islands\",\"alpha2\":\"KY\",\"alpha3\":\"CYM\",\"region\":\"Americas\"},{\"name\":\"Central African Republic\",\"alpha2\":\"CF\",\"alpha3\":\"CAF\",\"region\":\"Africa\"},{\"name\":\"Chad\",\"alpha2\":\"TD\",\"alpha3\":\"TCD\",\"region\":\"Africa\"},{\"name\":\"Chile\",\"alpha2\":\"CL\",\"alpha3\":\"CHL\",\"region\":\"Americas\"},{\"name\":\"China\",\"alpha2\":\"CN\",\"alpha3\":\"CHN\",\"region\":\"Asia\"},{\"name\":\"Christmas Island\",\"alpha2\":\"CX\",\"alpha3\":\"CXR\",\"region\":\"Oceania\"},{\"name\":\"Cocos (Keeling) Islands\",\"alpha2\":\"CC\",\"alpha3\":\"CCK\",\"region\":\"Oceania\"},{\"name\":\"Colombia\",\"alpha2\":\"CO\",\"alpha3\":\"COL\",\"region\":\"Americas\"},{\"name\":\"Comoros\",\"alpha2\":\"KM\",\"alpha3\":\"COM\",\"region\":\"Africa\"},{\"name\":\"Congo\",\"alpha2\":\"CG\",\"alpha3\":\"COG\",\"region\":\"Africa\"},{\"name\":\"Congo, Democratic Republic of the\",\"alpha2\":\"CD\",\"alpha3\":\"COD\",\"region\":\"Africa\"},{\"name\":\"Cook Islands\",\"alpha2\":\"CK\",\"alpha3\":\"COK\",\"region\":\"Oceania\"},{\"name\":\"Costa Rica\",\"alpha2\":\"CR\",\"alpha3\":\"CRI\",\"region\":\"Americas\"},{\"name\":\"Croatia\",\"alpha2\":\"HR\",\"alpha3\":\"HRV\",\"region\":\"Europe\"},{\"name\":\"Cuba\",\"alpha2\":\"CU\",\"alpha3\":\"CUB\",\"region\":\"Americas\"},{\"name\":\"Curaçao\",\"alpha2\":\"CW\",\"alpha3\":\"CUW\",\"region\":\"Americas\"},{\"name\":\"Cyprus\",\"alpha2\":\"CY\",\"alpha3\":\"CYP\",\"region\":\"Asia\"},{\"name\":\"Czechia\",\"alpha2\":\"CZ\",\"alpha3\":\"CZE\",\"region\":\"Europe\"},{\"name\":\"Denmark\",\"alpha2\":\"DK\",\"alpha3\":\"DNK\",\"region\":\"Europe\"},{\"name\":\"Djibouti\",\"alpha2\":\"DJ\",\"alpha3\":\"DJI\",\"region\":\"Africa\"},{\"name\":\"Dominica\",\"alpha2\":\"DM\",\"alpha3\":\"DMA\",\"region\":\"Americas\"},{\"name\":\"Dominican Republic\",\"alpha2\":\"DO\",\"alpha3\":\"DOM\",\"region\":\"Americas\"},{\"name\":\"Ecuador\",\"alpha2\":\"EC\",\"alpha3\":\"ECU\",\"region\":\"Americas\"},{\"name\":\"Egypt\",\"alpha2\":\"EG\",\"alpha3\":\"EGY\",\"region\":\"Africa\"},{\"name\":\"El Salvador\",\"alpha2\":\"SV\",\"alpha3\":\"SLV\",\"region\":\"Americas\"},{\"name\":\"Equatorial Guinea\",\"alpha2\":\"GQ\",\"alpha3\":\"GNQ\",\"region\":\"Africa\"},{\"name\":\"Eritrea\",\"alpha2\":\"ER\",\"alpha3\":\"ERI\",\"region\":\"Africa\"},{\"name\":\"Estonia\",\"alpha2\":\"EE\",\"alpha3\":\"EST\",\"region\":\"Europe\"},{\"name\":\"Eswatini\",\"alpha2\":\"SZ\",\"alpha3\":\"SWZ\",\"region\":\"Africa\"},{\"name\":\"Ethiopia\",\"alpha2\":\"ET\",\"alpha3\":\"ETH\",\"region\":\"Africa\"},{\"name\":\"Falkland Islands (Malvinas)\",\"alpha2\":\"FK\",\"alpha3\":\"FLK\",\"region\":\"Americas\"},{\"name\":\"Faroe Islands\",\"alpha2\":\"FO\",\"alpha3\":\"FRO\",\"region\":\"Europe\"},{\"name\":\"Fiji\",\"alpha2\":\"FJ\",\"alpha3\":\"FJI\",\"region\":\"Oceania\"},{\"name\":\"Finland\",\"alpha2\":\"FI\",\"alpha3\":\"FIN\",\"region\":\"Europe\"},{\"name\":\"France\",\"alpha2\":\"FR\",\"alpha3\":\"FRA\",\"region\":\"Europe\"},{\"name\":\"French Guiana\",\"alpha2\":\"GF\",\"alpha3\":\"GUF\",\"region\":\"Americas\"},{\"name\":\"French Polynesia\",\"alpha2\":\"PF\",\"alpha3\":\"PYF\",\"region\":\"Oceania\"},{\"name\":\"French Southern Territories\",\"alpha2\":\"TF\",\"alpha3\":\"ATF\",\"region\":\"Africa\"},{\"name\":\"Gabon\",\"alpha2\":\"GA\",\"alpha3\":\"GAB\",\"region\":\"Africa\"},{\"name\":\"Gambia\",\"alpha2\":\"GM\",\"alpha3\":\"GMB\",\"region\":\"Africa\"},{\"name\":\"Georgia\",\"alpha2\":\"GE\",\"alpha3\":\"GEO\",\"region\":\"Asia\"},{\"name\":\"Germany\",\"alpha2\":\"DE\",\"alpha3\":\"DEU\",\"region\":\"Europe\"},{\"name\":\"Ghana\",\"alpha2\":\"GH\",\"alpha3\":\"GHA\",\"region\":\"Africa\"},{\"name\":\"Gibraltar\",\"alpha2\":\"GI\",\"alpha3\":\"GIB\",\"region\":\"Europe\"},{\"name\":\"Greece\",\"alpha2\":\"GR\",\"alpha3\":\"GRC\",\"region\":\"Europe\"},{\"name\":\"Greenland\",\"alpha2\":\"GL\",\"alpha3\":\"GRL\",\"region\":\"Americas\"},{\"name\":\"Grenada\",\"alpha2\":\"GD\",\"alpha3\":\"GRD\",\"region\":\"Americas\"},{\"name\":\"Guadeloupe\",\"alpha2\":\"GP\",\"alpha3\":\"GLP\",\"region\":\"Americas\"},{\"name\":\"Guam\",\"alpha2\":\"GU\",\"alpha3\":\"GUM\",\"region\":\"Oceania\"},{\"name\":\"Guatemala\",\"alpha2\":\"GT\",\"alpha3\":\"GTM\",\"region\":\"Americas\"},{\"name\":\"Guernsey\",\"alpha2\":\"GG\",\"alpha3\":\"GGY\",\"region\":\"Europe\"},{\"name\":\"Guinea\",\"alpha2\":\"GN\",\"alpha3\":\"GIN\",\"region\":\"Africa\"},{\"name\":\"Guinea-Bissau\",\"alpha2\":\"GW\",\"alpha3\":\"GNB\",\"region\":\"Africa\"},{\"name\":\"Guyana\",\"alpha2\":\"GY\",\"alpha3\":\"GUY\",\"region\":\"Americas\"},{\"name\":\"Haiti\",\"alpha2\":\"HT\",\"alpha3\":\"HTI\",\"region\":\"Americas\"},{\"name\":\"Heard Island and McDonald Islands\",\"alpha2\":\"HM\",\"alpha3\":\"HMD\",\"region\":\"Oceania\"},{\"name\":\"Holy See\",\"alpha2\":\"VA\",\"alpha3\":\"VAT\",\"region\":\"Europe\"},{\"name\":\"Honduras\",\"alpha2\":\"HN\",\"alpha3\":\"HND\",\"region\":\"Americas\"},{\"name\":\"Hong Kong\",\"alpha2\":\"HK\",\"alpha3\":\"HKG\",\"region\":\"Asia\"},{\"name\":\"Hungary\",\"alpha2\":\"HU\",\"alpha3\":\"HUN\",\"region\":\"Europe\"},{\"name\":\"Iceland\",\"alpha2\":\"IS\",\"alpha3\":\"ISL\",\"region\":\"Europe\"},{\"name\":\"India\",\"alpha2\":\"IN\",\"alpha3\":\"IND\",\"region\":\"Asia\"},{\"name\":\"Indonesia\",\"alpha2\":\"ID\",\"alpha3\":\"IDN\",\"region\":\"Asia\"},{\"name\":\"Iran (Islamic Republic of)\",\"alpha2\":\"IR\",\"alpha3\":\"IRN\",\"region\":\"Asia\"},{\"name\":\"Iraq\",\"alpha2\":\"IQ\",\"alpha3\":\"IRQ\",\"region\":\"Asia\"},{\"name\":\"Ireland\",\"alpha2\":\"IE\",\"alpha3\":\"IRL\",\"region\":\"Europe\"},{\"name\":\"Isle of Man\",\"alpha2\":\"IM\",\"alpha3\":\"IMN\",\"region\":\"Europe\"},{\"name\":\"Israel\",\"alpha2\":\"IL\",\"alpha3\":\"ISR\",\"region\":\"Asia\"},{\"name\":\"Italy\",\"alpha2\":\"IT\",\"alpha3\":\"ITA\",\"region\":\"Europe\"},{\"name\":\"Jamaica\",\"alpha2\":\"JM\",\"alpha3\":\"JAM\",\"region\":\"Americas\"},{\"name\":\"Japan\",\"alpha2\":\"JP\",\"alpha3\":\"JPN\",\"region\":\"Asia\"},{\"name\":\"Jersey\",\"alpha2\":\"JE\",\"alpha3\":\"JEY\",\"region\":\"Europe\"},{\"name\":\"Jordan\",\"alpha2\":\"JO\",\"alpha3\":\"JOR\",\"region\":\"Asia\"},{\"name\":\"Kazakhstan\",\"alpha2\":\"KZ\",\"alpha3\":\"KAZ\",\"region\":\"Asia\"},{\"name\":\"Kenya\",\"alpha2\":\"KE\",\"alpha3\":\"KEN\",\"region\":\"Africa\"},{\"name\":\"Kiribati\",\"alpha2\":\"KI\",\"alpha3\":\"KIR\",\"region\":\"Oceania\"},{\"name\":\"Korea, Republic of\",\"alpha2\":\"KR\",\"alpha3\":\"KOR\",\"region\":\"Asia\"},{\"name\":\"Kuwait\",\"alpha2\":\"KW\",\"alpha3\":\"KWT\",\"region\":\"Asia\"},{\"name\":\"Kyrgyzstan\",\"alpha2\":\"KG\",\"alpha3\":\"KGZ\",\"region\":\"Asia\"},{\"name\":\"Latvia\",\"alpha2\":\"LV\",\"alpha3\":\"LVA\",\"region\":\"Europe\"},{\"name\":\"Lebanon\",\"alpha2\":\"LB\",\"alpha3\":\"LBN\",\"region\":\"Asia\"},{\"name\":\"Lesotho\",\"alpha2\":\"LS\",\"alpha3\":\"LSO\",\"region\":\"Africa\"},{\"name\":\"Liberia\",\"alpha2\":\"LR\",\"alpha3\":\"LBR\",\"region\":\"Africa\"},{\"name\":\"Libya\",\"alpha2\":\"LY\",\"alpha3\":\"LBY\",\"region\":\"Africa\"},{\"name\":\"Liechtenstein\",\"alpha2\":\"LI\",\"alpha3\":\"LIE\",\"region\":\"Europe\"},{\"name\":\"Lithuania\",\"alpha2\":\"LT\",\"alpha3\":\"LTU\",\"region\":\"Europe\"},{\"name\":\"Luxembourg\",\"alpha2\":\"LU\",\"alpha3\":\"LUX\",\"region\":\"Europe\"},{\"name\":\"Macao\",\"alpha2\":\"MO\",\"alpha3\":\"MAC\",\"region\":\"Asia\"},{\"name\":\"Madagascar\",\"alpha2\":\"MG\",\"alpha3\":\"MDG\",\"region\":\"Africa\"},{\"name\":\"Malawi\",\"alpha2\":\"MW\",\"alpha3\":\"MWI\",\"region\":\"Africa\"},{\"name\":\"Malaysia\",\"alpha2\":\"MY\",\"alpha3\":\"MYS\",\"region\":\"Asia\"},{\"name\":\"Maldives\",\"alpha2\":\"MV\",\"alpha3\":\"MDV\",\"region\":\"Asia\"},{\"name\":\"Mali\",\"alpha2\":\"ML\",\"alpha3\":\"MLI\",\"region\":\"Africa\"},{\"name\":\"Malta\",\"alpha2\":\"MT\",\"alpha3\":\"MLT\",\"region\":\"Europe\"},{\"name\":\"Marshall Islands\",\"alpha2\":\"MH\",\"alpha3\":\"MHL\",\"region\":\"Oceania\"},{\"name\":\"Martinique\",\"alpha2\":\"MQ\",\"alpha3\":\"MTQ\",\"region\":\"Americas\"},{\"name\":\"Mauritania\",\"alpha2\":\"MR\",\"alpha3\":\"MRT\",\"region\":\"Africa\"},{\"name\":\"Mauritius\",\"alpha2\":\"MU\",\"alpha3\":\"MUS\",\"region\":\"Africa\"},{\"name\":\"Mayotte\",\"alpha2\":\"YT\",\"alpha3\":\"MYT\",\"region\":\"Africa\"},{\"name\":\"Mexico\",\"alpha2\":\"MX\",\"alpha3\":\"MEX\",\"region\":\"Americas\"},{\"name\":\"Micronesia (Federated States of)\",\"alpha2\":\"FM\",\"alpha3\":\"FSM\",\"region\":\"Oceania\"},{\"name\":\"Moldova, Republic of\",\"alpha2\":\"MD\",\"alpha3\":\"MDA\",\"region\":\"Europe\"},{\"name\":\"Monaco\",\"alpha2\":\"MC\",\"alpha3\":\"MCO\",\"region\":\"Europe\"},{\"name\":\"Mongolia\",\"alpha2\":\"MN\",\"alpha3\":\"MNG\",\"region\":\"Asia\"},{\"name\":\"Montenegro\",\"alpha2\":\"ME\",\"alpha3\":\"MNE\",\"region\":\"Europe\"},{\"name\":\"Montserrat\",\"alpha2\":\"MS\",\"alpha3\":\"MSR\",\"region\":\"Americas\"},{\"name\":\"Morocco\",\"alpha2\":\"MA\",\"alpha3\":\"MAR\",\"region\":\"Africa\"},{\"name\":\"Mozambique\",\"alpha2\":\"MZ\",\"alpha3\":\"MOZ\",\"region\":\"Africa\"},{\"name\":\"Myanmar\",\"alpha2\":\"MM\",\"alpha3\":\"MMR\",\"region\":\"Asia\"},{\"name\":\"Namibia\",\"alpha2\":\"NA\",\"alpha3\":\"NAM\",\"region\":\"Africa\"},{\"name\":\"Nauru\",\"alpha2\":\"NR\",\"alpha3\":\"NRU\",\"region\":\"Oceania\"},{\"name\":\"Nepal\",\"alpha2\":\"NP\",\"alpha3\":\"NPL\",\"region\":\"Asia\"},{\"name\":\"Netherlands\",\"alpha2\":\"NL\",\"alpha3\":\"NLD\",\"region\":\"Europe\"},{\"name\":\"New Caledonia\",\"alpha2\":\"NC\",\"alpha3\":\"NCL\",\"region\":\"Oceania\"},{\"name\":\"New Zealand\",\"alpha2\":\"NZ\",\"alpha3\":\"NZL\",\"region\":\"Oceania\"},{\"name\":\"Nicaragua\",\"alpha2\":\"NI\",\"alpha3\":\"NIC\",\"region\":\"Americas\"},{\"name\":\"Niger\",\"alpha2\":\"NE\",\"alpha3\":\"NER\",\"region\":\"Africa\"},{\"name\":\"Nigeria\",\"alpha2\":\"NG\",\"alpha3\":\"NGA\",\"region\":\"Africa\"},{\"name\":\"Niue\",\"alpha2\":\"NU\",\"alpha3\":\"NIU\",\"region\":\"Oceania\"},{\"name\":\"Norfolk Island\",\"alpha2\":\"NF\",\"alpha3\":\"NFK\",\"region\":\"Oceania\"},{\"name\":\"North Macedonia\",\"alpha2\":\"MK\",\"alpha3\":\"MKD\",\"region\":\"Europe\"},{\"name\":\"Northern Mariana Islands\",\"alpha2\":\"MP\",\"alpha3\":\"MNP\",\"region\":\"Oceania\"},{\"name\":\"Norway\",\"alpha2\":\"NO\",\"alpha3\":\"NOR\",\"region\":\"Europe\"},{\"name\":\"Oman\",\"alpha2\":\"OM\",\"alpha3\":\"OMN\",\"region\":\"Asia\"},{\"name\":\"Pakistan\",\"alpha2\":\"PK\",\"alpha3\":\"PAK\",\"region\":\"Asia\"},{\"name\":\"Palau\",\"alpha2\":\"PW\",\"alpha3\":\"PLW\",\"region\":\"Oceania\"},{\"name\":\"Palestine, State of\",\"alpha2\":\"PS\",\"alpha3\":\"PSE\",\"region\":\"Asia\"},{\"name\":\"Panama\",\"alpha2\":\"PA\",\"alpha3\":\"PAN\",\"region\":\"Americas\"},{\"name\":\"Papua New Guinea\",\"alpha2\":\"PG\",\"alpha3\":\"PNG\",\"region\":\"Oceania\"},{\"name\":\"Paraguay\",\"alpha2\":\"PY\",\"alpha3\":\"PRY\",\"region\":\"Americas\"},{\"name\":\"Peru\",\"alpha2\":\"PE\",\"alpha3\":\"PER\",\"region\":\"Americas\"},{\"name\":\"Philippines\",\"alpha2\":\"PH\",\"alpha3\":\"PHL\",\"region\":\"Asia\"},{\"name\":\"Pitcairn\",\"alpha2\":\"PN\",\"alpha3\":\"PCN\",\"region\":\"Oceania\"},{\"name\":\"Poland\",\"alpha2\":\"PL\",\"alpha3\":\"POL\",\"region\":\"Europe\"},{\"name\":\"Portugal\",\"alpha2\":\"PT\",\"alpha3\":\"PRT\",\"region\":\"Europe\"},{\"name\":\"Puerto Rico\",\"alpha2\":\"PR\",\"alpha3\":\"PRI\",\"region\":\"Americas\"},{\"name\":\"Qatar\",\"alpha2\":\"QA\",\"alpha3\":\"QAT\",\"region\":\"Asia\"},{\"name\":\"Réunion\",\"alpha2\":\"RE\",\"alpha3\":\"REU\",\"region\":\"Africa\"},{\"name\":\"Romania\",\"alpha2\":\"RO\",\"alpha3\":\"ROU\",\"region\":\"Europe\"},{\"name\":\"Russian Federation\",\"alpha2\":\"RU\",\"alpha3\":\"RUS\",\"region\":\"Europe\"},{\"name\":\"Rwanda\",\"alpha2\":\"RW\",\"alpha3\":\"RWA\",\"region\":\"Africa\"},{\"name\":\"Saint Barthélemy\",\"alpha2\":\"BL\",\"alpha3\":\"BLM\",\"region\":\"Americas\"},{\"name\":\"Saint Helena, Ascension and Tristan da Cunha\",\"alpha2\":\"SH\",\"alpha3\":\"SHN\",\"region\":\"Africa\"},{\"name\":\"Saint Kitts and Nevis\",\"alpha2\":\"KN\",\"alpha3\":\"KNA\",\"region\":\"Americas\"},{\"name\":\"Saint Lucia\",\"alpha2\":\"LC\",\"alpha3\":\"LCA\",\"region\":\"Americas\"},{\"name\":\"Saint Martin (French part)\",\"alpha2\":\"MF\",\"alpha3\":\"MAF\",\"region\":\"Americas\"},{\"name\":\"Saint Pierre and Miquelon\",\"alpha2\":\"PM\",\"alpha3\":\"SPM\",\"region\":\"Americas\"},{\"name\":\"Saint Vincent and the Grenadines\",\"alpha2\":\"VC\",\"alpha3\":\"VCT\",\"region\":\"Americas\"},{\"name\":\"Samoa\",\"alpha2\":\"WS\",\"alpha3\":\"WSM\",\"region\":\"Oceania\"},{\"name\":\"San Marino\",\"alpha2\":\"SM\",\"alpha3\":\"SMR\",\"region\":\"Europe\"},{\"name\":\"Sao Tome and Principe\",\"alpha2\":\"ST\",\"alpha3\":\"STP\",\"region\":\"Africa\"},{\"name\":\"Saudi Arabia\",\"alpha2\":\"SA\",\"alpha3\":\"SAU\",\"region\":\"Asia\"},{\"name\":\"Senegal\",\"alpha2\":\"SN\",\"alpha3\":\"SEN\",\"region\":\"Africa\"},{\"name\":\"Serbia\",\"alpha2\":\"RS\",\"alpha3\":\"SRB\",\"region\":\"Europe\"},{\"name\":\"Seychelles\",\"alpha2\":\"SC\",\"alpha3\":\"SYC\",\"region\":\"Africa\"},{\"name\":\"Sierra Leone\",\"alpha2\":\"SL\",\"alpha3\":\"SLE\",\"region\":\"Africa\"},{\"name\":\"Singapore\",\"alpha2\":\"SG\",\"alpha3\":\"SGP\",\"region\":\"Asia\"},{\"name\":\"Sint Maarten (Dutch part)\",\"alpha2\":\"SX\",\"alpha3\":\"SXM\",\"region\":\"Americas\"},{\"name\":\"Slovakia\",\"alpha2\":\"SK\",\"alpha3\":\"SVK\",\"region\":\"Europe\"},{\"name\":\"Slovenia\",\"alpha2\":\"SI\",\"alpha3\":\"SVN\",\"region\":\"Europe\"},{\"name\":\"Solomon Islands\",\"alpha2\":\"SB\",\"alpha3\":\"SLB\",\"region\":\"Oceania\"},{\"name\":\"Somalia\",\"alpha2\":\"SO\",\"alpha3\":\"SOM\",\"region\":\"Africa\"},{\"name\":\"South Africa\",\"alpha2\":\"ZA\",\"alpha3\":\"ZAF\",\"region\":\"Africa\"},{\"name\":\"South Georgia and the South Sandwich Islands\",\"alpha2\":\"GS\",\"alpha3\":\"SGS\",\"region\":\"Americas\"},{\"name\":\"South Sudan\",\"alpha2\":\"SS\",\"alpha3\":\"SSD\",\"region\":\"Africa\"},{\"name\":\"Spain\",\"alpha2\":\"ES\",\"alpha3\":\"ESP\",\"region\":\"Europe\"},{\"name\":\"Sri Lanka\",\"alpha2\":\"LK\",\"alpha3\":\"LKA\",\"region\":\"Asia\"},{\"name\":\"Sudan\",\"alpha2\":\"SD\",\"alpha3\":\"SDN\",\"region\":\"Africa\"},{\"name\":\"Suriname\",\"alpha2\":\"SR\",\"alpha3\":\"SUR\",\"region\":\"Americas\"},{\"name\":\"Svalbard and Jan Mayen\",\"alpha2\":\"SJ\",\"alpha3\":\"SJM\",\"region\":\"Europe\"},{\"name\":\"Sweden\",\"alpha2\":\"SE\",\"alpha3\":\"SWE\",\"region\":\"Europe\"},{\"name\":\"Switzerland\",\"alpha2\":\"CH\",\"alpha3\":\"CHE\",\"region\":\"Europe\"},{\"name\":\"Syrian Arab Republic\",\"alpha2\":\"SY\",\"alpha3\":\"SYR\",\"region\":\"Asia\"},{\"name\":\"Taiwan, Province of China\",\"alpha2\":\"TW\",\"alpha3\":\"TWN\",\"region\":\"Asia\"},{\"name\":\"Tajikistan\",\"alpha2\":\"TJ\",\"alpha3\":\"TJK\",\"region\":\"Asia\"},{\"name\":\"Tanzania, United Republic of\",\"alpha2\":\"TZ\",\"alpha3\":\"TZA\",\"region\":\"Africa\"},{\"name\":\"Thailand\",\"alpha2\":\"TH\",\"alpha3\":\"THA\",\"region\":\"Asia\"},{\"name\":\"Timor-Leste\",\"alpha2\":\"TL\",\"alpha3\":\"TLS\",\"region\":\"Asia\"},{\"name\":\"Togo\",\"alpha2\":\"TG\",\"alpha3\":\"TGO\",\"region\":\"Africa\"},{\"name\":\"Tokelau\",\"alpha2\":\"TK\",\"alpha3\":\"TKL\",\"region\":\"Oceania\"},{\"name\":\"Tonga\",\"alpha2\":\"TO\",\"alpha3\":\"TON\",\"region\":\"Oceania\"},{\"name\":\"Trinidad and Tobago\",\"alpha2\":\"TT\",\"alpha3\":\"TTO\",\"region\":\"Americas\"},{\"name\":\"Tunisia\",\"alpha2\":\"TN\",\"alpha3\":\"TUN\",\"region\":\"Africa\"},{\"name\":\"Turkey\",\"alpha2\":\"TR\",\"alpha3\":\"TUR\",\"region\":\"Asia\"},{\"name\":\"Turkmenistan\",\"alpha2\":\"TM\",\"alpha3\":\"TKM\",\"region\":\"Asia\"},{\"name\":\"Turks and Caicos Islands\",\"alpha2\":\"TC\",\"alpha3\":\"TCA\",\"region\":\"Americas\"},{\"name\":\"Tuvalu\",\"alpha2\":\"TV\",\"alpha3\":\"TUV\",\"region\":\"Oceania\"},{\"name\":\"Uganda\",\"alpha2\":\"UG\",\"alpha3\":\"UGA\",\"region\":\"Africa\"},{\"name\":\"Ukraine\",\"alpha2\":\"UA\",\"alpha3\":\"UKR\",\"region\":\"Europe\"},{\"name\":\"United Arab Emirates\",\"alpha2\":\"AE\",\"alpha3\":\"ARE\",\"region\":\"Asia\"},{\"name\":\"United Kingdom of Great Britain and Northern Ireland\",\"alpha2\":\"GB\",\"alpha3\":\"GBR\",\"region\":\"Europe\"},{\"name\":\"United States of America\",\"alpha2\":\"US\",\"alpha3\":\"USA\",\"region\":\"Americas\"},{\"name\":\"United States Minor Outlying Islands\",\"alpha2\":\"UM\",\"alpha3\":\"UMI\",\"region\":\"Oceania\"},{\"name\":\"Uruguay\",\"alpha2\":\"UY\",\"alpha3\":\"URY\",\"region\":\"Americas\"},{\"name\":\"Uzbekistan\",\"alpha2\":\"UZ\",\"alpha3\":\"UZB\",\"region\":\"Asia\"},{\"name\":\"Vanuatu\",\"alpha2\":\"VU\",\"alpha3\":\"VUT\",\"region\":\"Oceania\"},{\"name\":\"Venezuela (Bolivarian Republic of)\",\"alpha2\":\"VE\",\"alpha3\":\"VEN\",\"region\":\"Americas\"},{\"name\":\"Viet Nam\",\"alpha2\":\"VN\",\"alpha3\":\"VNM\",\"region\":\"Asia\"},{\"name\":\"Virgin Islands (British)\",\"alpha2\":\"VG\",\"alpha3\":\"VGB\",\"region\":\"Americas\"},{\"name\":\"Virgin Islands (U.S.)\",\"alpha2\":\"VI\",\"alpha3\":\"VIR\",\"region\":\"Americas\"},{\"name\":\"Wallis and Futuna\",\"alpha2\":\"WF\",\"alpha3\":\"WLF\",\"region\":\"Oceania\"},{\"name\":\"Western Sahara\",\"alpha2\":\"EH\",\"alpha3\":\"ESH\",\"region\":\"Africa\"},{\"name\":\"Yemen\",\"alpha2\":\"YE\",\"alpha3\":\"YEM\",\"region\":\"Asia\"},{\"name\":\"Zambia\",\"alpha2\":\"ZM\",\"alpha3\":\"ZMB\",\"region\":\"Africa\"},{\"name\":\"Zimbabwe\",\"alpha2\":\"ZW\",\"alpha3\":\"ZWE\",\"region\":\"Africa\"},{\"name\":\"Byteland PROD\",\"alpha2\":\"YY\",\"alpha3\":\"YYY\",\"region\":\"Europe\"}];",
|
||
"",
|
||
"",
|
||
"const regionsToCheck = [",
|
||
" ['Africa'],",
|
||
" ['Americas'],",
|
||
" ['Asia'],",
|
||
" ['Europe'],",
|
||
" ['Oceania'],",
|
||
" ['Europe', 'Africa'],",
|
||
" ['Europe', 'Asia'],",
|
||
" ['Europe', 'Asia', 'Americas'],",
|
||
"];",
|
||
"",
|
||
"const querystring = require('querystring');",
|
||
"",
|
||
"regionsToCheck.forEach(function (regions) {",
|
||
" pm.test(`List countries from regions ${regions}`, function () {",
|
||
" const data = {",
|
||
" 'region': regions,",
|
||
" };",
|
||
" const params = querystring.stringify(data);",
|
||
" const url = pm.variables.get(\"base_url\") + `/countries?${params}`;",
|
||
"",
|
||
" pm.sendRequest(url, function (err, response) {",
|
||
" pm.test(`Validate response URL /countries?${params}`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" for (var i = 0; i < countries.length; i++) {",
|
||
" if (!regions.includes(countries[i].region)) {",
|
||
" continue;",
|
||
" }",
|
||
"",
|
||
" pm.expect(resp).to.deep.include(countries[i], `Response has to include country ${countries[i].alpha2} from ${countries[i].region}`);",
|
||
" }",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get country by alpha2",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var countrySchema = {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о стране из стандарта ISO 3166\",",
|
||
" \"properties\": {",
|
||
" \"name\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Полное название страны\",",
|
||
" \"maxLength\": 100",
|
||
" },",
|
||
" \"alpha2\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"alpha3\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Трехбуквенный код страны\",",
|
||
" \"maxLength\": 3,",
|
||
" \"pattern\": \"[a-zA-Z]{3}\"",
|
||
" },",
|
||
" \"region\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Географический регион, к которому относится страна\",",
|
||
" \"enum\": [",
|
||
" \"Europe\",",
|
||
" \"Africa\",",
|
||
" \"Americas\",",
|
||
" \"Oceania\",",
|
||
" \"Asia\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"name\",",
|
||
" \"alpha2\",",
|
||
" \"alpha3\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"const countries = [{\"name\":\"Afghanistan\",\"alpha2\":\"AF\",\"alpha3\":\"AFG\",\"region\":\"Asia\"},{\"name\":\"Åland Islands\",\"alpha2\":\"AX\",\"alpha3\":\"ALA\",\"region\":\"Europe\"},{\"name\":\"Albania\",\"alpha2\":\"AL\",\"alpha3\":\"ALB\",\"region\":\"Europe\"},{\"name\":\"Algeria\",\"alpha2\":\"DZ\",\"alpha3\":\"DZA\",\"region\":\"Africa\"},{\"name\":\"American Samoa\",\"alpha2\":\"AS\",\"alpha3\":\"ASM\",\"region\":\"Oceania\"},{\"name\":\"Andorra\",\"alpha2\":\"AD\",\"alpha3\":\"AND\",\"region\":\"Europe\"},{\"name\":\"Angola\",\"alpha2\":\"AO\",\"alpha3\":\"AGO\",\"region\":\"Africa\"},{\"name\":\"Anguilla\",\"alpha2\":\"AI\",\"alpha3\":\"AIA\",\"region\":\"Americas\"},{\"name\":\"Antigua and Barbuda\",\"alpha2\":\"AG\",\"alpha3\":\"ATG\",\"region\":\"Americas\"},{\"name\":\"Argentina\",\"alpha2\":\"AR\",\"alpha3\":\"ARG\",\"region\":\"Americas\"},{\"name\":\"Armenia\",\"alpha2\":\"AM\",\"alpha3\":\"ARM\",\"region\":\"Asia\"},{\"name\":\"Aruba\",\"alpha2\":\"AW\",\"alpha3\":\"ABW\",\"region\":\"Americas\"},{\"name\":\"Australia\",\"alpha2\":\"AU\",\"alpha3\":\"AUS\",\"region\":\"Oceania\"},{\"name\":\"Austria\",\"alpha2\":\"AT\",\"alpha3\":\"AUT\",\"region\":\"Europe\"},{\"name\":\"Azerbaijan\",\"alpha2\":\"AZ\",\"alpha3\":\"AZE\",\"region\":\"Asia\"},{\"name\":\"Bahamas\",\"alpha2\":\"BS\",\"alpha3\":\"BHS\",\"region\":\"Americas\"},{\"name\":\"Bahrain\",\"alpha2\":\"BH\",\"alpha3\":\"BHR\",\"region\":\"Asia\"},{\"name\":\"Bangladesh\",\"alpha2\":\"BD\",\"alpha3\":\"BGD\",\"region\":\"Asia\"},{\"name\":\"Barbados\",\"alpha2\":\"BB\",\"alpha3\":\"BRB\",\"region\":\"Americas\"},{\"name\":\"Belarus\",\"alpha2\":\"BY\",\"alpha3\":\"BLR\",\"region\":\"Europe\"},{\"name\":\"Belgium\",\"alpha2\":\"BE\",\"alpha3\":\"BEL\",\"region\":\"Europe\"},{\"name\":\"Belize\",\"alpha2\":\"BZ\",\"alpha3\":\"BLZ\",\"region\":\"Americas\"},{\"name\":\"Benin\",\"alpha2\":\"BJ\",\"alpha3\":\"BEN\",\"region\":\"Africa\"},{\"name\":\"Bermuda\",\"alpha2\":\"BM\",\"alpha3\":\"BMU\",\"region\":\"Americas\"},{\"name\":\"Bhutan\",\"alpha2\":\"BT\",\"alpha3\":\"BTN\",\"region\":\"Asia\"},{\"name\":\"Bolivia (Plurinational State of)\",\"alpha2\":\"BO\",\"alpha3\":\"BOL\",\"region\":\"Americas\"},{\"name\":\"Bonaire, Sint Eustatius and Saba\",\"alpha2\":\"BQ\",\"alpha3\":\"BES\",\"region\":\"Americas\"},{\"name\":\"Bosnia and Herzegovina\",\"alpha2\":\"BA\",\"alpha3\":\"BIH\",\"region\":\"Europe\"},{\"name\":\"Botswana\",\"alpha2\":\"BW\",\"alpha3\":\"BWA\",\"region\":\"Africa\"},{\"name\":\"Bouvet Island\",\"alpha2\":\"BV\",\"alpha3\":\"BVT\",\"region\":\"Americas\"},{\"name\":\"Brazil\",\"alpha2\":\"BR\",\"alpha3\":\"BRA\",\"region\":\"Americas\"},{\"name\":\"British Indian Ocean Territory\",\"alpha2\":\"IO\",\"alpha3\":\"IOT\",\"region\":\"Africa\"},{\"name\":\"Brunei Darussalam\",\"alpha2\":\"BN\",\"alpha3\":\"BRN\",\"region\":\"Asia\"},{\"name\":\"Bulgaria\",\"alpha2\":\"BG\",\"alpha3\":\"BGR\",\"region\":\"Europe\"},{\"name\":\"Burkina Faso\",\"alpha2\":\"BF\",\"alpha3\":\"BFA\",\"region\":\"Africa\"},{\"name\":\"Burundi\",\"alpha2\":\"BI\",\"alpha3\":\"BDI\",\"region\":\"Africa\"},{\"name\":\"Cabo Verde\",\"alpha2\":\"CV\",\"alpha3\":\"CPV\",\"region\":\"Africa\"},{\"name\":\"Cambodia\",\"alpha2\":\"KH\",\"alpha3\":\"KHM\",\"region\":\"Asia\"},{\"name\":\"Cameroon\",\"alpha2\":\"CM\",\"alpha3\":\"CMR\",\"region\":\"Africa\"},{\"name\":\"Canada\",\"alpha2\":\"CA\",\"alpha3\":\"CAN\",\"region\":\"Americas\"},{\"name\":\"Cayman Islands\",\"alpha2\":\"KY\",\"alpha3\":\"CYM\",\"region\":\"Americas\"},{\"name\":\"Central African Republic\",\"alpha2\":\"CF\",\"alpha3\":\"CAF\",\"region\":\"Africa\"},{\"name\":\"Chad\",\"alpha2\":\"TD\",\"alpha3\":\"TCD\",\"region\":\"Africa\"},{\"name\":\"Chile\",\"alpha2\":\"CL\",\"alpha3\":\"CHL\",\"region\":\"Americas\"},{\"name\":\"China\",\"alpha2\":\"CN\",\"alpha3\":\"CHN\",\"region\":\"Asia\"},{\"name\":\"Christmas Island\",\"alpha2\":\"CX\",\"alpha3\":\"CXR\",\"region\":\"Oceania\"},{\"name\":\"Cocos (Keeling) Islands\",\"alpha2\":\"CC\",\"alpha3\":\"CCK\",\"region\":\"Oceania\"},{\"name\":\"Colombia\",\"alpha2\":\"CO\",\"alpha3\":\"COL\",\"region\":\"Americas\"},{\"name\":\"Comoros\",\"alpha2\":\"KM\",\"alpha3\":\"COM\",\"region\":\"Africa\"},{\"name\":\"Congo\",\"alpha2\":\"CG\",\"alpha3\":\"COG\",\"region\":\"Africa\"},{\"name\":\"Congo, Democratic Republic of the\",\"alpha2\":\"CD\",\"alpha3\":\"COD\",\"region\":\"Africa\"},{\"name\":\"Cook Islands\",\"alpha2\":\"CK\",\"alpha3\":\"COK\",\"region\":\"Oceania\"},{\"name\":\"Costa Rica\",\"alpha2\":\"CR\",\"alpha3\":\"CRI\",\"region\":\"Americas\"},{\"name\":\"Croatia\",\"alpha2\":\"HR\",\"alpha3\":\"HRV\",\"region\":\"Europe\"},{\"name\":\"Cuba\",\"alpha2\":\"CU\",\"alpha3\":\"CUB\",\"region\":\"Americas\"},{\"name\":\"Curaçao\",\"alpha2\":\"CW\",\"alpha3\":\"CUW\",\"region\":\"Americas\"},{\"name\":\"Cyprus\",\"alpha2\":\"CY\",\"alpha3\":\"CYP\",\"region\":\"Asia\"},{\"name\":\"Czechia\",\"alpha2\":\"CZ\",\"alpha3\":\"CZE\",\"region\":\"Europe\"},{\"name\":\"Denmark\",\"alpha2\":\"DK\",\"alpha3\":\"DNK\",\"region\":\"Europe\"},{\"name\":\"Djibouti\",\"alpha2\":\"DJ\",\"alpha3\":\"DJI\",\"region\":\"Africa\"},{\"name\":\"Dominica\",\"alpha2\":\"DM\",\"alpha3\":\"DMA\",\"region\":\"Americas\"},{\"name\":\"Dominican Republic\",\"alpha2\":\"DO\",\"alpha3\":\"DOM\",\"region\":\"Americas\"},{\"name\":\"Ecuador\",\"alpha2\":\"EC\",\"alpha3\":\"ECU\",\"region\":\"Americas\"},{\"name\":\"Egypt\",\"alpha2\":\"EG\",\"alpha3\":\"EGY\",\"region\":\"Africa\"},{\"name\":\"El Salvador\",\"alpha2\":\"SV\",\"alpha3\":\"SLV\",\"region\":\"Americas\"},{\"name\":\"Equatorial Guinea\",\"alpha2\":\"GQ\",\"alpha3\":\"GNQ\",\"region\":\"Africa\"},{\"name\":\"Eritrea\",\"alpha2\":\"ER\",\"alpha3\":\"ERI\",\"region\":\"Africa\"},{\"name\":\"Estonia\",\"alpha2\":\"EE\",\"alpha3\":\"EST\",\"region\":\"Europe\"},{\"name\":\"Eswatini\",\"alpha2\":\"SZ\",\"alpha3\":\"SWZ\",\"region\":\"Africa\"},{\"name\":\"Ethiopia\",\"alpha2\":\"ET\",\"alpha3\":\"ETH\",\"region\":\"Africa\"},{\"name\":\"Falkland Islands (Malvinas)\",\"alpha2\":\"FK\",\"alpha3\":\"FLK\",\"region\":\"Americas\"},{\"name\":\"Faroe Islands\",\"alpha2\":\"FO\",\"alpha3\":\"FRO\",\"region\":\"Europe\"},{\"name\":\"Fiji\",\"alpha2\":\"FJ\",\"alpha3\":\"FJI\",\"region\":\"Oceania\"},{\"name\":\"Finland\",\"alpha2\":\"FI\",\"alpha3\":\"FIN\",\"region\":\"Europe\"},{\"name\":\"France\",\"alpha2\":\"FR\",\"alpha3\":\"FRA\",\"region\":\"Europe\"},{\"name\":\"French Guiana\",\"alpha2\":\"GF\",\"alpha3\":\"GUF\",\"region\":\"Americas\"},{\"name\":\"French Polynesia\",\"alpha2\":\"PF\",\"alpha3\":\"PYF\",\"region\":\"Oceania\"},{\"name\":\"French Southern Territories\",\"alpha2\":\"TF\",\"alpha3\":\"ATF\",\"region\":\"Africa\"},{\"name\":\"Gabon\",\"alpha2\":\"GA\",\"alpha3\":\"GAB\",\"region\":\"Africa\"},{\"name\":\"Gambia\",\"alpha2\":\"GM\",\"alpha3\":\"GMB\",\"region\":\"Africa\"},{\"name\":\"Georgia\",\"alpha2\":\"GE\",\"alpha3\":\"GEO\",\"region\":\"Asia\"},{\"name\":\"Germany\",\"alpha2\":\"DE\",\"alpha3\":\"DEU\",\"region\":\"Europe\"},{\"name\":\"Ghana\",\"alpha2\":\"GH\",\"alpha3\":\"GHA\",\"region\":\"Africa\"},{\"name\":\"Gibraltar\",\"alpha2\":\"GI\",\"alpha3\":\"GIB\",\"region\":\"Europe\"},{\"name\":\"Greece\",\"alpha2\":\"GR\",\"alpha3\":\"GRC\",\"region\":\"Europe\"},{\"name\":\"Greenland\",\"alpha2\":\"GL\",\"alpha3\":\"GRL\",\"region\":\"Americas\"},{\"name\":\"Grenada\",\"alpha2\":\"GD\",\"alpha3\":\"GRD\",\"region\":\"Americas\"},{\"name\":\"Guadeloupe\",\"alpha2\":\"GP\",\"alpha3\":\"GLP\",\"region\":\"Americas\"},{\"name\":\"Guam\",\"alpha2\":\"GU\",\"alpha3\":\"GUM\",\"region\":\"Oceania\"},{\"name\":\"Guatemala\",\"alpha2\":\"GT\",\"alpha3\":\"GTM\",\"region\":\"Americas\"},{\"name\":\"Guernsey\",\"alpha2\":\"GG\",\"alpha3\":\"GGY\",\"region\":\"Europe\"},{\"name\":\"Guinea\",\"alpha2\":\"GN\",\"alpha3\":\"GIN\",\"region\":\"Africa\"},{\"name\":\"Guinea-Bissau\",\"alpha2\":\"GW\",\"alpha3\":\"GNB\",\"region\":\"Africa\"},{\"name\":\"Guyana\",\"alpha2\":\"GY\",\"alpha3\":\"GUY\",\"region\":\"Americas\"},{\"name\":\"Haiti\",\"alpha2\":\"HT\",\"alpha3\":\"HTI\",\"region\":\"Americas\"},{\"name\":\"Heard Island and McDonald Islands\",\"alpha2\":\"HM\",\"alpha3\":\"HMD\",\"region\":\"Oceania\"},{\"name\":\"Holy See\",\"alpha2\":\"VA\",\"alpha3\":\"VAT\",\"region\":\"Europe\"},{\"name\":\"Honduras\",\"alpha2\":\"HN\",\"alpha3\":\"HND\",\"region\":\"Americas\"},{\"name\":\"Hong Kong\",\"alpha2\":\"HK\",\"alpha3\":\"HKG\",\"region\":\"Asia\"},{\"name\":\"Hungary\",\"alpha2\":\"HU\",\"alpha3\":\"HUN\",\"region\":\"Europe\"},{\"name\":\"Iceland\",\"alpha2\":\"IS\",\"alpha3\":\"ISL\",\"region\":\"Europe\"},{\"name\":\"India\",\"alpha2\":\"IN\",\"alpha3\":\"IND\",\"region\":\"Asia\"},{\"name\":\"Indonesia\",\"alpha2\":\"ID\",\"alpha3\":\"IDN\",\"region\":\"Asia\"},{\"name\":\"Iran (Islamic Republic of)\",\"alpha2\":\"IR\",\"alpha3\":\"IRN\",\"region\":\"Asia\"},{\"name\":\"Iraq\",\"alpha2\":\"IQ\",\"alpha3\":\"IRQ\",\"region\":\"Asia\"},{\"name\":\"Ireland\",\"alpha2\":\"IE\",\"alpha3\":\"IRL\",\"region\":\"Europe\"},{\"name\":\"Isle of Man\",\"alpha2\":\"IM\",\"alpha3\":\"IMN\",\"region\":\"Europe\"},{\"name\":\"Israel\",\"alpha2\":\"IL\",\"alpha3\":\"ISR\",\"region\":\"Asia\"},{\"name\":\"Italy\",\"alpha2\":\"IT\",\"alpha3\":\"ITA\",\"region\":\"Europe\"},{\"name\":\"Jamaica\",\"alpha2\":\"JM\",\"alpha3\":\"JAM\",\"region\":\"Americas\"},{\"name\":\"Japan\",\"alpha2\":\"JP\",\"alpha3\":\"JPN\",\"region\":\"Asia\"},{\"name\":\"Jersey\",\"alpha2\":\"JE\",\"alpha3\":\"JEY\",\"region\":\"Europe\"},{\"name\":\"Jordan\",\"alpha2\":\"JO\",\"alpha3\":\"JOR\",\"region\":\"Asia\"},{\"name\":\"Kazakhstan\",\"alpha2\":\"KZ\",\"alpha3\":\"KAZ\",\"region\":\"Asia\"},{\"name\":\"Kenya\",\"alpha2\":\"KE\",\"alpha3\":\"KEN\",\"region\":\"Africa\"},{\"name\":\"Kiribati\",\"alpha2\":\"KI\",\"alpha3\":\"KIR\",\"region\":\"Oceania\"},{\"name\":\"Korea, Republic of\",\"alpha2\":\"KR\",\"alpha3\":\"KOR\",\"region\":\"Asia\"},{\"name\":\"Kuwait\",\"alpha2\":\"KW\",\"alpha3\":\"KWT\",\"region\":\"Asia\"},{\"name\":\"Kyrgyzstan\",\"alpha2\":\"KG\",\"alpha3\":\"KGZ\",\"region\":\"Asia\"},{\"name\":\"Latvia\",\"alpha2\":\"LV\",\"alpha3\":\"LVA\",\"region\":\"Europe\"},{\"name\":\"Lebanon\",\"alpha2\":\"LB\",\"alpha3\":\"LBN\",\"region\":\"Asia\"},{\"name\":\"Lesotho\",\"alpha2\":\"LS\",\"alpha3\":\"LSO\",\"region\":\"Africa\"},{\"name\":\"Liberia\",\"alpha2\":\"LR\",\"alpha3\":\"LBR\",\"region\":\"Africa\"},{\"name\":\"Libya\",\"alpha2\":\"LY\",\"alpha3\":\"LBY\",\"region\":\"Africa\"},{\"name\":\"Liechtenstein\",\"alpha2\":\"LI\",\"alpha3\":\"LIE\",\"region\":\"Europe\"},{\"name\":\"Lithuania\",\"alpha2\":\"LT\",\"alpha3\":\"LTU\",\"region\":\"Europe\"},{\"name\":\"Luxembourg\",\"alpha2\":\"LU\",\"alpha3\":\"LUX\",\"region\":\"Europe\"},{\"name\":\"Macao\",\"alpha2\":\"MO\",\"alpha3\":\"MAC\",\"region\":\"Asia\"},{\"name\":\"Madagascar\",\"alpha2\":\"MG\",\"alpha3\":\"MDG\",\"region\":\"Africa\"},{\"name\":\"Malawi\",\"alpha2\":\"MW\",\"alpha3\":\"MWI\",\"region\":\"Africa\"},{\"name\":\"Malaysia\",\"alpha2\":\"MY\",\"alpha3\":\"MYS\",\"region\":\"Asia\"},{\"name\":\"Maldives\",\"alpha2\":\"MV\",\"alpha3\":\"MDV\",\"region\":\"Asia\"},{\"name\":\"Mali\",\"alpha2\":\"ML\",\"alpha3\":\"MLI\",\"region\":\"Africa\"},{\"name\":\"Malta\",\"alpha2\":\"MT\",\"alpha3\":\"MLT\",\"region\":\"Europe\"},{\"name\":\"Marshall Islands\",\"alpha2\":\"MH\",\"alpha3\":\"MHL\",\"region\":\"Oceania\"},{\"name\":\"Martinique\",\"alpha2\":\"MQ\",\"alpha3\":\"MTQ\",\"region\":\"Americas\"},{\"name\":\"Mauritania\",\"alpha2\":\"MR\",\"alpha3\":\"MRT\",\"region\":\"Africa\"},{\"name\":\"Mauritius\",\"alpha2\":\"MU\",\"alpha3\":\"MUS\",\"region\":\"Africa\"},{\"name\":\"Mayotte\",\"alpha2\":\"YT\",\"alpha3\":\"MYT\",\"region\":\"Africa\"},{\"name\":\"Mexico\",\"alpha2\":\"MX\",\"alpha3\":\"MEX\",\"region\":\"Americas\"},{\"name\":\"Micronesia (Federated States of)\",\"alpha2\":\"FM\",\"alpha3\":\"FSM\",\"region\":\"Oceania\"},{\"name\":\"Moldova, Republic of\",\"alpha2\":\"MD\",\"alpha3\":\"MDA\",\"region\":\"Europe\"},{\"name\":\"Monaco\",\"alpha2\":\"MC\",\"alpha3\":\"MCO\",\"region\":\"Europe\"},{\"name\":\"Mongolia\",\"alpha2\":\"MN\",\"alpha3\":\"MNG\",\"region\":\"Asia\"},{\"name\":\"Montenegro\",\"alpha2\":\"ME\",\"alpha3\":\"MNE\",\"region\":\"Europe\"},{\"name\":\"Montserrat\",\"alpha2\":\"MS\",\"alpha3\":\"MSR\",\"region\":\"Americas\"},{\"name\":\"Morocco\",\"alpha2\":\"MA\",\"alpha3\":\"MAR\",\"region\":\"Africa\"},{\"name\":\"Mozambique\",\"alpha2\":\"MZ\",\"alpha3\":\"MOZ\",\"region\":\"Africa\"},{\"name\":\"Myanmar\",\"alpha2\":\"MM\",\"alpha3\":\"MMR\",\"region\":\"Asia\"},{\"name\":\"Namibia\",\"alpha2\":\"NA\",\"alpha3\":\"NAM\",\"region\":\"Africa\"},{\"name\":\"Nauru\",\"alpha2\":\"NR\",\"alpha3\":\"NRU\",\"region\":\"Oceania\"},{\"name\":\"Nepal\",\"alpha2\":\"NP\",\"alpha3\":\"NPL\",\"region\":\"Asia\"},{\"name\":\"Netherlands\",\"alpha2\":\"NL\",\"alpha3\":\"NLD\",\"region\":\"Europe\"},{\"name\":\"New Caledonia\",\"alpha2\":\"NC\",\"alpha3\":\"NCL\",\"region\":\"Oceania\"},{\"name\":\"New Zealand\",\"alpha2\":\"NZ\",\"alpha3\":\"NZL\",\"region\":\"Oceania\"},{\"name\":\"Nicaragua\",\"alpha2\":\"NI\",\"alpha3\":\"NIC\",\"region\":\"Americas\"},{\"name\":\"Niger\",\"alpha2\":\"NE\",\"alpha3\":\"NER\",\"region\":\"Africa\"},{\"name\":\"Nigeria\",\"alpha2\":\"NG\",\"alpha3\":\"NGA\",\"region\":\"Africa\"},{\"name\":\"Niue\",\"alpha2\":\"NU\",\"alpha3\":\"NIU\",\"region\":\"Oceania\"},{\"name\":\"Norfolk Island\",\"alpha2\":\"NF\",\"alpha3\":\"NFK\",\"region\":\"Oceania\"},{\"name\":\"North Macedonia\",\"alpha2\":\"MK\",\"alpha3\":\"MKD\",\"region\":\"Europe\"},{\"name\":\"Northern Mariana Islands\",\"alpha2\":\"MP\",\"alpha3\":\"MNP\",\"region\":\"Oceania\"},{\"name\":\"Norway\",\"alpha2\":\"NO\",\"alpha3\":\"NOR\",\"region\":\"Europe\"},{\"name\":\"Oman\",\"alpha2\":\"OM\",\"alpha3\":\"OMN\",\"region\":\"Asia\"},{\"name\":\"Pakistan\",\"alpha2\":\"PK\",\"alpha3\":\"PAK\",\"region\":\"Asia\"},{\"name\":\"Palau\",\"alpha2\":\"PW\",\"alpha3\":\"PLW\",\"region\":\"Oceania\"},{\"name\":\"Palestine, State of\",\"alpha2\":\"PS\",\"alpha3\":\"PSE\",\"region\":\"Asia\"},{\"name\":\"Panama\",\"alpha2\":\"PA\",\"alpha3\":\"PAN\",\"region\":\"Americas\"},{\"name\":\"Papua New Guinea\",\"alpha2\":\"PG\",\"alpha3\":\"PNG\",\"region\":\"Oceania\"},{\"name\":\"Paraguay\",\"alpha2\":\"PY\",\"alpha3\":\"PRY\",\"region\":\"Americas\"},{\"name\":\"Peru\",\"alpha2\":\"PE\",\"alpha3\":\"PER\",\"region\":\"Americas\"},{\"name\":\"Philippines\",\"alpha2\":\"PH\",\"alpha3\":\"PHL\",\"region\":\"Asia\"},{\"name\":\"Pitcairn\",\"alpha2\":\"PN\",\"alpha3\":\"PCN\",\"region\":\"Oceania\"},{\"name\":\"Poland\",\"alpha2\":\"PL\",\"alpha3\":\"POL\",\"region\":\"Europe\"},{\"name\":\"Portugal\",\"alpha2\":\"PT\",\"alpha3\":\"PRT\",\"region\":\"Europe\"},{\"name\":\"Puerto Rico\",\"alpha2\":\"PR\",\"alpha3\":\"PRI\",\"region\":\"Americas\"},{\"name\":\"Qatar\",\"alpha2\":\"QA\",\"alpha3\":\"QAT\",\"region\":\"Asia\"},{\"name\":\"Réunion\",\"alpha2\":\"RE\",\"alpha3\":\"REU\",\"region\":\"Africa\"},{\"name\":\"Romania\",\"alpha2\":\"RO\",\"alpha3\":\"ROU\",\"region\":\"Europe\"},{\"name\":\"Russian Federation\",\"alpha2\":\"RU\",\"alpha3\":\"RUS\",\"region\":\"Europe\"},{\"name\":\"Rwanda\",\"alpha2\":\"RW\",\"alpha3\":\"RWA\",\"region\":\"Africa\"},{\"name\":\"Saint Barthélemy\",\"alpha2\":\"BL\",\"alpha3\":\"BLM\",\"region\":\"Americas\"},{\"name\":\"Saint Helena, Ascension and Tristan da Cunha\",\"alpha2\":\"SH\",\"alpha3\":\"SHN\",\"region\":\"Africa\"},{\"name\":\"Saint Kitts and Nevis\",\"alpha2\":\"KN\",\"alpha3\":\"KNA\",\"region\":\"Americas\"},{\"name\":\"Saint Lucia\",\"alpha2\":\"LC\",\"alpha3\":\"LCA\",\"region\":\"Americas\"},{\"name\":\"Saint Martin (French part)\",\"alpha2\":\"MF\",\"alpha3\":\"MAF\",\"region\":\"Americas\"},{\"name\":\"Saint Pierre and Miquelon\",\"alpha2\":\"PM\",\"alpha3\":\"SPM\",\"region\":\"Americas\"},{\"name\":\"Saint Vincent and the Grenadines\",\"alpha2\":\"VC\",\"alpha3\":\"VCT\",\"region\":\"Americas\"},{\"name\":\"Samoa\",\"alpha2\":\"WS\",\"alpha3\":\"WSM\",\"region\":\"Oceania\"},{\"name\":\"San Marino\",\"alpha2\":\"SM\",\"alpha3\":\"SMR\",\"region\":\"Europe\"},{\"name\":\"Sao Tome and Principe\",\"alpha2\":\"ST\",\"alpha3\":\"STP\",\"region\":\"Africa\"},{\"name\":\"Saudi Arabia\",\"alpha2\":\"SA\",\"alpha3\":\"SAU\",\"region\":\"Asia\"},{\"name\":\"Senegal\",\"alpha2\":\"SN\",\"alpha3\":\"SEN\",\"region\":\"Africa\"},{\"name\":\"Serbia\",\"alpha2\":\"RS\",\"alpha3\":\"SRB\",\"region\":\"Europe\"},{\"name\":\"Seychelles\",\"alpha2\":\"SC\",\"alpha3\":\"SYC\",\"region\":\"Africa\"},{\"name\":\"Sierra Leone\",\"alpha2\":\"SL\",\"alpha3\":\"SLE\",\"region\":\"Africa\"},{\"name\":\"Singapore\",\"alpha2\":\"SG\",\"alpha3\":\"SGP\",\"region\":\"Asia\"},{\"name\":\"Sint Maarten (Dutch part)\",\"alpha2\":\"SX\",\"alpha3\":\"SXM\",\"region\":\"Americas\"},{\"name\":\"Slovakia\",\"alpha2\":\"SK\",\"alpha3\":\"SVK\",\"region\":\"Europe\"},{\"name\":\"Slovenia\",\"alpha2\":\"SI\",\"alpha3\":\"SVN\",\"region\":\"Europe\"},{\"name\":\"Solomon Islands\",\"alpha2\":\"SB\",\"alpha3\":\"SLB\",\"region\":\"Oceania\"},{\"name\":\"Somalia\",\"alpha2\":\"SO\",\"alpha3\":\"SOM\",\"region\":\"Africa\"},{\"name\":\"South Africa\",\"alpha2\":\"ZA\",\"alpha3\":\"ZAF\",\"region\":\"Africa\"},{\"name\":\"South Georgia and the South Sandwich Islands\",\"alpha2\":\"GS\",\"alpha3\":\"SGS\",\"region\":\"Americas\"},{\"name\":\"South Sudan\",\"alpha2\":\"SS\",\"alpha3\":\"SSD\",\"region\":\"Africa\"},{\"name\":\"Spain\",\"alpha2\":\"ES\",\"alpha3\":\"ESP\",\"region\":\"Europe\"},{\"name\":\"Sri Lanka\",\"alpha2\":\"LK\",\"alpha3\":\"LKA\",\"region\":\"Asia\"},{\"name\":\"Sudan\",\"alpha2\":\"SD\",\"alpha3\":\"SDN\",\"region\":\"Africa\"},{\"name\":\"Suriname\",\"alpha2\":\"SR\",\"alpha3\":\"SUR\",\"region\":\"Americas\"},{\"name\":\"Svalbard and Jan Mayen\",\"alpha2\":\"SJ\",\"alpha3\":\"SJM\",\"region\":\"Europe\"},{\"name\":\"Sweden\",\"alpha2\":\"SE\",\"alpha3\":\"SWE\",\"region\":\"Europe\"},{\"name\":\"Switzerland\",\"alpha2\":\"CH\",\"alpha3\":\"CHE\",\"region\":\"Europe\"},{\"name\":\"Syrian Arab Republic\",\"alpha2\":\"SY\",\"alpha3\":\"SYR\",\"region\":\"Asia\"},{\"name\":\"Taiwan, Province of China\",\"alpha2\":\"TW\",\"alpha3\":\"TWN\",\"region\":\"Asia\"},{\"name\":\"Tajikistan\",\"alpha2\":\"TJ\",\"alpha3\":\"TJK\",\"region\":\"Asia\"},{\"name\":\"Tanzania, United Republic of\",\"alpha2\":\"TZ\",\"alpha3\":\"TZA\",\"region\":\"Africa\"},{\"name\":\"Thailand\",\"alpha2\":\"TH\",\"alpha3\":\"THA\",\"region\":\"Asia\"},{\"name\":\"Timor-Leste\",\"alpha2\":\"TL\",\"alpha3\":\"TLS\",\"region\":\"Asia\"},{\"name\":\"Togo\",\"alpha2\":\"TG\",\"alpha3\":\"TGO\",\"region\":\"Africa\"},{\"name\":\"Tokelau\",\"alpha2\":\"TK\",\"alpha3\":\"TKL\",\"region\":\"Oceania\"},{\"name\":\"Tonga\",\"alpha2\":\"TO\",\"alpha3\":\"TON\",\"region\":\"Oceania\"},{\"name\":\"Trinidad and Tobago\",\"alpha2\":\"TT\",\"alpha3\":\"TTO\",\"region\":\"Americas\"},{\"name\":\"Tunisia\",\"alpha2\":\"TN\",\"alpha3\":\"TUN\",\"region\":\"Africa\"},{\"name\":\"Turkey\",\"alpha2\":\"TR\",\"alpha3\":\"TUR\",\"region\":\"Asia\"},{\"name\":\"Turkmenistan\",\"alpha2\":\"TM\",\"alpha3\":\"TKM\",\"region\":\"Asia\"},{\"name\":\"Turks and Caicos Islands\",\"alpha2\":\"TC\",\"alpha3\":\"TCA\",\"region\":\"Americas\"},{\"name\":\"Tuvalu\",\"alpha2\":\"TV\",\"alpha3\":\"TUV\",\"region\":\"Oceania\"},{\"name\":\"Uganda\",\"alpha2\":\"UG\",\"alpha3\":\"UGA\",\"region\":\"Africa\"},{\"name\":\"Ukraine\",\"alpha2\":\"UA\",\"alpha3\":\"UKR\",\"region\":\"Europe\"},{\"name\":\"United Arab Emirates\",\"alpha2\":\"AE\",\"alpha3\":\"ARE\",\"region\":\"Asia\"},{\"name\":\"United Kingdom of Great Britain and Northern Ireland\",\"alpha2\":\"GB\",\"alpha3\":\"GBR\",\"region\":\"Europe\"},{\"name\":\"United States of America\",\"alpha2\":\"US\",\"alpha3\":\"USA\",\"region\":\"Americas\"},{\"name\":\"United States Minor Outlying Islands\",\"alpha2\":\"UM\",\"alpha3\":\"UMI\",\"region\":\"Oceania\"},{\"name\":\"Uruguay\",\"alpha2\":\"UY\",\"alpha3\":\"URY\",\"region\":\"Americas\"},{\"name\":\"Uzbekistan\",\"alpha2\":\"UZ\",\"alpha3\":\"UZB\",\"region\":\"Asia\"},{\"name\":\"Vanuatu\",\"alpha2\":\"VU\",\"alpha3\":\"VUT\",\"region\":\"Oceania\"},{\"name\":\"Venezuela (Bolivarian Republic of)\",\"alpha2\":\"VE\",\"alpha3\":\"VEN\",\"region\":\"Americas\"},{\"name\":\"Viet Nam\",\"alpha2\":\"VN\",\"alpha3\":\"VNM\",\"region\":\"Asia\"},{\"name\":\"Virgin Islands (British)\",\"alpha2\":\"VG\",\"alpha3\":\"VGB\",\"region\":\"Americas\"},{\"name\":\"Virgin Islands (U.S.)\",\"alpha2\":\"VI\",\"alpha3\":\"VIR\",\"region\":\"Americas\"},{\"name\":\"Wallis and Futuna\",\"alpha2\":\"WF\",\"alpha3\":\"WLF\",\"region\":\"Oceania\"},{\"name\":\"Western Sahara\",\"alpha2\":\"EH\",\"alpha3\":\"ESH\",\"region\":\"Africa\"},{\"name\":\"Yemen\",\"alpha2\":\"YE\",\"alpha3\":\"YEM\",\"region\":\"Asia\"},{\"name\":\"Zambia\",\"alpha2\":\"ZM\",\"alpha3\":\"ZMB\",\"region\":\"Africa\"},{\"name\":\"Zimbabwe\",\"alpha2\":\"ZW\",\"alpha3\":\"ZWE\",\"region\":\"Africa\"},{\"name\":\"Byteland PROD\",\"alpha2\":\"YY\",\"alpha3\":\"YYY\",\"region\":\"Europe\"}];",
|
||
"",
|
||
"",
|
||
"const codesToCheck = ['RU', 'SK', 'YY'];",
|
||
"",
|
||
"codesToCheck.forEach(function (code) {",
|
||
" pm.test(`Get country \"${code}\" [existing]`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/countries/\" + code;",
|
||
"",
|
||
" pm.sendRequest(url, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, countrySchema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" const expected = countries.find((c) => c.alpha2 == code);",
|
||
"",
|
||
" console.log(\"got\", resp, \"expected\", expected);",
|
||
" pm.expect(resp).to.deep.eq(expected, `Got invalid object`);",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get country by alpha2 [not found]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const unknownCodes = ['UU', 'PP', 'GJ'];",
|
||
"",
|
||
"unknownCodes.forEach(function (code) {",
|
||
" pm.test(`Get country \"${code}\" [non-existing]`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/countries/\" + code;",
|
||
"",
|
||
" pm.sendRequest(url, function (err, response) {",
|
||
" pm.test(\"Validate response [Not Found expected]\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(404, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"name": "03/auth/registration",
|
||
"item": [
|
||
{
|
||
"name": "Register a user [basic]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"profile\": {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о профиле пользователя\",",
|
||
" \"properties\": {",
|
||
" \"login\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Логин пользователя\",",
|
||
" \"maxLength\": 30,",
|
||
" \"pattern\": \"[a-zA-Z0-9-]+\"",
|
||
" },",
|
||
" \"email\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"E-mail пользователя\",",
|
||
" \"maxLength\": 50",
|
||
" },",
|
||
" \"countryCode\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"isPublic\": {",
|
||
" \"type\": \"boolean\",",
|
||
" \"description\": \"Является ли данный профиль публичным. \\n\\nПубличные профили доступны другим пользователям: если профиль публичный, любой пользователь платформы сможет получить информацию о пользователе.\\n\"",
|
||
" },",
|
||
" \"phone\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Номер телефона пользователя в формате +123456789\",",
|
||
" \"pattern\": \"\\\\+[\\\\d]+\"",
|
||
" },",
|
||
" \"image\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Ссылка на фото для аватара пользователя\",",
|
||
" \"maxLength\": 200",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"login\",",
|
||
" \"email\",",
|
||
" \"countryCode\",",
|
||
" \"isPublic\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"profile\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Register a user\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'yellowMonkey2',",
|
||
" 'email': 'yellowstone1980@you.ru',",
|
||
" 'password': '$aba4821FWfew01#.fewA$',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+74951239922',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" const profile = {",
|
||
" 'profile': {",
|
||
" 'login': 'yellowMonkey2',",
|
||
" 'email': 'yellowstone1980@you.ru',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+74951239922',",
|
||
" }",
|
||
" }",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(201, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" console.log(\"got\", resp, \"expected\", profile);",
|
||
" pm.expect(resp).to.deep.eq(profile, `Got invalid object`);",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Register a user [without optional fields]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"profile\": {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о профиле пользователя\",",
|
||
" \"properties\": {",
|
||
" \"login\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Логин пользователя\",",
|
||
" \"maxLength\": 30,",
|
||
" \"pattern\": \"[a-zA-Z0-9-]+\"",
|
||
" },",
|
||
" \"email\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"E-mail пользователя\",",
|
||
" \"maxLength\": 50",
|
||
" },",
|
||
" \"countryCode\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"isPublic\": {",
|
||
" \"type\": \"boolean\",",
|
||
" \"description\": \"Является ли данный профиль публичным. \\n\\nПубличные профили доступны другим пользователям: если профиль публичный, любой пользователь платформы сможет получить информацию о пользователе.\\n\"",
|
||
" },",
|
||
" \"phone\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Номер телефона пользователя в формате +123456789\",",
|
||
" \"pattern\": \"\\\\+[\\\\d]+\"",
|
||
" },",
|
||
" \"image\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Ссылка на фото для аватара пользователя\",",
|
||
" \"maxLength\": 200",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"login\",",
|
||
" \"email\",",
|
||
" \"countryCode\",",
|
||
" \"isPublic\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"profile\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Register a user\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'redGoat',",
|
||
" 'email': 'redGoat@you.ru',",
|
||
" 'password': 'PWD@few29aaa',",
|
||
" 'countryCode': 'KZ',",
|
||
" 'isPublic': true,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" const profile = {",
|
||
" 'profile': {",
|
||
" 'login': 'redGoat',",
|
||
" 'email': 'redGoat@you.ru',",
|
||
" 'countryCode': 'KZ',",
|
||
" 'isPublic': true,",
|
||
" }",
|
||
" }",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(201, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" console.log(\"got\", resp, \"expected\", profile);",
|
||
" pm.expect(resp).to.deep.eq(profile, `Got invalid object`);",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Register a duplicated user [error]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const cases = [",
|
||
" {",
|
||
" 'conflict': 'login',",
|
||
" 'body': {",
|
||
" 'login': 'yellowMonkey2',",
|
||
" 'email': 'yellowstone12392@you.ru',",
|
||
" 'password': '$aba4821FWfew01#.fewA$',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': true,",
|
||
" }",
|
||
" },",
|
||
" {",
|
||
" 'conflict': 'email',",
|
||
" 'body': {",
|
||
" 'login': 'spiderman',",
|
||
" 'email': 'yellowstone1980@you.ru',",
|
||
" 'password': '$991jjFFF#.fewA$',",
|
||
" 'countryCode': 'LV',",
|
||
" 'isPublic': true,",
|
||
" }",
|
||
" },",
|
||
" {",
|
||
" 'conflict': 'phone',",
|
||
" 'body': {",
|
||
" 'login': 'mickeymouse',",
|
||
" 'email': 'mickeymouse@you.ru',",
|
||
" 'password': '$1kewofew!#.fewA$',",
|
||
" 'countryCode': 'MG',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+74951239922',",
|
||
" }",
|
||
" }",
|
||
"];",
|
||
"",
|
||
"cases.forEach(function (data) {",
|
||
" pm.test(`Register a user with duplicated ${data.conflict}`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify(data.body)",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [expect conflict on ${data.conflict}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" console.log('Tried to register a user', data.body);",
|
||
" pm.expect(response.code).to.be.eq(409, \"Invalid response code status (expected 409 due to openapi.yml line #163\");",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Register a user with not strong enough password",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const passwords = [",
|
||
" 'sH0r#',",
|
||
" '#onlylowercase1$',",
|
||
" '@UPPERCASE1!',",
|
||
" 'NoDigitsAtAll'",
|
||
"];",
|
||
"",
|
||
"passwords.forEach(function (password) {",
|
||
" pm.test(`Register a user with not strong enough password \"${password}\"`, () => {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'passwordkitten',",
|
||
" 'email': 'kitty@gmail.com',",
|
||
" 'password': password,",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': true,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [password ${password}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(400, \"Invalid response code status (expected 400 due to openapi.yml line #842\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"});",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Register a user from non-existing country",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"pm.test(\"Register a user from non-existing country\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'MIMMIMI',",
|
||
" 'email': 'feowio321@you.ru',",
|
||
" 'password': '$GGAAAzzo3#.fewA$',",
|
||
" 'countryCode': 'UU',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+3742371919',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response [expect error]\", () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(400, \"Invalid response code status (expected 400 due to openapi.yml line #151\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"name": "04/auth/sign-in",
|
||
"item": [
|
||
{
|
||
"name": "Register a user",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"profile\": {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о профиле пользователя\",",
|
||
" \"properties\": {",
|
||
" \"login\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Логин пользователя\",",
|
||
" \"maxLength\": 30,",
|
||
" \"pattern\": \"[a-zA-Z0-9-]+\"",
|
||
" },",
|
||
" \"email\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"E-mail пользователя\",",
|
||
" \"maxLength\": 50",
|
||
" },",
|
||
" \"countryCode\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"isPublic\": {",
|
||
" \"type\": \"boolean\",",
|
||
" \"description\": \"Является ли данный профиль публичным. \\n\\nПубличные профили доступны другим пользователям: если профиль публичный, любой пользователь платформы сможет получить информацию о пользователе.\\n\"",
|
||
" },",
|
||
" \"phone\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Номер телефона пользователя в формате +123456789\",",
|
||
" \"pattern\": \"\\\\+[\\\\d]+\"",
|
||
" },",
|
||
" \"image\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Ссылка на фото для аватара пользователя\",",
|
||
" \"maxLength\": 200",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"login\",",
|
||
" \"email\",",
|
||
" \"countryCode\",",
|
||
" \"isPublic\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"profile\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Register a user\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'yellowMonkey200',",
|
||
" 'email': 'yellowstone2000@gmail.com',",
|
||
" 'password': '$PASSw0rd^',",
|
||
" 'countryCode': 'BY',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+74951439922',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" const profile = {",
|
||
" 'profile': {",
|
||
" 'login': 'yellowMonkey200',",
|
||
" 'email': 'yellowstone2000@gmail.com',",
|
||
" 'countryCode': 'BY',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+74951439922',",
|
||
" }",
|
||
" }",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.oneOf([201, 409], \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" pm.expect(resp).to.deep.eq(profile, `Got invalid object`);",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"token\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Сгенерированный токен пользователя\",",
|
||
" \"minLength\": 20,",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"token\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Sign in\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'yellowMonkey200',",
|
||
" 'password': '$PASSw0rd^',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" console.log('Token', resp.token);",
|
||
" pm.expect(resp.token).to.have.lengthOf.above(19, \"Violated requirements on minimum token length (openapi.yml line #206)\");",
|
||
"",
|
||
" const previousToken = resp.token;",
|
||
"",
|
||
" setTimeout(() => {",
|
||
" pm.test('Sign in one more time to check if tokens are unique', () => {",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test('Validate response [expect a new token]', () => {",
|
||
" var newResp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(newResp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" const newToken = newResp.token;",
|
||
" console.log('previous token', previousToken);",
|
||
" console.log('new token', newToken);",
|
||
"",
|
||
" pm.expect(newToken).to.not.equal(previousToken, \"Tokens have to be unique (openapi.yml line #174)\");",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
" }, 1000);",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in with invalid login",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"pm.test(\"Sign in with invalid credentials\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'yellowMonkey201',",
|
||
" 'password': '$PASSw0rd^',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(401, \"Invalid response code status (openapi.yml line #211)\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in with invalid password",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"pm.test(\"Sign in with invalid credentials\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'yellowMonkey200',",
|
||
" 'password': 'Ewfffl0',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(401, \"Invalid response code status (openapi.yml line #211)\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"name": "05/me",
|
||
"item": [
|
||
{
|
||
"name": "Register a user",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"profile\": {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о профиле пользователя\",",
|
||
" \"properties\": {",
|
||
" \"login\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Логин пользователя\",",
|
||
" \"maxLength\": 30,",
|
||
" \"pattern\": \"[a-zA-Z0-9-]+\"",
|
||
" },",
|
||
" \"email\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"E-mail пользователя\",",
|
||
" \"maxLength\": 50",
|
||
" },",
|
||
" \"countryCode\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"isPublic\": {",
|
||
" \"type\": \"boolean\",",
|
||
" \"description\": \"Является ли данный профиль публичным. \\n\\nПубличные профили доступны другим пользователям: если профиль публичный, любой пользователь платформы сможет получить информацию о пользователе.\\n\"",
|
||
" },",
|
||
" \"phone\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Номер телефона пользователя в формате +123456789\",",
|
||
" \"pattern\": \"\\\\+[\\\\d]+\"",
|
||
" },",
|
||
" \"image\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Ссылка на фото для аватара пользователя\",",
|
||
" \"maxLength\": 200",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"login\",",
|
||
" \"email\",",
|
||
" \"countryCode\",",
|
||
" \"isPublic\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"profile\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Register a user\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'yellowMonkey335',",
|
||
" 'email': 'iamnotayellowmonkey@gmail.com',",
|
||
" 'password': '$PASSw0rd^',",
|
||
" 'countryCode': 'BY',",
|
||
" 'isPublic': true,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" const profile = {",
|
||
" 'profile': {",
|
||
" 'login': 'yellowMonkey335',",
|
||
" 'email': 'iamnotayellowmonkey@gmail.com',",
|
||
" 'countryCode': 'BY',",
|
||
" 'isPublic': true,",
|
||
" }",
|
||
" }",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.oneOf([201, 409], \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" pm.expect(resp).to.deep.eq(profile, `Got invalid object`);",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Register another user",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"profile\": {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о профиле пользователя\",",
|
||
" \"properties\": {",
|
||
" \"login\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Логин пользователя\",",
|
||
" \"maxLength\": 30,",
|
||
" \"pattern\": \"[a-zA-Z0-9-]+\"",
|
||
" },",
|
||
" \"email\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"E-mail пользователя\",",
|
||
" \"maxLength\": 50",
|
||
" },",
|
||
" \"countryCode\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"isPublic\": {",
|
||
" \"type\": \"boolean\",",
|
||
" \"description\": \"Является ли данный профиль публичным. \\n\\nПубличные профили доступны другим пользователям: если профиль публичный, любой пользователь платформы сможет получить информацию о пользователе.\\n\"",
|
||
" },",
|
||
" \"phone\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Номер телефона пользователя в формате +123456789\",",
|
||
" \"pattern\": \"\\\\+[\\\\d]+\"",
|
||
" },",
|
||
" \"image\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Ссылка на фото для аватара пользователя\",",
|
||
" \"maxLength\": 200",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"login\",",
|
||
" \"email\",",
|
||
" \"countryCode\",",
|
||
" \"isPublic\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"profile\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Register a user\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'billyJean',",
|
||
" 'email': 'billyJean@gmail.com',",
|
||
" 'password': 'Password0',",
|
||
" 'countryCode': 'UG',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+1999999999'",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" const profile = {",
|
||
" 'profile': {",
|
||
" 'login': 'billyJean',",
|
||
" 'email': 'billyJean@gmail.com',",
|
||
" 'countryCode': 'UG',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+1999999999'",
|
||
" }",
|
||
" }",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.oneOf([201, 409], \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" pm.expect(resp).to.deep.eq(profile, `Got invalid object`);",
|
||
" pm.globals.set(\"05_taken_phone\", resp.phone);",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"token\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Сгенерированный токен пользователя\",",
|
||
" \"minLength\": 20,",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"token\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Sign in\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'yellowMonkey335',",
|
||
" 'password': '$PASSw0rd^',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" pm.globals.set(\"05_profile_token\", resp.token);",
|
||
" console.log(\"Token has been saved\", resp.token)",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get my profile",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const profile = {",
|
||
" 'login': 'yellowMonkey335',",
|
||
" 'email': 'iamnotayellowmonkey@gmail.com',",
|
||
" 'countryCode': 'BY',",
|
||
" 'isPublic': true,",
|
||
"};",
|
||
"const token = pm.globals.get(\"05_profile_token\");",
|
||
"",
|
||
"pm.test(\"Get profile\", function () {",
|
||
" console.log('Getting profile with token', token);",
|
||
" ",
|
||
" const url = pm.variables.get(\"base_url\") + \"/me/profile\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate profile\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" console.log(\"Got profile\", resp);",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" pm.expect(resp).to.deep.eq(profile, \"Invalid profile\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get my profile with invalid token",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const tokens = [",
|
||
" '',",
|
||
" 'blahblahfewufojweiiojfweifwejiojfweioj'",
|
||
"];",
|
||
"",
|
||
"tokens.forEach(function (token) {",
|
||
" pm.test(`Get profile with invalid token \"${token}\"`, function () {",
|
||
" const url = pm.variables.get(\"base_url\") + \"/me/profile\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" pm.expect(response.code).to.be.eq(401, \"Invalid response code status (openapi.yml line #233)\");",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Patch profile",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const oldProfile = {",
|
||
" 'login': 'yellowMonkey335',",
|
||
" 'email': 'iamnotayellowmonkey@gmail.com',",
|
||
" 'countryCode': 'BY',",
|
||
" 'isPublic': true,",
|
||
"};",
|
||
"const patchData = {",
|
||
" 'countryCode': 'YY',",
|
||
" 'isPublic': false,",
|
||
" 'phone': '+4821930125',",
|
||
" 'image': 'https://http.cat/images/200.jpg',",
|
||
"};",
|
||
"const expected = {",
|
||
" 'login': 'yellowMonkey335',",
|
||
" 'email': 'iamnotayellowmonkey@gmail.com',",
|
||
" 'countryCode': 'YY',",
|
||
" 'isPublic': false,",
|
||
" 'phone': '+4821930125',",
|
||
" 'image': 'https://http.cat/images/200.jpg',",
|
||
"};",
|
||
"",
|
||
"const token = pm.globals.get(\"05_profile_token\");",
|
||
"",
|
||
"pm.test(\"Patch profile\", function () {",
|
||
" const url = pm.variables.get(\"base_url\") + \"/me/profile\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'PATCH',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify(patchData)",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" console.log('Patch data', patchData);",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" console.log('Got profile', resp);",
|
||
" console.log('Expected', expected);",
|
||
"",
|
||
" pm.expect(resp).to.deep.eq(expected, 'Invalid profile');",
|
||
"",
|
||
" pm.test('Patch with the same data one more time', () => {",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test('Validate response, no conflicts expected as the phone is used by the same user ', () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" console.log('Got profile', resp);",
|
||
" console.log('Expected', expected);",
|
||
"",
|
||
" pm.expect(resp).to.deep.eq(expected, 'Invalid profile');",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Patch profile with conflict",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const patchData = {",
|
||
" 'phone': '+1999999999',",
|
||
"};",
|
||
"const token = pm.globals.get(\"05_profile_token\");",
|
||
"",
|
||
"pm.test(\"Patch profile and expect conflict\", function () {",
|
||
" const url = pm.variables.get(\"base_url\") + \"/me/profile\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'PATCH',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify(patchData)",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" console.log('Patch data', patchData);",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(409, \"Invalid response code status (openapi.yml line #300)\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Patch profile with a non-existing country",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const patchData = {",
|
||
" 'countryCode': 'UU',",
|
||
"};",
|
||
"const token = pm.globals.get(\"05_profile_token\");",
|
||
"",
|
||
"pm.test(\"Patch profile with a non-existing country\", function () {",
|
||
" const url = pm.variables.get(\"base_url\") + \"/me/profile\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'PATCH',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify(patchData)",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" console.log('Patch data', patchData);",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(400, \"Invalid response code status (openapi.yml line #288)\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"name": "06/profiles",
|
||
"item": [
|
||
{
|
||
"name": "Register a user",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"profile\": {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о профиле пользователя\",",
|
||
" \"properties\": {",
|
||
" \"login\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Логин пользователя\",",
|
||
" \"maxLength\": 30,",
|
||
" \"pattern\": \"[a-zA-Z0-9-]+\"",
|
||
" },",
|
||
" \"email\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"E-mail пользователя\",",
|
||
" \"maxLength\": 50",
|
||
" },",
|
||
" \"countryCode\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"isPublic\": {",
|
||
" \"type\": \"boolean\",",
|
||
" \"description\": \"Является ли данный профиль публичным. \\n\\nПубличные профили доступны другим пользователям: если профиль публичный, любой пользователь платформы сможет получить информацию о пользователе.\\n\"",
|
||
" },",
|
||
" \"phone\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Номер телефона пользователя в формате +123456789\",",
|
||
" \"pattern\": \"\\\\+[\\\\d]+\"",
|
||
" },",
|
||
" \"image\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Ссылка на фото для аватара пользователя\",",
|
||
" \"maxLength\": 200",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"login\",",
|
||
" \"email\",",
|
||
" \"countryCode\",",
|
||
" \"isPublic\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"profile\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Register a user\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'bloodmary',",
|
||
" 'email': 'bloodmary@ya.ru',",
|
||
" 'password': '$ab1a4821FWfew01#.fewA$',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+73121239992',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" const profile = {",
|
||
" 'profile': {",
|
||
" 'login': 'bloodmary',",
|
||
" 'email': 'bloodmary@ya.ru',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+73121239992',",
|
||
" }",
|
||
" }",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.oneOf([201, 409], \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Register other user",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"profile\": {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о профиле пользователя\",",
|
||
" \"properties\": {",
|
||
" \"login\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Логин пользователя\",",
|
||
" \"maxLength\": 30,",
|
||
" \"pattern\": \"[a-zA-Z0-9-]+\"",
|
||
" },",
|
||
" \"email\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"E-mail пользователя\",",
|
||
" \"maxLength\": 50",
|
||
" },",
|
||
" \"countryCode\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"isPublic\": {",
|
||
" \"type\": \"boolean\",",
|
||
" \"description\": \"Является ли данный профиль публичным. \\n\\nПубличные профили доступны другим пользователям: если профиль публичный, любой пользователь платформы сможет получить информацию о пользователе.\\n\"",
|
||
" },",
|
||
" \"phone\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Номер телефона пользователя в формате +123456789\",",
|
||
" \"pattern\": \"\\\\+[\\\\d]+\"",
|
||
" },",
|
||
" \"image\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Ссылка на фото для аватара пользователя\",",
|
||
" \"maxLength\": 200",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"login\",",
|
||
" \"email\",",
|
||
" \"countryCode\",",
|
||
" \"isPublic\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"profile\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Register a user\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'otherUser1234',",
|
||
" 'email': 'otherUser1234@you.ru',",
|
||
" 'password': '$1ab1221F23fdWfew01#.fewA$',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+71111239922',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" const profile = {",
|
||
" 'profile': {",
|
||
" 'login': 'otherUser1234',",
|
||
" 'email': 'otherUser1234@you.ru',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+71111239922',",
|
||
" }",
|
||
" }",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.oneOf([201, 409], \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"token\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Сгенерированный токен пользователя\",",
|
||
" \"minLength\": 20,",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"token\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Sign in\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'bloodmary',",
|
||
" 'password': '$ab1a4821FWfew01#.fewA$',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" pm.globals.set(\"06_profile_token\", resp.token);",
|
||
" console.log(\"Token has been saved\")",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get other user profile",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"profile\": {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о профиле пользователя\",",
|
||
" \"properties\": {",
|
||
" \"login\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Логин пользователя\",",
|
||
" \"maxLength\": 30,",
|
||
" \"pattern\": \"[a-zA-Z0-9-]+\"",
|
||
" },",
|
||
" \"email\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"E-mail пользователя\",",
|
||
" \"maxLength\": 50",
|
||
" },",
|
||
" \"countryCode\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"isPublic\": {",
|
||
" \"type\": \"boolean\",",
|
||
" \"description\": \"Является ли данный профиль публичным. \\n\\nПубличные профили доступны другим пользователям: если профиль публичный, любой пользователь платформы сможет получить информацию о пользователе.\\n\"",
|
||
" },",
|
||
" \"phone\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Номер телефона пользователя в формате +123456789\",",
|
||
" \"pattern\": \"\\\\+[\\\\d]+\"",
|
||
" },",
|
||
" \"image\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Ссылка на фото для аватара пользователя\",",
|
||
" \"maxLength\": 200",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"login\",",
|
||
" \"email\",",
|
||
" \"countryCode\",",
|
||
" \"isPublic\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Get other user profile\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/profiles/otherUser1234\";",
|
||
" const token = pm.globals.get(\"06_profile_token\");",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" pm.expect(resp.login).to.be.eq(\"otherUser1234\", \"Invalid login\");",
|
||
" pm.expect(resp.email).to.be.eq(\"otherUser1234@you.ru\", \"Invalid email\");",
|
||
" pm.expect(resp.countryCode).to.be.eq(\"RU\", \"Invalid countryCode\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get profile with invalid token",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const tokens = [",
|
||
" '',",
|
||
" 'blahblahfewufojweiiojfweifwejiojfweioj'",
|
||
"];",
|
||
"",
|
||
"tokens.forEach(function (token) {",
|
||
" pm.test(`Get profile with invalid token \"${token}\"`, function () {",
|
||
" const url = pm.variables.get(\"base_url\") + \"/profiles/otherUser1234\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" pm.expect(response.code).to.be.eq(401, \"Invalid response code status (openapi.yml line #332)\");",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get a non-existing user's profile",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"06_profile_token\");",
|
||
"",
|
||
"pm.test(`Get a non-existing profile \"${token}\"`, function () {",
|
||
" const url = pm.variables.get(\"base_url\") + \"/profiles/iDoesntExist\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" pm.expect(response.code).to.be.eq(403, \"Invalid response code status (openapi.yml line #339)\");",
|
||
" });",
|
||
" });",
|
||
"});"
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"name": "07/password",
|
||
"item": [
|
||
{
|
||
"name": "Register a user",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"profile\": {",
|
||
" \"type\": \"object\",",
|
||
" \"description\": \"Информация о профиле пользователя\",",
|
||
" \"properties\": {",
|
||
" \"login\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Логин пользователя\",",
|
||
" \"maxLength\": 30,",
|
||
" \"pattern\": \"[a-zA-Z0-9-]+\"",
|
||
" },",
|
||
" \"email\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"E-mail пользователя\",",
|
||
" \"maxLength\": 50",
|
||
" },",
|
||
" \"countryCode\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Двухбуквенный код, уникально идентифицирующий страну\",",
|
||
" \"maxLength\": 2,",
|
||
" \"pattern\": \"[a-zA-Z]{2}\"",
|
||
" },",
|
||
" \"isPublic\": {",
|
||
" \"type\": \"boolean\",",
|
||
" \"description\": \"Является ли данный профиль публичным. \\n\\nПубличные профили доступны другим пользователям: если профиль публичный, любой пользователь платформы сможет получить информацию о пользователе.\\n\"",
|
||
" },",
|
||
" \"phone\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Номер телефона пользователя в формате +123456789\",",
|
||
" \"pattern\": \"\\\\+[\\\\d]+\"",
|
||
" },",
|
||
" \"image\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Ссылка на фото для аватара пользователя\",",
|
||
" \"maxLength\": 200",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"login\",",
|
||
" \"email\",",
|
||
" \"countryCode\",",
|
||
" \"isPublic\"",
|
||
" ]",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"profile\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Register a user\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'yellowMonkey2023',",
|
||
" 'email': 'yellowMonkey2023@you.ru',",
|
||
" 'password': '$oldPassword0',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+74951239223',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" const profile = {",
|
||
" 'profile': {",
|
||
" 'login': 'yellowMonkey2023',",
|
||
" 'email': 'yellowMonkey2023@you.ru',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': true,",
|
||
" 'phone': '+74951239223',",
|
||
" }",
|
||
" }",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.oneOf([201, 409], \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"token\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Сгенерированный токен пользователя\",",
|
||
" \"minLength\": 20,",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"token\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Sign in\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'yellowMonkey2023',",
|
||
" 'password': '$oldPassword0',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" pm.globals.set(\"07_profile_token\", resp.token);",
|
||
" console.log(\"Token has been saved\")",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Change password [invalid token]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"pm.test(\"Update password with invalid token\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/me/updatePassword\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer invalidTOKENjfewoijfiowej`,",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'oldPassword': '$oldPassword0',",
|
||
" 'newPassword': '$aba4821FWTYR^%#.fewA$',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate get other user profile response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(401, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Change password [invalid old password]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"pm.test(\"Update password with invalid old password\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/me/updatePassword\";",
|
||
" const token = pm.globals.get(\"07_profile_token\");",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'oldPassword': 'lolL0L',",
|
||
" 'newPassword': '$aba4821FWTYR^%#.fewA$',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(403, \"Invalid response code status (invalid old password)\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Change password [not strong enough]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const passwords = [",
|
||
" 'sH0r#',",
|
||
" '#onlylowercase1$',",
|
||
" '@UPPERCASE1!',",
|
||
" 'NoDigitsAtAll'",
|
||
"];",
|
||
"const token = pm.globals.get(\"07_profile_token\");",
|
||
"",
|
||
"passwords.forEach(function (password) {",
|
||
" pm.test(`Update password with not strong enough password \"${password}\"`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/me/updatePassword\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'oldPassword': '$oldPassword0',",
|
||
" 'newPassword': password,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response (for password \"${password}\")`, () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(400, \"Invalid response code status (not strong enough password, openapi.yml line #387)\");",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Change password",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"pm.test(\"Update password\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/me/updatePassword\";",
|
||
" const token = pm.globals.get(\"07_profile_token\");",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'oldPassword': '$oldPassword0',",
|
||
" 'newPassword': '#newPassword1',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate get other user profile response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in with old password",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"token\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Сгенерированный токен пользователя\",",
|
||
" \"minLength\": 20,",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"token\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"pm.test(\"Sign in\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'yellowMonkey2023',",
|
||
" 'password': '$oldPassword0',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
" pm.expect(response.code).to.be.eq(401, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in with new password",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var schema = {",
|
||
" \"type\": \"object\",",
|
||
" \"properties\": {",
|
||
" \"token\": {",
|
||
" \"type\": \"string\",",
|
||
" \"description\": \"Сгенерированный токен пользователя\",",
|
||
" \"minLength\": 20,",
|
||
" }",
|
||
" },",
|
||
" \"required\": [",
|
||
" \"token\"",
|
||
" ],",
|
||
" \"$schema\": \"http://json-schema.org/draft-04/schema#\"",
|
||
"};",
|
||
"",
|
||
"setTimeout(() => {",
|
||
" pm.test(\"Sign in\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'yellowMonkey2023',",
|
||
" 'password': '#newPassword1',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" pm.expect(tv4.validate(resp, schema), \"Invalid JSON schema\").to.be.true;",
|
||
"",
|
||
" pm.globals.set(\"07_profile_new_token\", resp.token);",
|
||
" console.log(\"Token has been saved\")",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"}, 1000); // Wait until new second to guarantee token uniquiness ",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get my profile with new token",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"07_profile_new_token\");",
|
||
"",
|
||
"pm.test(\"Get profile\", function () {",
|
||
" console.log('Getting profile with token', token);",
|
||
" ",
|
||
" const url = pm.variables.get(\"base_url\") + \"/me/profile\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" console.log(\"Got profile\", resp);",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" pm.expect(resp.login).to.be.eq(\"yellowMonkey2023\", \"Invalid login\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get my profile with old token",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"07_profile_token\");",
|
||
"",
|
||
"pm.test(\"Get profile\", function () {",
|
||
" console.log('Getting profile with token', token);",
|
||
" ",
|
||
" const url = pm.variables.get(\"base_url\") + \"/me/profile\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" console.log(\"Got profile\", resp);",
|
||
" pm.expect(response.code).to.be.eq(401, \"Invalid response code status (old token has to be invalidated)\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"name": "08/friends",
|
||
"item": [
|
||
{
|
||
"name": "Register users",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const users = [",
|
||
" {",
|
||
" 'login': 'user1',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user2',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user3',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user4',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user5',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user6',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user7',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Alice',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Bob',",
|
||
" 'isPublic': false,",
|
||
" },",
|
||
"]",
|
||
"",
|
||
"users.forEach(function (userData) {",
|
||
" pm.test(`Register user \"${userData.login}\"`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': userData.login,",
|
||
" 'email': userData.login + 'reg@yahoo.com',",
|
||
" 'password': 'Strong0!',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': userData.isPublic,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [user ${userData.login}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(201, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"users = [",
|
||
" 'Alice',",
|
||
" 'Bob',",
|
||
"]",
|
||
"",
|
||
"users.forEach(function (user) {",
|
||
" pm.test(`Sign in as ${user}`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': user,",
|
||
" 'password': 'Strong0!',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" pm.globals.set(\"08_friends_token_\" + user, resp.token);",
|
||
" console.log(\"Token has been saved\")",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Friends add / remove",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const log = [",
|
||
" {",
|
||
" 'login': 'user1',",
|
||
" 'action': 'add',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user2',",
|
||
" 'action': 'add',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user3',",
|
||
" 'action': 'add',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user4',",
|
||
" 'action': 'add',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user5',",
|
||
" 'action': 'add',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user5',",
|
||
" 'action': 'remove',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user2',",
|
||
" 'action': 'remove',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user4',",
|
||
" 'action': 'remove',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user6',",
|
||
" 'action': 'add',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user5',",
|
||
" 'action': 'add',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user7',",
|
||
" 'action': 'add',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user2',",
|
||
" 'action': 'add',",
|
||
" },",
|
||
"];",
|
||
"// user1, user3, user6, user5, user7, user2",
|
||
"const token = pm.globals.get(\"08_friends_token_Alice\");",
|
||
"",
|
||
"var friendList = [];",
|
||
"",
|
||
"let promises = [];",
|
||
"let resolves = [];",
|
||
"for (var i = 0; i < log.length; i++) {",
|
||
" promises.push(new Promise((resolve) => {",
|
||
" resolves.push(resolve);",
|
||
" }));",
|
||
"}",
|
||
"",
|
||
"function testAction(idx) {",
|
||
" if (idx >= log.length) {",
|
||
" return;",
|
||
" }",
|
||
"",
|
||
" const op = log[idx];",
|
||
"",
|
||
" pm.test(`Friends action: ${op.action} \"${op.login}\"`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/friends/\" + op.action;",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': op.login,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [${op.action} \"${op.login}\"}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" if (op.action == 'add') {",
|
||
" friendList.push(op.login);",
|
||
" } else {",
|
||
" const index = friendList.indexOf(op.login);",
|
||
" if (index !== -1) {",
|
||
" friendList.splice(index, 1);",
|
||
" }",
|
||
" }",
|
||
"",
|
||
" console.log('Actual friend list', friendList);",
|
||
"",
|
||
" resolves[idx]();",
|
||
"",
|
||
" testAction(idx + 1);",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"}",
|
||
"",
|
||
"testAction(0);",
|
||
"",
|
||
"async function waitAll() {",
|
||
" const result = await Promise.all(promises);",
|
||
" console.log('Finish waiting');",
|
||
"}",
|
||
"waitAll();",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Friend list with pagination",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const querystring = require('querystring');",
|
||
"",
|
||
"const params = [",
|
||
" {",
|
||
" 'offset': 0,",
|
||
" 'limit': 3,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 3,",
|
||
" 'limit': 3,",
|
||
" },",
|
||
" {",
|
||
" 'offset': null,",
|
||
" 'limit': 10,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 1,",
|
||
" 'limit': 2,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 0,",
|
||
" 'limit': 4,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 4,",
|
||
" 'limit': 4,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 8,",
|
||
" 'limit': 4,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 3,",
|
||
" 'limit': null,",
|
||
" },",
|
||
" {",
|
||
" 'offset': null,",
|
||
" 'limit': null,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 5,",
|
||
" 'limit': 1,",
|
||
" },",
|
||
"];",
|
||
"// user1, user3, user6, user5, user7, user2",
|
||
"const token = pm.globals.get(\"08_friends_token_Alice\");",
|
||
"",
|
||
"var expected = [\"user2\", \"user7\", \"user5\", \"user6\", \"user3\", \"user1\"];",
|
||
"",
|
||
"params.forEach(function (page) {",
|
||
" pm.test(`Get friends [offset ${page.offset}, limit ${page.limit}]`, function () {",
|
||
" var data = {};",
|
||
" if (page.offset != null) {",
|
||
" data['offset'] = page.offset;",
|
||
" }",
|
||
" if (page.limit != null) {",
|
||
" data['limit'] = page.limit;",
|
||
" }",
|
||
" const query = querystring.stringify(data);",
|
||
"",
|
||
" var url = pm.variables.get(\"base_url\") + \"/friends\";",
|
||
" if (query.length > 0) {",
|
||
" url += `?${query}`;",
|
||
" }",
|
||
"",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [offset ${page.offset}, limit ${page.limit}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" var offset = page.offset;",
|
||
" if (offset == null) {",
|
||
" offset = 0;",
|
||
" }",
|
||
"",
|
||
" var limit = page.limit;",
|
||
" if (limit == null) {",
|
||
" limit = 5;",
|
||
" }",
|
||
"",
|
||
" const start = Math.min(offset, expected.length);",
|
||
" const end = Math.min(offset + limit, expected.length);",
|
||
" pm.expect(resp).to.have.lengthOf(end - start, \"Invalid response array length\");",
|
||
"",
|
||
" for (var i = start; i < end; i++) {",
|
||
" const idx = i - start;",
|
||
" pm.expect(resp[idx].login).to.be.eq(expected[i], `Invalid login of user #${idx}`);",
|
||
" }",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Add a non-existing user",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"08_friends_token_Alice\");",
|
||
"",
|
||
"pm.test(`Add to friends a user that doesn't exist`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/friends/add\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': \"IDoesntExist\",",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(404, \"Invalid response code status (openapi.yml line #450)\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Remove users that are not friends",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"08_friends_token_Alice\");",
|
||
"",
|
||
"pm.test(`Remove a user that is not a friend`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/friends/remove\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'Bob',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get private profile [failure]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"08_friends_token_Alice\");",
|
||
"",
|
||
"pm.test(\"Get private profile without permission\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/profiles/Bob\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(403, \"Invalid response code status (profile is private and Alice is not a friend of Bob)\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Bob adds Alice to friends",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"08_friends_token_Bob\");",
|
||
"",
|
||
"pm.test(\"Bob adds Alice to friends and opens his profile to her\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/friends/add\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'Alice',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get private profile [success]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"08_friends_token_Alice\");",
|
||
"",
|
||
"pm.test(\"Get private profile WITH permission (now Alice is a friend of Bob)\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/profiles/Bob\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" pm.expect(resp.login).to.be.eq(\"Bob\", \"Invalid login\");",
|
||
" pm.expect(resp.email).to.be.eq(\"Bobreg@yahoo.com\", \"Invalid email\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"name": "09/posts/publish",
|
||
"item": [
|
||
{
|
||
"name": "Register users",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const users = [",
|
||
" {",
|
||
" 'login': 'Harry',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Ron',",
|
||
" 'isPublic': false,",
|
||
" },",
|
||
"]",
|
||
"",
|
||
"users.forEach(function (userData) {",
|
||
" pm.test(`Register user \"${userData.login}\"`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': userData.login,",
|
||
" 'email': userData.login + 'reg@yahoo.com',",
|
||
" 'password': 'Strong0!',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': userData.isPublic,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [user ${userData.login}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(201, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"users = [",
|
||
" 'Harry',",
|
||
" 'Ron',",
|
||
"]",
|
||
"",
|
||
"users.forEach(function (user) {",
|
||
" pm.test(`Sign in as ${user}`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': user,",
|
||
" 'password': 'Strong0!',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" pm.globals.set(\"09_token_\" + user, resp.token);",
|
||
" console.log(\"Token has been saved\")",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Publish posts",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const posts = [",
|
||
" {",
|
||
" 'login': 'Harry',",
|
||
" 'content': 'Это мой первый пост!',",
|
||
" 'tags': ['первый', 'самара'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Harry',",
|
||
" 'content': 'А это второй!',",
|
||
" 'tags': ['новичок'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Harry',",
|
||
" 'content': 'Ребята, можете подсказать, теслу надо закупать или нет? Бум уже прошел?',",
|
||
" 'tags': ['moex', 'tesla', 'советы'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Harry',",
|
||
" 'content': 'ТЕСЛА ДАЛА +20% ЗА СУТКИ, А Я ТАК И НЕ КУПИЛ, ВОТ БЛИН!!!!',",
|
||
" 'tags': ['fail', 'tesla'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Ron',",
|
||
" 'content': 'Чтобы быть таким же успешным как я, надо каждый день покупать... Пост приватный!',",
|
||
" 'tags': ['private'],",
|
||
" },",
|
||
"];",
|
||
"",
|
||
"let promises = [];",
|
||
"let resolves = [];",
|
||
"for (var i = 0; i < posts.length; i++) {",
|
||
" promises.push(new Promise((resolve) => {",
|
||
" resolves.push(resolve);",
|
||
" }));",
|
||
"}",
|
||
"",
|
||
"function recPublish(idx) {",
|
||
" console.log(`Running iteration ${idx}`);",
|
||
"",
|
||
" if (idx >= posts.length) {",
|
||
" console.log(`Stop iterating`);",
|
||
" return;",
|
||
" }",
|
||
"",
|
||
" const post = posts[idx];",
|
||
" const token = pm.globals.get(`09_token_${post.login}`);",
|
||
"",
|
||
" pm.test(`Publish a post from \"${post.login}\" #${idx}`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/posts/new\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'content': post.content,",
|
||
" 'tags': post.tags,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [\"${post.login}\" #${idx}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" console.log('A new post has been published', resp);",
|
||
"",
|
||
" pm.expect(resp.content).to.be.eq(post.content, 'Invalid content');",
|
||
" pm.expect(resp.tags).to.have.lengthOf(post.tags.length, 'Invalid tags');",
|
||
" pm.expect(resp.author).to.be.eq(post.login, 'Invalid author');",
|
||
"",
|
||
" pm.globals.set(`09_post_id_${idx}`, resp.id);",
|
||
"",
|
||
" resolves[idx]();",
|
||
"",
|
||
" recPublish(idx + 1);",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"}",
|
||
"",
|
||
"recPublish(0);",
|
||
"",
|
||
"async function waitAll() {",
|
||
" const result = await Promise.all(promises);",
|
||
" console.log('Finish waiting');",
|
||
"}",
|
||
"waitAll();",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get public posts",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"var posts = [",
|
||
" {",
|
||
" 'id': pm.globals.get('09_post_id_0'),",
|
||
" 'content': 'Это мой первый пост!',",
|
||
" 'tags': ['первый', 'самара'],",
|
||
" },",
|
||
" {",
|
||
" 'id': pm.globals.get('09_post_id_1'),",
|
||
" 'content': 'А это второй!',",
|
||
" 'tags': ['новичок'],",
|
||
" },",
|
||
" {",
|
||
" 'id': pm.globals.get('09_post_id_2'),",
|
||
" 'content': 'Ребята, можете подсказать, теслу надо закупать или нет? Бум уже прошел?',",
|
||
" 'tags': ['moex', 'tesla', 'советы'],",
|
||
" },",
|
||
" {",
|
||
" 'id': pm.globals.get('09_post_id_3'),",
|
||
" 'content': 'ТЕСЛА ДАЛА +20% ЗА СУТКИ, А Я ТАК И НЕ КУПИЛ, ВОТ БЛИН!!!!',",
|
||
" 'tags': ['fail', 'tesla'],",
|
||
" },",
|
||
"];",
|
||
"",
|
||
"const users = [",
|
||
" 'Harry',",
|
||
" 'Ron',",
|
||
"]",
|
||
"",
|
||
"users.forEach(function (user) {",
|
||
" posts.forEach(function (post) {",
|
||
" const token = pm.globals.get(`09_token_${user}`);",
|
||
" ",
|
||
" pm.test(`Get public post by ID ${post.id} (on behalf of ${user})`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + `/posts/${post.id}`;",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [${post.id} (on behalf of ${user})]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" pm.expect(resp.content).to.be.eq(post.content, 'Invalid content');",
|
||
" pm.expect(resp.tags).to.have.lengthOf(post.tags.length, 'Invalid tags');",
|
||
" pm.expect(resp.author).to.be.eq('Harry', 'Invalid author');",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get a private post [failure]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(`09_token_Harry`);",
|
||
"const postId = pm.globals.get('09_post_id_4');",
|
||
"",
|
||
"pm.test(`Harry tries to fetch a Ron's post by ID ${postId} while they are not friends`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + `/posts/${postId}`;",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(404, \"Invalid response code status (openapi.yml line #594)\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Ron adds Harry to friends",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"09_token_Ron\");",
|
||
"",
|
||
"pm.test(\"Ron adds Harry to friends and opens his posts to a new friend\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/friends/add\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'Harry',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get a private post [success]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(`09_token_Harry`);",
|
||
"const postId = pm.globals.get('09_post_id_4');",
|
||
"",
|
||
"pm.test(`Harry tries to fetch a Ron's post by ID ${postId}, but they are friends now`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + `/posts/${postId}`;",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status (openapi.yml line #594)\");",
|
||
"",
|
||
" pm.expect(resp.author).to.be.eq('Ron', 'Invalid author');",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"name": "10/posts/feed",
|
||
"item": [
|
||
{
|
||
"name": "Register users",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const users = [",
|
||
" {",
|
||
" 'login': 'Diana',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'William',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Charles',",
|
||
" 'isPublic': false,",
|
||
" }",
|
||
"]",
|
||
"",
|
||
"users.forEach(function (userData) {",
|
||
" pm.test(`Register user \"${userData.login}\"`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': userData.login,",
|
||
" 'email': userData.login + 'reg@yahoo.com',",
|
||
" 'password': 'Strong0!',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': userData.isPublic,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [user ${userData.login}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(201, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"users = [",
|
||
" 'Diana',",
|
||
" 'William',",
|
||
" 'Charles',",
|
||
"]",
|
||
"",
|
||
"users.forEach(function (user) {",
|
||
" pm.test(`Sign in as ${user}`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': user,",
|
||
" 'password': 'Strong0!',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" pm.globals.set(\"10_token_\" + user, resp.token);",
|
||
" console.log(\"Token has been saved\")",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Publish posts",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const posts = [",
|
||
" {",
|
||
" 'login': 'Diana',",
|
||
" 'content': 'Это мой первый пост!',",
|
||
" 'tags': ['первый', 'самара'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Diana',",
|
||
" 'content': 'А это второй!',",
|
||
" 'tags': ['новичок'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Diana',",
|
||
" 'content': 'Ребята, можете подсказать, теслу надо закупать или нет? Бум уже прошел?',",
|
||
" 'tags': ['moex', 'tesla', 'советы'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Charles',",
|
||
" 'content': 'Пожалуй, останусь в тени, и доступа не будет даже у членов семьи!',",
|
||
" 'tags': ['royal'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Diana',",
|
||
" 'content': 'ТЕСЛА ДАЛА +20% ЗА СУТКИ, А Я ТАК И НЕ КУПИЛ, ВОТ БЛИН!!!!',",
|
||
" 'tags': ['fail', 'tesla'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Diana',",
|
||
" 'content': 'Чтобы быть таким же успешным как я, надо каждый день покупать... Пост приватный!',",
|
||
" 'tags': ['private'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Diana',",
|
||
" 'content': 'Покупайте акции английской королевской семьи!',",
|
||
" 'tags': ['royal'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'William',",
|
||
" 'content': 'У меня тоже есть фид!',",
|
||
" 'tags': ['royal'],",
|
||
" },",
|
||
" {",
|
||
" 'login': 'William',",
|
||
" 'content': 'И я тоже планирую в него что-то да постить!',",
|
||
" 'tags': ['royal'],",
|
||
" }",
|
||
"];",
|
||
"",
|
||
"let promises = [];",
|
||
"let resolves = [];",
|
||
"for (var i = 0; i < posts.length; i++) {",
|
||
" promises.push(new Promise((resolve) => {",
|
||
" resolves.push(resolve);",
|
||
" }));",
|
||
"}",
|
||
"",
|
||
"function recPublish(idx) {",
|
||
" if (idx >= posts.length) {",
|
||
" return;",
|
||
" }",
|
||
"",
|
||
" const post = posts[idx];",
|
||
" const token = pm.globals.get(`10_token_${post.login}`);",
|
||
"",
|
||
" pm.test(`Publish a post from \"${post.login}\" #${idx}`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/posts/new\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'content': post.content,",
|
||
" 'tags': post.tags,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [\"${post.login}\" #${idx}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" console.log('A new post has been published', resp);",
|
||
"",
|
||
" pm.expect(resp.content).to.be.eq(post.content, 'Invalid content');",
|
||
" pm.expect(resp.tags).to.have.lengthOf(post.tags.length, 'Invalid tags');",
|
||
" pm.expect(resp.author).to.be.eq(post.login, 'Invalid author');",
|
||
"",
|
||
" resolves[idx]();",
|
||
"",
|
||
" recPublish(idx + 1);",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"}",
|
||
"",
|
||
"recPublish(0);",
|
||
"",
|
||
"async function waitAll() {",
|
||
" const result = await Promise.all(promises);",
|
||
" console.log('Finish waiting');",
|
||
"}",
|
||
"waitAll();",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get Diana's feed with pagination",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const querystring = require('querystring');",
|
||
"",
|
||
"const expected = [",
|
||
" {",
|
||
" 'content': 'Покупайте акции английской королевской семьи!',",
|
||
" 'tags': ['royal'],",
|
||
" },",
|
||
" {",
|
||
" 'content': 'Чтобы быть таким же успешным как я, надо каждый день покупать... Пост приватный!',",
|
||
" 'tags': ['private'],",
|
||
" },",
|
||
" {",
|
||
" 'content': 'ТЕСЛА ДАЛА +20% ЗА СУТКИ, А Я ТАК И НЕ КУПИЛ, ВОТ БЛИН!!!!',",
|
||
" 'tags': ['fail', 'tesla'],",
|
||
" },",
|
||
" {",
|
||
" 'content': 'Ребята, можете подсказать, теслу надо закупать или нет? Бум уже прошел?',",
|
||
" 'tags': ['moex', 'tesla', 'советы'],",
|
||
" },",
|
||
" {",
|
||
" 'content': 'А это второй!',",
|
||
" 'tags': ['новичок'],",
|
||
" },",
|
||
" {",
|
||
" 'content': 'Это мой первый пост!',",
|
||
" 'tags': ['первый', 'самара'],",
|
||
" },",
|
||
"];",
|
||
"",
|
||
"const params = [",
|
||
" {",
|
||
" 'offset': 0,",
|
||
" 'limit': 3,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 3,",
|
||
" 'limit': 3,",
|
||
" },",
|
||
" {",
|
||
" 'offset': null,",
|
||
" 'limit': 10,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 1,",
|
||
" 'limit': 2,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 0,",
|
||
" 'limit': 4,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 4,",
|
||
" 'limit': 4,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 8,",
|
||
" 'limit': 4,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 3,",
|
||
" 'limit': null,",
|
||
" },",
|
||
" {",
|
||
" 'offset': null,",
|
||
" 'limit': null,",
|
||
" },",
|
||
" {",
|
||
" 'offset': 5,",
|
||
" 'limit': 1,",
|
||
" },",
|
||
"];",
|
||
"",
|
||
"const token = pm.globals.get(\"10_token_Charles\");",
|
||
"",
|
||
"params.forEach(function (page) {",
|
||
" pm.test(`Charles fetches Diana's feed [offset ${page.offset}, limit ${page.limit}]`, function () {",
|
||
" var data = {};",
|
||
" if (page.offset != null) {",
|
||
" data['offset'] = page.offset;",
|
||
" }",
|
||
" if (page.limit != null) {",
|
||
" data['limit'] = page.limit;",
|
||
" }",
|
||
" const query = querystring.stringify(data);",
|
||
"",
|
||
" var url = pm.variables.get(\"base_url\") + \"/posts/feed/Diana\";",
|
||
" if (query.length > 0) {",
|
||
" url += `?${query}`;",
|
||
" }",
|
||
"",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [offset ${page.offset}, limit ${page.limit}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" var offset = page.offset;",
|
||
" if (offset == null) {",
|
||
" offset = 0;",
|
||
" }",
|
||
"",
|
||
" var limit = page.limit;",
|
||
" if (limit == null) {",
|
||
" limit = 5;",
|
||
" }",
|
||
"",
|
||
" const start = Math.min(offset, expected.length);",
|
||
" const end = Math.min(offset + limit, expected.length);",
|
||
" pm.expect(resp).to.have.lengthOf(end - start, \"Invalid response array length\");",
|
||
"",
|
||
" for (var i = start; i < end; i++) {",
|
||
" const idx = i - start;",
|
||
"",
|
||
" pm.expect(resp[idx].author).to.be.eq('Diana', `Invalid author for post [#${idx}] ${resp[idx].id}`);",
|
||
" pm.expect(resp[idx].content).to.be.eq(expected[i].content, `Invalid content for post [#${idx}] ${resp[idx].id}`);",
|
||
" pm.expect(resp[idx].tags).to.have.lengthOf(expected[i].tags.length, `Invalid tags for post [#${idx}] ${resp[idx].id}`);",
|
||
" }",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "William gets his feed",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const querystring = require('querystring');",
|
||
"",
|
||
"const expected = [",
|
||
" {",
|
||
" 'content': 'И я тоже планирую в него что-то да постить!',",
|
||
" 'tags': ['royal'],",
|
||
" },",
|
||
" {",
|
||
" 'content': 'У меня тоже есть фид!',",
|
||
" 'tags': ['royal'],",
|
||
" }",
|
||
"];",
|
||
"",
|
||
"",
|
||
"const token = pm.globals.get(\"10_token_William\");",
|
||
"",
|
||
"pm.test(`William gets his feed`, function () {",
|
||
" const url = pm.variables.get(\"base_url\") + \"/posts/feed/my\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" pm.expect(resp).to.have.lengthOf(expected.length, \"Invalid response array length\");",
|
||
"",
|
||
" for (var i = 0; i < expected.length; i++) {",
|
||
" pm.expect(resp[i].author).to.be.eq('William', `Invalid author for post [#${i}] ${resp[i].id}`);",
|
||
" pm.expect(resp[i].content).to.be.eq(expected[i].content, `Invalid content for post [#${i}] ${resp[i].id}`);",
|
||
" pm.expect(resp[i].tags).to.have.lengthOf(expected[i].tags.length, `Invalid tags for post [#${i}] ${resp[i].id}`);",
|
||
" }",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get Charles' feed [failure]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"10_token_William\");",
|
||
"",
|
||
"pm.test(`William gets Charles' feed, but they are not friends`, function () {",
|
||
" const url = pm.variables.get(\"base_url\") + \"/posts/feed/Charles\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(404, \"Invalid response code status (openapi.yml line #668)\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Charles adds William to friends",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"10_token_Charles\");",
|
||
"",
|
||
"pm.test(\"Charles adds William to friends and opens his posts to a new friend\", function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/friends/add\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`,",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': 'William',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get Charles' feed [success]",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"10_token_William\");",
|
||
"",
|
||
"pm.test(`William gets Charles' feed, but THEY ARE FRIENDS now`, function () {",
|
||
" const url = pm.variables.get(\"base_url\") + \"/posts/feed/Charles\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status (openapi.yml line #668)\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"name": "11/posts/likes",
|
||
"item": [
|
||
{
|
||
"name": "Register users",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const users = [",
|
||
" {",
|
||
" 'login': 'Joey',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Peter',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user100',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user101',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user102',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user103',",
|
||
" 'isPublic': true,",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user104',",
|
||
" 'isPublic': true,",
|
||
" }",
|
||
"]",
|
||
"",
|
||
"users.forEach(function (userData) {",
|
||
" pm.test(`Register user \"${userData.login}\"`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/register\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': userData.login,",
|
||
" 'email': userData.login + 'reg@yahoo.com',",
|
||
" 'password': 'Strong0!',",
|
||
" 'countryCode': 'RU',",
|
||
" 'isPublic': userData.isPublic,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [user ${userData.login}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(201, \"Invalid response code status\");",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Sign in",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"users = [",
|
||
" 'Joey',",
|
||
" 'Peter',",
|
||
" 'user100',",
|
||
" `user101`,",
|
||
" `user102`,",
|
||
" `user103`,",
|
||
" `user104`",
|
||
"]",
|
||
"",
|
||
"users.forEach(function (user) {",
|
||
" pm.test(`Sign in as ${user}`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/auth/sign-in\";",
|
||
" var options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'login': user,",
|
||
" 'password': 'Strong0!',",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
" ",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(\"Validate sign-in response\", () => {",
|
||
" var resp = response.json();",
|
||
"",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" pm.globals.set(\"11_token_\" + user, resp.token);",
|
||
" console.log(\"Token has been saved\")",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Publish posts",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const posts = [",
|
||
" {",
|
||
" 'login': 'Joey',",
|
||
" 'content': 'Это мой первый пост! Накидайте реакций!',",
|
||
" 'tags': ['первый', 'казань'],",
|
||
" }",
|
||
"];",
|
||
"",
|
||
"let promises = [];",
|
||
"let resolves = [];",
|
||
"for (var i = 0; i < posts.length; i++) {",
|
||
" promises.push(new Promise((resolve) => {",
|
||
" resolves.push(resolve);",
|
||
" }));",
|
||
"}",
|
||
"",
|
||
"function recPublish(idx) {",
|
||
" if (idx >= posts.length) {",
|
||
" return;",
|
||
" }",
|
||
"",
|
||
" const post = posts[idx];",
|
||
" const token = pm.globals.get(`11_token_${post.login}`);",
|
||
"",
|
||
" pm.test(`Publish a post from \"${post.login}\" #${idx}`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + \"/posts/new\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" body: {",
|
||
" mode: 'raw',",
|
||
" raw: JSON.stringify({",
|
||
" 'content': post.content,",
|
||
" 'tags': post.tags,",
|
||
" })",
|
||
" }",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [\"${post.login}\" #${idx}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" console.log('A new post has been published', resp);",
|
||
"",
|
||
" pm.expect(resp.content).to.be.eq(post.content, 'Invalid content');",
|
||
" pm.expect(resp.tags).to.have.lengthOf(post.tags.length, 'Invalid tags');",
|
||
" pm.expect(resp.author).to.be.eq(post.login, 'Invalid author');",
|
||
"",
|
||
" pm.globals.set(`11_post_id_${idx}`, resp.id);",
|
||
"",
|
||
" resolves[idx]();",
|
||
"",
|
||
" recPublish(idx + 1);",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"}",
|
||
"",
|
||
"recPublish(0);",
|
||
"",
|
||
"async function waitAll() {",
|
||
" const result = await Promise.all(promises);",
|
||
" console.log('Finish waiting');",
|
||
"}",
|
||
"waitAll();",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Like / dislike",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const log = [",
|
||
" {",
|
||
" 'login': 'Joey',",
|
||
" 'action': 'like',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user100',",
|
||
" 'action': 'dislike',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user101',",
|
||
" 'action': 'like',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user101',",
|
||
" 'action': 'like',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user102',",
|
||
" 'action': 'dislike',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user104',",
|
||
" 'action': 'like',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Peter',",
|
||
" 'action': 'dislike',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user103',",
|
||
" 'action': 'like',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Peter',",
|
||
" 'action': 'like',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Joey',",
|
||
" 'action': 'like',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'Joey',",
|
||
" 'action': 'dislike',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user101',",
|
||
" 'action': 'like',",
|
||
" },",
|
||
" {",
|
||
" 'login': 'user102',",
|
||
" 'action': 'dislike',",
|
||
" },",
|
||
"];",
|
||
"",
|
||
"const postId = pm.globals.get(`11_post_id_0`);",
|
||
"var lastAction = new Map();",
|
||
"",
|
||
"let promises = [];",
|
||
"let resolves = [];",
|
||
"for (var i = 0; i < log.length; i++) {",
|
||
" promises.push(new Promise((resolve) => {",
|
||
" resolves.push(resolve);",
|
||
" }));",
|
||
"}",
|
||
"",
|
||
"function reproduceLog(idx) {",
|
||
" if (idx >= log.length) {",
|
||
" return;",
|
||
" }",
|
||
"",
|
||
" const op = log[idx];",
|
||
" const token = pm.globals.get(`11_token_${op.login}`);",
|
||
"",
|
||
" pm.test(`${op.login} ${op.action}s post with ID ${postId} [#${idx}]`, function () {",
|
||
" var url = pm.variables.get(\"base_url\") + `/posts/${postId}/` + op.action;",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'POST',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response [${op.login} ${op.action} #${idx}]`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" pm.expect(resp.content).to.be.eq('Это мой первый пост! Накидайте реакций!', 'Invalid content');",
|
||
" pm.expect(resp.author).to.be.eq('Joey', 'Invalid author');",
|
||
"",
|
||
" lastAction.set(op.login, op.action);",
|
||
" console.log('last actions', lastAction);",
|
||
"",
|
||
" let likes = 0;",
|
||
" let dislikes = 0;",
|
||
" for (let [key, value] of lastAction) {",
|
||
" if (value == 'like') {",
|
||
" likes++;",
|
||
" } else {",
|
||
" dislikes++;",
|
||
" }",
|
||
" }",
|
||
"",
|
||
" pm.expect(resp.likesCount).to.be.eq(likes, 'Invalid likes count');",
|
||
" pm.expect(resp.dislikesCount).to.be.eq(dislikes, 'Invalid dislikes count');",
|
||
"",
|
||
" resolves[idx]();",
|
||
"",
|
||
" reproduceLog(idx + 1);",
|
||
" });",
|
||
" });",
|
||
" });",
|
||
"}",
|
||
"",
|
||
"reproduceLog(0);",
|
||
"",
|
||
"async function waitAll() {",
|
||
" const result = await Promise.all(promises);",
|
||
" console.log('Finish waiting');",
|
||
"}",
|
||
"waitAll();",
|
||
"",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
},
|
||
{
|
||
"name": "Get feed and check counters",
|
||
"event": [
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"exec": [
|
||
"const token = pm.globals.get(\"11_token_Joey\");",
|
||
"",
|
||
"pm.test(`Joey gets his feed`, function () {",
|
||
" const url = pm.variables.get(\"base_url\") + \"/posts/feed/my\";",
|
||
" const options = {",
|
||
" url: url,",
|
||
" method: 'GET',",
|
||
" header: {",
|
||
" 'Content-Type': 'application/json',",
|
||
" 'Authorization': `Bearer ${token}`",
|
||
" },",
|
||
" };",
|
||
"",
|
||
" pm.sendRequest(options, function (err, response) {",
|
||
" pm.test(`Validate response`, () => {",
|
||
" var resp = response.json();",
|
||
" ",
|
||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||
"",
|
||
" pm.expect(resp).to.have.lengthOf(1, \"Invalid response array length\");",
|
||
"",
|
||
" pm.expect(resp[0].likesCount).to.be.eq(4, \"Invalid likes count\");",
|
||
" pm.expect(resp[0].dislikesCount).to.be.eq(3, \"Invalid dislikes count\");",
|
||
" });",
|
||
" });",
|
||
"});",
|
||
"",
|
||
"",
|
||
""
|
||
],
|
||
"type": "text/javascript"
|
||
}
|
||
}
|
||
],
|
||
"request": {
|
||
"method": "GET",
|
||
"header": [],
|
||
"url": {
|
||
"raw": "{{base_url}}/ping",
|
||
"host": [
|
||
"{{base_url}}"
|
||
],
|
||
"path": [
|
||
"ping"
|
||
]
|
||
}
|
||
},
|
||
"response": []
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"event": [
|
||
{
|
||
"listen": "prerequest",
|
||
"script": {
|
||
"type": "text/javascript",
|
||
"exec": [
|
||
""
|
||
]
|
||
}
|
||
},
|
||
{
|
||
"listen": "test",
|
||
"script": {
|
||
"type": "text/javascript",
|
||
"exec": [
|
||
""
|
||
]
|
||
}
|
||
}
|
||
],
|
||
"variable": [
|
||
{
|
||
"key": "base_url",
|
||
"value": "http://localhost:8080/api",
|
||
"type": "default"
|
||
}
|
||
]
|
||
} |