Updated countries list, uploaded private tests, removed github CI/CD
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
name: Run tests
|
||||
|
||||
on: deployment
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: cu-backend
|
||||
timeout-minutes: 10
|
||||
if: github.actor != 'github-classroom[bot]'
|
||||
container:
|
||||
image: gcr.io/kaniko-project/executor:debug
|
||||
steps:
|
||||
- name: Login to ghcr.io
|
||||
run: >
|
||||
echo "{\"auths\": {\"ghcr.io\": {\"auth\": \"$(echo -n "$AUTH" | base64 -w 0)\"}}}"
|
||||
> /kaniko/.docker/config.json
|
||||
env:
|
||||
AUTH: "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
- name: Build solution image
|
||||
run: >
|
||||
/kaniko/executor
|
||||
--context="${{ github.repositoryUrl }}#refs/heads/main#${{ github.sha }}"
|
||||
--context-sub-path=solution
|
||||
--destination="$(echo -n "$REPO:run-${{ github.run_id }}" | tr '[:upper:]' '[:lower:]')"
|
||||
--destination="$(echo -n "$REPO:latest" | tr '[:upper:]' '[:lower:]')"
|
||||
--label org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
||||
env:
|
||||
GIT_USERNAME: kaniko
|
||||
GIT_PASSWORD: "${{ secrets.GITHUB_TOKEN }}"
|
||||
REPO: "ghcr.io/${{ github.repository }}"
|
||||
|
||||
tests:
|
||||
name: Tests
|
||||
runs-on: ubuntu-22.04
|
||||
needs: build
|
||||
timeout-minutes: 10
|
||||
if: github.actor != 'github-classroom[bot]'
|
||||
steps:
|
||||
- uses: Central-University-IT/setup-test-backend@v1
|
||||
|
||||
- uses: docker/login-action@v3.0.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- run: >
|
||||
IMAGE_SOLUTION="$(echo "ghcr.io/${{ github.repository }}:run-${{ github.run_id }}" | tr '[:upper:]' '[:lower:]')"
|
||||
IMAGE_POSTGRES="$(echo "ghcr.io/${{ github.repository_owner }}/postgres:16.1-alpine3.19" | tr '[:upper:]' '[:lower:]')"
|
||||
/usr/local/bin/checker
|
||||
continue-on-error: true
|
||||
|
||||
- uses: actions/upload-artifact@v4.0.0
|
||||
with:
|
||||
name: result
|
||||
path: ./result.json
|
||||
if-no-files-found: error
|
||||
compression-level: 0
|
||||
|
||||
- uses: bots-house/ghcr-delete-image-action@v1.1.0
|
||||
continue-on-error: true
|
||||
with:
|
||||
owner: ${{ github.repository_owner }}
|
||||
name: ${{ github.event.repository.name }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: run-${{ github.run_id }}
|
||||
@@ -21,7 +21,6 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-E
|
||||
('Andorra','AD','AND','Europe'),
|
||||
('Angola','AO','AGO','Africa'),
|
||||
('Anguilla','AI','AIA','Americas'),
|
||||
('Antarctica','AQ','ATA',''),
|
||||
('Antigua and Barbuda','AG','ATG','Americas'),
|
||||
('Argentina','AR','ARG','Americas'),
|
||||
('Armenia','AM','ARM','Asia'),
|
||||
@@ -67,7 +66,6 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-E
|
||||
('Congo, Democratic Republic of the','CD','COD','Africa'),
|
||||
('Cook Islands','CK','COK','Oceania'),
|
||||
('Costa Rica','CR','CRI','Americas'),
|
||||
('Côte d Ivoire','CI','CIV','Africa'),
|
||||
('Croatia','HR','HRV','Europe'),
|
||||
('Cuba','CU','CUB','Americas'),
|
||||
('Curaçao','CW','CUW','Americas'),
|
||||
@@ -131,11 +129,9 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-E
|
||||
('Kazakhstan','KZ','KAZ','Asia'),
|
||||
('Kenya','KE','KEN','Africa'),
|
||||
('Kiribati','KI','KIR','Oceania'),
|
||||
('Korea (Democratic People s Republic of)','KP','PRK','Asia'),
|
||||
('Korea, Republic of','KR','KOR','Asia'),
|
||||
('Kuwait','KW','KWT','Asia'),
|
||||
('Kyrgyzstan','KG','KGZ','Asia'),
|
||||
('Lao People s Democratic Republic','LA','LAO','Asia'),
|
||||
('Latvia','LV','LVA','Europe'),
|
||||
('Lebanon','LB','LBN','Asia'),
|
||||
('Lesotho','LS','LSO','Africa'),
|
||||
@@ -261,5 +257,6 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-E
|
||||
('Western Sahara','EH','ESH','Africa'),
|
||||
('Yemen','YE','YEM','Asia'),
|
||||
('Zambia','ZM','ZMB','Africa'),
|
||||
('Zimbabwe','ZW','ZWE','Africa');
|
||||
('Zimbabwe','ZW','ZWE','Africa'),
|
||||
('Byteland PROD','YY','YYY','Europe');
|
||||
EOSQL
|
||||
@@ -1,889 +0,0 @@
|
||||
{
|
||||
"info": {
|
||||
"_postman_id": "a5dbb75a-d7a8-4e8c-8660-9925345a3a86",
|
||||
"name": "PROD round 2: public tests [1]",
|
||||
"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 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#\"",
|
||||
"};",
|
||||
"",
|
||||
"var countries = [",
|
||||
" {",
|
||||
" \"name\": \"Algeria\",",
|
||||
" \"alpha2\": \"DZ\",",
|
||||
" \"alpha3\": \"DZA\",",
|
||||
" \"region\": \"Africa\"",
|
||||
" },",
|
||||
" {",
|
||||
" \"name\": \"Russian Federation\",",
|
||||
" \"alpha2\": \"RU\",",
|
||||
" \"alpha3\": \"RUS\",",
|
||||
" \"region\": \"Europe\"",
|
||||
" },",
|
||||
"];",
|
||||
"",
|
||||
"countries.forEach(function (country) {",
|
||||
" pm.test(`List countries from region \"${country.region}\"`, function () {",
|
||||
" var url = pm.variables.get(\"base_url\") + `/countries?region=${country.region}`;",
|
||||
"",
|
||||
" pm.sendRequest(url, function (err, response) {",
|
||||
" pm.test(`Validate response for region ${country.region}`, () => {",
|
||||
" 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(\"got\", resp);",
|
||||
" pm.expect(resp).to.deep.include(country, `Invalid countries list`);",
|
||||
" });",
|
||||
" });",
|
||||
" });",
|
||||
"});",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/countries",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"countries"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Get country",
|
||||
"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#\"",
|
||||
"};",
|
||||
"",
|
||||
"var countries = [",
|
||||
" {",
|
||||
" \"name\": \"Algeria\",",
|
||||
" \"alpha2\": \"DZ\",",
|
||||
" \"alpha3\": \"DZA\",",
|
||||
" \"region\": \"Africa\"",
|
||||
" },",
|
||||
" {",
|
||||
" \"name\": \"Russian Federation\",",
|
||||
" \"alpha2\": \"RU\",",
|
||||
" \"alpha3\": \"RUS\",",
|
||||
" \"region\": \"Europe\"",
|
||||
" },",
|
||||
" {",
|
||||
" \"name\": \"Kazakhstan\",",
|
||||
" \"alpha2\": \"KZ\",",
|
||||
" \"alpha3\": \"KAZ\",",
|
||||
" \"region\": \"Asia\"",
|
||||
" }",
|
||||
"];",
|
||||
"",
|
||||
"countries.forEach(function (country) {",
|
||||
" pm.test(`Get country \"${country.name}\" [existing]`, function () {",
|
||||
" var url = pm.variables.get(\"base_url\") + \"/countries/\" + country.alpha2;",
|
||||
"",
|
||||
" 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;",
|
||||
"",
|
||||
" console.log(\"got\", resp, \"expected\", country);",
|
||||
" pm.expect(resp).to.deep.eq(country, `Got invalid object`);",
|
||||
" });",
|
||||
" });",
|
||||
" });",
|
||||
"});",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/countries/RU",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"countries",
|
||||
"RU"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "03/auth/registration",
|
||||
"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': '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": "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': '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.oneOf([201, 409], \"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": "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': 'yellowMonkey2',",
|
||||
" 'password': '$aba4821FWfew01#.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;",
|
||||
"",
|
||||
" console.log('Token', resp.token);",
|
||||
" });",
|
||||
" });",
|
||||
"});",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"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': 'yellowMonkey10000',",
|
||||
" 'email': 'yellowstone1980@you.ru',",
|
||||
" 'password': '$aba4821FWfew01#.fewA$',",
|
||||
" 'countryCode': 'RU',",
|
||||
" 'isPublic': true,",
|
||||
" 'phone': '+74951239922',",
|
||||
" })",
|
||||
" }",
|
||||
" };",
|
||||
"",
|
||||
" const profile = {",
|
||||
" 'profile': {",
|
||||
" 'login': 'yellowMonkey10000',",
|
||||
" '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.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': 'yellowMonkey10000',",
|
||||
" 'password': '$aba4821FWfew01#.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.environment.set(\"05_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 my profile",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"pm.test(\"Get profile\", function () {",
|
||||
" const url = pm.variables.get(\"base_url\") + \"/me/profile\";",
|
||||
" const token = pm.environment.get(\"05_profile_token\");",
|
||||
" 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();",
|
||||
"",
|
||||
" pm.expect(response.code).to.be.eq(200, \"Invalid response code status\");",
|
||||
"",
|
||||
" console.log(\"Got profile\", resp);",
|
||||
" pm.expect(resp.login).to.be.eq(\"yellowMonkey10000\", \"Invalid login\");",
|
||||
" });",
|
||||
" });",
|
||||
"});",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"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:57424/api",
|
||||
"type": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
+5519
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user