Перейти к содержимому

JuniorQaEngineer

Регистрация: 14 мая 2019
Offline Активность: 23 мар 2020 21:14
*----

Мои темы

Как в postman передать путь к загружаемому файлу?

01 февраля 2020 - 09:58

Всем привет

Имеется форма, которая может принимать определенный размер и тип файлов, в сумме около 80 загрузок разных файлов. Перед загрузкой (PUT) каждого файла нужно выполнить 4 запроса, т.ч для загрузки  каждого файла требуется прогнать 5 запросов.  

Насколько я знаю, имеется три способа загрузки файла через postman, это: form-data, binary и CSV с переменными. Хотелось бы обойтись без CSV.

Есть ли в Postman возможность, в Form-data, указывать путь к файлу? Чтобы наименование файла завести в переменную и несколькими итерациями прогнать все 50 файлов?

Хочу получить что-то, типа:

xdsd.png

Возможности использовать newman - нет :)

Заранее спасибо 

 


Postman "Schema Valid" как проверить Response с документацией

21 декабря 2019 - 16:18

Всем привет  :victory:

Пытаюсь сравнить структуру ответа в postman с документацией (нужно проверить тип полей)

В ответ приходит сообщение, которое может иметь 0 или несколько файлов и квитанций структура у всех прикрепленных файлов или квитанций одинаковая, но их количество постоянно меняется, т.к. сообщение приходит рандомное.

Пример Response:

            "Message": null,
            "Files": []
        },
        {
            "Id": "string",
            "ReceiveTime": "string",
            "StatusTime": "string",
            "Status": "error",
            "Message": "string",
            "Files": [
                {
                    "Id": "string",
                    "Name": "string",
                    "Description": null,
                    "Size": "integer",
                    "RepositoryInfo": [
                        {
                            "Path": "string",
                            "Host": "string",
                            "Port": "integer",
                            "RepositoryType": "string"
                        }
                    ]
                },
                {
                    "Id": "string",
                    "Name": "string",
                    "Description": null,
                    "Size": "integer",
                    "RepositoryInfo": [
                        {
                            "Path": "string",
                            "Host": "string",
                            "Port": "integer",
                            "RepositoryType": "string"
                        }
                    ]
                },
                {
                    "Id": "string",
                    "Name": "string",
                    "Description": null,
                    "Size": "integer",
                    "RepositoryInfo": [
                        {
                            "Path": "string",
                            "Host": "string",
                            "Port": "integer",
                            "RepositoryType": "string"
                        }
                    ]
                },
                {
                    "Id": "string",
                    "Name": "string",
                    "Description": null,
                    "Size": "integer",
                    "RepositoryInfo": [
                        {
                            "Path": "string",
                            "Host": "string",
                            "Port": "integer",
                            "RepositoryType": "string"
                        }
                    ]
                }
            ]
        }
    ]
}

Через это https://www.jsonschema.net/  я преобразую , во что, сам не знаю, но так работает ))))), и после кидаю схему в postman test:

var schema = {
  "definitions": {},
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://example.com/root.json",
  "type": "object",
  "title": "The Root Schema",
  "required": [
    "Id",
    "CorrelationId",
    "GroupId",
    "Type",
    "Title",
    "Text",
    "CreationDate",
    "UpdatedDate",
    "Status",
    "TaskName",
    "RegNumber",
    "TotalSize",
    "Sender",
    "Files",
    "Receipts"
  ],
  "properties": {
    "Id": {
      "$id": "#/properties/Id",
      "type": "string",
      "title": "The Id Schema",
      "default": "",
      "examples": [
        "string"
      ],
      "pattern": "^(.*)$"
    },
    "CorrelationId": {
      "$id": "#/properties/CorrelationId",
      "type": "null",
      "title": "The Correlationid Schema",
      "default": null,
      "examples": [
        null
      ]
    },
    "GroupId": {
      "$id": "#/properties/GroupId",
      "type": "null",
      "title": "The Groupid Schema",
      "default": null,
      "examples": [
        null
      ]
    },
    "Type": {
      "$id": "#/properties/Type",
      "type": "string",
      "title": "The Type Schema",
      "default": "",
      "examples": [
        "outbox"
      ],
      "pattern": "^(.*)$"
    },
    "Title": {
      "$id": "#/properties/Title",
      "type": "string",
      "title": "The Title Schema",
      "default": "",
      "examples": [
        "string"
      ],
      "pattern": "^(.*)$"
    },
    "Text": {
      "$id": "#/properties/Text",
      "type": "string",
      "title": "The Text Schema",
      "default": "",
      "examples": [
        "string"
      ],
      "pattern": "^(.*)$"
    },
    "CreationDate": {
      "$id": "#/properties/CreationDate",
      "type": "string",
      "title": "The Creationdate Schema",
      "default": "",
      "examples": [
        "string"
      ],
      "pattern": "^(.*)$"
    },
    "UpdatedDate": {
      "$id": "#/properties/UpdatedDate",
      "type": "string",
      "title": "The Updateddate Schema",
      "default": "",
      "examples": [
        "string"
      ],
      "pattern": "^(.*)$"
    },
    "Status": {
      "$id": "#/properties/Status",
      "type": "string",
      "title": "The Status Schema",
      "default": "",
      "examples": [
        "error"
      ],
      "pattern": "^(.*)$"
    },
    "TaskName": {
      "$id": "#/properties/TaskName",
      "type": "string",
      "title": "The Taskname Schema",
      "default": "",
      "examples": [
        "string"
      ],
      "pattern": "^(.*)$"
    },
    "RegNumber": {
      "$id": "#/properties/RegNumber",
      "type": "null",
      "title": "The Regnumber Schema",
      "default": null,
      "examples": [
        null
      ]
    },
    "TotalSize": {
      "$id": "#/properties/TotalSize",
      "type": "string",
      "title": "The Totalsize Schema",
      "default": "",
      "examples": [
        "integer"
      ],
      "pattern": "^(.*)$"
    },
    "Sender": {
      "$id": "#/properties/Sender",
      "type": "object",
      "title": "The Sender Schema",
      "required": [
        "Inn",
        "Ogrn",
        "Bik",
        "RegNum",
        "DivisionCode"
      ],
      "properties": {
        "Inn": {
          "$id": "#/properties/Sender/properties/Inn",
          "type": "string",
          "title": "The Inn Schema",
          "default": "",
          "examples": [
            "integer"
          ],
          "pattern": "^(.*)$"
        },
        "Ogrn": {
          "$id": "#/properties/Sender/properties/Ogrn",
          "type": "null",
          "title": "The Ogrn Schema",
          "default": null,
          "examples": [
            null
          ]
        },
        "Bik": {
          "$id": "#/properties/Sender/properties/Bik",
          "type": "null",
          "title": "The Bik Schema",
          "default": null,
          "examples": [
            null
          ]
        },
        "RegNum": {
          "$id": "#/properties/Sender/properties/RegNum",
          "type": "null",
          "title": "The Regnum Schema",
          "default": null,
          "examples": [
            null
          ]
        },
        "DivisionCode": {
          "$id": "#/properties/Sender/properties/DivisionCode",
          "type": "null",
          "title": "The Divisioncode Schema",
          "default": null,
          "examples": [
            null
          ]
        }
      }
    },
    "Files": {
      "$id": "#/properties/Files",
      "type": "array",
      "title": "The Files Schema",
      "items": {
        "$id": "#/properties/Files/items",
        "type": "object",
        "title": "The Items Schema",
        "required": [
          "Id",
          "Name",
          "Description",
          "Encrypted",
          "SignedFile",
          "Size",
          "RepositoryInfo"
        ],
        "properties": {
          "Id": {
            "$id": "#/properties/Files/items/properties/Id",
            "type": "string",
            "title": "The Id Schema",
            "default": "",
            "examples": [
              "string"
            ],
            "pattern": "^(.*)$"
          },
          "Name": {
            "$id": "#/properties/Files/items/properties/Name",
            "type": "string",
            "title": "The Name Schema",
            "default": "",
            "examples": [
              "string"
            ],
            "pattern": "^(.*)$"
          },
          "Description": {
            "$id": "#/properties/Files/items/properties/Description",
            "type": "null",
            "title": "The Description Schema",
            "default": null,
            "examples": [
              null
            ]
          },
          "Encrypted": {
            "$id": "#/properties/Files/items/properties/Encrypted",
            "type": "boolean",
            "title": "The Encrypted Schema",
            "default": false,
            "examples": [
              true
            ]
          },
          "SignedFile": {
            "$id": "#/properties/Files/items/properties/SignedFile",
            "type": "null",
            "title": "The Signedfile Schema",
            "default": null,
            "examples": [
              null
            ]
          },
          "Size": {
            "$id": "#/properties/Files/items/properties/Size",
            "type": "string",
            "title": "The Size Schema",
            "default": "",
            "examples": [
              "integer"
            ],
            "pattern": "^(.*)$"
          },
          "RepositoryInfo": {
            "$id": "#/properties/Files/items/properties/RepositoryInfo",
            "type": "array",
            "title": "The Repositoryinfo Schema",
            "items": {
              "$id": "#/properties/Files/items/properties/RepositoryInfo/items",
              "type": "object",
              "title": "The Items Schema",
              "required": [
                "Path",
                "Host",
                "Port",
                "RepositoryType"
              ],
              "properties": {
                "Path": {
                  "$id": "#/properties/Files/items/properties/RepositoryInfo/items/properties/Path",
                  "type": "string",
                  "title": "The Path Schema",
                  "default": "",
                  "examples": [
                    "string"
                  ],
                  "pattern": "^(.*)$"
                },
                "Host": {
                  "$id": "#/properties/Files/items/properties/RepositoryInfo/items/properties/Host",
                  "type": "string",
                  "title": "The Host Schema",
                  "default": "",
                  "examples": [
                    "string"
                  ],
                  "pattern": "^(.*)$"
                },
                "Port": {
                  "$id": "#/properties/Files/items/properties/RepositoryInfo/items/properties/Port",
                  "type": "string",
                  "title": "The Port Schema",
                  "default": "",
                  "examples": [
                    "integer"
                  ],
                  "pattern": "^(.*)$"
                },
                "RepositoryType": {
                  "$id": "#/properties/Files/items/properties/RepositoryInfo/items/properties/RepositoryType",
                  "type": "string",
                  "title": "The Repositorytype Schema",
                  "default": "",
                  "examples": [
                    "string"
                  ],
                  "pattern": "^(.*)$"
                }
              }
            }
          }
        }
      }
    },
    "Receipts": {
      "$id": "#/properties/Receipts",
      "type": "array",
      "title": "The Receipts Schema",
      "items": {
        "$id": "#/properties/Receipts/items",
        "type": "object",
        "title": "The Items Schema",
        "required": [
          "Id",
          "ReceiveTime",
          "StatusTime",
          "Status",
          "Message",
          "Files"
        ],
        "properties": {
          "Id": {
            "$id": "#/properties/Receipts/items/properties/Id",
            "type": "string",
            "title": "The Id Schema",
            "default": "",
            "examples": [
              "string"
            ],
            "pattern": "^(.*)$"
          },
          "ReceiveTime": {
            "$id": "#/properties/Receipts/items/properties/ReceiveTime",
            "type": "string",
            "title": "The Receivetime Schema",
            "default": "",
            "examples": [
              "string"
            ],
            "pattern": "^(.*)$"
          },
          "StatusTime": {
            "$id": "#/properties/Receipts/items/properties/StatusTime",
            "type": "string",
            "title": "The Statustime Schema",
            "default": "",
            "examples": [
              "string"
            ],
            "pattern": "^(.*)$"
          },
          "Status": {
            "$id": "#/properties/Receipts/items/properties/Status",
            "type": "string",
            "title": "The Status Schema",
            "default": "",
            "examples": [
              "string"
            ],
            "pattern": "^(.*)$"
          },
          "Message": {
            "$id": "#/properties/Receipts/items/properties/Message",
            "type": "null",
            "title": "The Message Schema",
            "default": null,
            "examples": [
              null
            ]
          },
          "Files": {
            "$id": "#/properties/Receipts/items/properties/Files",
            "type": "array",
            "title": "The Files Schema"
          }
        }
      }
    }
  }
}
pm.test('Shema Valid', () => {
    var carrier = JSON.parse(responseBody); 
    pm.expect(tv4.validate(carrier, schema)).to.be.true
}) 

В схеме большинство полей удаляю, оставляю только поле type, пример:

"Message": {
   "type": "null",
  }

Теперь вопросы:

1) Есть ли способ проще в написании чем выбрал я c написанием этой схемы(https://www.jsonschema.net/)? 

2) Как сделать проверку файлов, квитанций, если их будет 10-20шт, не дублируя их? через цикл? а эта схема(https://www.jsonschema.net/), на сколько я понимаю не съест цикл javascript-a 

2) Правильную ли я выбрал форму проверки в postman-e?

3) Если поля обязательные или необязательные, как это прописать в тесте(pm.expect(tv4.validate(carrier, shema)).to.be.true)?

4) Если  сообщении присутствует файл и отсутствует квитанция, как это протестировать?) (Пометить массив квитанций как необязательный?)

Уф, надеюсь более менее понятно написал )))

Заранее спасибо )


Не получается выполнить запрос к API ВКонтакте в Postman

16 мая 2019 - 09:12

Здравствуйте, выполняю тестовое задание, нужно автоматизировать в Postman любой открытый api перепробовал уже несколько сайтов, youtube, worldweatheronline.com, везде итог одинаковый, самый простой запрос, который написан в документации в примере, проходит, работает, как только пытаюсь составить какой-нибудь свой из списка представленных методов на этом сайте, получаю ответ типа авторизация не проходит или как с примером vk (запрос не моет быть выполнен)
 

До этого с API дел никогда не имел, копаюсь 2-ой день.
 

Сейчас экспериментирую с vk.com, думал, что с документацией на русском станет все понятно, а итог тот же ))

Синтаксис запроса: https://vk.com/dev.p...od=api_requests  
если делать по примеру по ссылке, то все получается:

 

444.png

 

Но если беру другой метод, к примеру search.getHints

получается такой результат:

 

5555.png

 

 

 

сам запрос: https://api.vk.com/m...etHints?v=5.52{{token}}&item_id=544801554_1&q=Запрос&offset=5&limit=10&filters=correspondents&search_global=0

 

Токен у меня с доступом пользователя, получал через Standalone приложение по этому видео

 

Такая же история с YouTube - ом, но там несколько простых запросов проходит два или три, а с остальными тоже пишет, что не авторизовался.