1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00
wakapi/testing/wakapi_api_tests.postman_collection.json

3470 lines
83 KiB
JSON
Raw Normal View History

{
"info": {
"_postman_id": "5c0749a5-6ddf-41ea-82f1-140578788bc3",
"name": "Wakapi API Tests",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Auth",
"item": [
{
"name": "Sign up user",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Body matches string\", function () {",
" pm.expect(pm.response.text()).to.include(\"Account created successfully\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "location",
"value": "{{TZ}}",
"type": "text"
},
{
"key": "username",
"value": "testuser",
"type": "text"
},
{
"key": "email",
"value": "testuser@wakapi.dev",
"type": "text"
},
{
"key": "password",
"value": "testpassword",
"type": "text"
},
{
"key": "password_repeat",
"value": "testpassword",
"type": "text"
}
]
},
"url": {
"raw": "{{BASE_URL}}/signup",
"host": [
"{{BASE_URL}}"
],
"path": [
"signup"
]
}
},
"response": []
},
{
"name": "Sign up existing user (conflict)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 409\", function () {",
" pm.response.to.have.status(409);",
"});",
"",
"pm.test(\"Body matches string\", function () {",
" pm.expect(pm.response.text()).to.include(\"User already existing\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "location",
"value": "{{TZ}}",
"type": "text"
},
{
"key": "username",
"value": "testuser",
"type": "text"
},
{
"key": "email",
"value": "testuser@wakapi.dev",
"type": "text"
},
{
"key": "password",
"value": "testpassword",
"type": "text"
},
{
"key": "password_repeat",
"value": "testpassword",
"type": "text"
}
]
},
"url": {
"raw": "{{BASE_URL}}/signup",
"host": [
"{{BASE_URL}}"
],
"path": [
"signup"
]
}
},
"response": []
},
{
"name": "Login",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 302\", function () {",
" pm.response.to.have.status(302);",
"});",
"",
"pm.test(\"Redirect to summary\", function () {",
" pm.expect(pm.response.headers.get(\"Location\")).to.eql(\"/summary\");",
"});",
"",
"pm.test(\"Sets cookie\", function () {",
" pm.expect(pm.response.headers.get(\"Set-Cookie\")).to.include(\"wakapi_auth=\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true,
"followRedirects": false
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "username",
"value": "testuser",
"type": "text"
},
{
"key": "password",
"value": "testpassword",
"type": "text"
}
]
},
"url": {
"raw": "{{BASE_URL}}/login",
"host": [
"{{BASE_URL}}"
],
"path": [
"login"
]
}
},
"response": []
},
{
"name": "Login (wrong password)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 401\", function () {",
" pm.response.to.have.status(401);",
"});",
"",
"pm.test(\"No redirect\", function () {",
" pm.response.to.not.have.header(\"Location\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true,
"followRedirects": false
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "username",
"value": "testuser",
"type": "text"
},
{
"key": "password",
"value": "wrongpassword",
"type": "text"
}
]
},
"url": {
"raw": "{{BASE_URL}}/login",
"host": [
"{{BASE_URL}}"
],
"path": [
"login"
]
}
},
"response": []
2021-10-11 12:29:38 +03:00
},
{
"name": "Authenticate (header)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true,
"followRedirects": false
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?interval=today",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "interval",
"value": "today"
}
]
}
},
"response": []
},
{
"name": "Authenticate (query param)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true,
"followRedirects": false
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?interval=today&api_key={{WRITEUSER_API_KEY}}",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "interval",
"value": "today"
},
{
"key": "api_key",
"value": "{{WRITEUSER_API_KEY}}"
}
]
}
},
"response": []
}
]
},
{
"name": "Heartbeats",
"item": [
{
"name": "Create heartbeats",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
"});",
"",
"pm.test(\"Response body is correct\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.responses.length).to.eql(2);",
" pm.expect(jsonData.responses[0].length).to.eql(2);",
" pm.expect(jsonData.responses[1].length).to.eql(2);",
" pm.expect(jsonData.responses[0][1]).to.eql(201);",
" pm.expect(jsonData.responses[1][1]).to.eql(201);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "[{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts1}}\n},\n{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts3}}\n}]",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BASE_URL}}/api/heartbeat",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"heartbeat"
]
}
},
"response": []
},
2021-06-11 18:41:55 +03:00
{
"name": "Create heartbeats (alt 1)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
2021-06-11 18:41:55 +03:00
"});",
"",
"pm.test(\"Response body is correct\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.responses.length).to.eql(2);",
" pm.expect(jsonData.responses[0].length).to.eql(2);",
" pm.expect(jsonData.responses[1].length).to.eql(2);",
" pm.expect(jsonData.responses[0][1]).to.eql(201);",
" pm.expect(jsonData.responses[1][1]).to.eql(201);",
"});"
2021-06-11 18:41:55 +03:00
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "[{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts1}}\n},\n{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts2}}\n}]",
2021-06-11 18:41:55 +03:00
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BASE_URL}}/api/v1/users/current/heartbeats.bulk",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"v1",
"users",
"current",
"heartbeats.bulk"
]
}
},
"response": []
},
{
"name": "Create heartbeats (alt 2)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
2021-06-11 18:41:55 +03:00
"});",
"",
"pm.test(\"Response body is correct\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.responses.length).to.eql(2);",
" pm.expect(jsonData.responses[0].length).to.eql(2);",
" pm.expect(jsonData.responses[1].length).to.eql(2);",
" pm.expect(jsonData.responses[0][1]).to.eql(201);",
" pm.expect(jsonData.responses[1][1]).to.eql(201);",
"});"
2021-06-11 18:41:55 +03:00
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "[{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts1}}\n},\n{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts2}}\n}]",
2021-06-11 18:41:55 +03:00
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current/heartbeats",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"current",
"heartbeats"
]
}
},
"response": []
},
{
"name": "Create heartbeats (alt 3)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
"});",
"",
"pm.test(\"Response body is correct\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.responses.length).to.eql(2);",
" pm.expect(jsonData.responses[0].length).to.eql(2);",
" pm.expect(jsonData.responses[1].length).to.eql(2);",
" pm.expect(jsonData.responses[0][1]).to.eql(201);",
" pm.expect(jsonData.responses[1][1]).to.eql(201);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "[{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts1}}\n},\n{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts2}}\n}]",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BASE_URL}}/api/users/current/heartbeats.bulk",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"users",
"current",
"heartbeats.bulk"
]
}
},
"response": []
},
{
"name": "Create heartbeats (alt 4, single)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
"});",
"",
"pm.test(\"Response body is correct\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.responses.length).to.eql(1);",
" pm.expect(jsonData.responses[0].length).to.eql(2);",
" pm.expect(jsonData.responses[0][1]).to.eql(201);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts1}}\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BASE_URL}}/api/heartbeat",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"heartbeat"
]
}
},
"response": []
},
{
"name": "Create heartbeats (alt 5, single)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
"});",
"",
"pm.test(\"Response body is correct\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.responses.length).to.eql(1);",
" pm.expect(jsonData.responses[0].length).to.eql(2);",
" pm.expect(jsonData.responses[0][1]).to.eql(201);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts1}}\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BASE_URL}}/api/v1/users/current/heartbeats",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"v1",
"users",
"current",
"heartbeats"
]
}
},
"response": []
},
{
"name": "Create heartbeats (alt 6, single)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
"});",
"",
"pm.test(\"Response body is correct\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.responses.length).to.eql(1);",
" pm.expect(jsonData.responses[0].length).to.eql(2);",
" pm.expect(jsonData.responses[0][1]).to.eql(201);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts1}}\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current/heartbeats",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"current",
"heartbeats"
]
}
},
"response": []
},
{
"name": "Create heartbeats (alt 7, single)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
"});",
"",
"pm.test(\"Response body is correct\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.responses.length).to.eql(1);",
" pm.expect(jsonData.responses[0].length).to.eql(2);",
" pm.expect(jsonData.responses[0][1]).to.eql(201);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts1}}\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BASE_URL}}/api/users/current/heartbeats",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"users",
"current",
"heartbeats"
]
}
},
"response": []
},
{
"name": "Create heartbeats (non-matching)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 404\", function () {",
" pm.response.to.have.status(404);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{ts1}}\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BASE_URL}}/api/v2/users/current/heartbeats",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"v2",
"users",
"current",
"heartbeats"
]
}
},
"response": []
},
{
"name": "Create heartbeats (unauthorized)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 401\", function () {",
" pm.response.to.have.status(401);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
2021-05-29 10:52:26 +03:00
"raw": "[{\n \"entity\": \"/home/user1/dev/proejct1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{tsNowMinus1Min}}\n}]",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BASE_URL}}/api/heartbeat",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"heartbeat"
]
}
},
"response": []
},
{
"name": "Create heartbeats (get heartbeats test)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
2022-07-02 01:28:56 +03:00
"raw": "[{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": 1640995200\n},\n{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": 1641074400\n},\n{\n \"entity\": \"/home/user1/dev/project1/main.go\",\n \"project\": \"wakapi\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": 1641081600\n}]",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BASE_URL}}/api/heartbeat",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"heartbeat"
]
}
},
"response": []
},
{
"name": "Get heartbeats",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Response body is correct\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.timezone).to.eql(pm.collectionVariables.get('TZ'));",
" var date = new Date(\"2022-01-01T00:00:00+0100\")",
" pm.expect(new Date(jsonData.start)).to.eql(date);",
" pm.expect(new Date(jsonData.end)).to.eql(new Date(date.getTime() + 3600 * 1000 * 24 - 1000));",
" pm.expect(jsonData.data.length).to.eql(2);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current/heartbeats?date=2022-01-01",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"current",
"heartbeats"
],
"query": [
{
"key": "date",
"value": "2022-01-01"
}
]
}
},
"response": []
}
]
},
{
"name": "Summary",
"item": [
{
"name": "Get summary (today)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const moment = require('moment')",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct user\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.user_id).to.eql(\"writeuser\");",
"});",
"",
"pm.test(\"Correct summary data\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.projects.length).to.eql(1);",
" pm.expect(jsonData.languages.length).to.eql(1);",
" pm.expect(jsonData.editors.length).to.eql(1);",
" pm.expect(jsonData.operating_systems.length).to.eql(1);",
" pm.expect(jsonData.machines.length).to.eql(1);",
" pm.expect(jsonData.branches).to.be.null;",
"});",
"",
"/*",
"// This is something the unit tests are supposed to check",
"pm.test(\"Correct summary range\", function () {",
" const jsonData = pm.response.json();",
" const from = moment(jsonData.from)",
" const to = moment(jsonData.to)",
"",
" pm.expect(moment.duration(moment().diff(from.add(2, 'm'))).asSeconds()).to.lt(10); // first heartbeat is now minus 1 min minus some latency",
" pm.expect(moment.duration(moment().diff(to.add(1, 'm'))).asSeconds()).to.lt(10); // first heartbeat is now minus 1 min minus some latency",
"});",
"*/"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?interval=today",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "interval",
"value": "today"
}
]
}
},
"response": []
},
{
"name": "Get summary (last 7 days)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const moment = require('moment')",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct user\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.user_id).to.eql(\"writeuser\");",
"});",
"",
"pm.test(\"Correct summary data\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.projects.length).to.eql(1);",
" pm.expect(jsonData.languages.length).to.eql(1);",
" pm.expect(jsonData.editors.length).to.eql(1);",
" pm.expect(jsonData.operating_systems.length).to.eql(1);",
" pm.expect(jsonData.machines.length).to.eql(1);",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?interval=last_7_days",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "interval",
"value": "last_7_days"
}
]
}
},
"response": []
},
{
"name": "Get summary (week)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const moment = require('moment')",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct user\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.user_id).to.eql(\"writeuser\");",
"});",
"",
"pm.test(\"Correct summary data\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.projects.length).to.eql(1);",
" pm.expect(jsonData.languages.length).to.eql(1);",
" pm.expect(jsonData.editors.length).to.eql(1);",
" pm.expect(jsonData.operating_systems.length).to.eql(1);",
" pm.expect(jsonData.machines.length).to.eql(1);",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?start=week",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "start",
"value": "week"
}
]
}
},
"response": []
},
{
"name": "Get summary (range)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const moment = require('moment')",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct user\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.user_id).to.eql(\"writeuser\");",
"});",
"",
"pm.test(\"Correct summary data\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.projects.length).to.eql(1);",
" pm.expect(jsonData.languages.length).to.eql(1);",
" pm.expect(jsonData.editors.length).to.eql(1);",
" pm.expect(jsonData.operating_systems.length).to.eql(1);",
" pm.expect(jsonData.machines.length).to.eql(1);",
"});",
"",
"pm.test(\"Correct dates\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(moment(jsonData.from).unix()).to.gte(moment(pm.variables.get('tsStartOfDayIso')).unix())",
" pm.expect(moment(jsonData.to).unix()).to.lte(moment(pm.variables.get('tsEndOfDayIso')).unix())",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?from={{tsStartOfDayIso}}&to={{tsEndOfDayIso}}",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "from",
"value": "{{tsStartOfDayIso}}"
},
{
"key": "to",
"value": "{{tsEndOfDayIso}}"
}
]
}
},
"response": []
},
{
"name": "Get summary (default tz)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const moment = require('moment')",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct time zone\", function () {",
" const jsonData = pm.response.json();",
" const targetDateTz = moment(`2021-05-28T00:00:00${pm.variables.get('TZ_OFFSET')}`)",
" pm.expect(moment(jsonData.from).isSame(targetDateTz)).to.eql(true)",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true,
"disableUrlEncoding": false
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?from=2021-05-28&to=2021-05-28",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "from",
"value": "2021-05-28"
},
{
"key": "to",
"value": "2021-05-28"
}
]
}
},
"response": []
},
{
"name": "Get summary (parse tz)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const moment = require('moment')",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct time zone\", function () {",
" const jsonData = pm.response.json();",
" // when it was midnight in UTC+3, it was still 11 pm in Germany",
" const targetDateTz = moment(`2021-05-28T00:00:00${pm.variables.get('TZ_OFFSET')}`).add(-1, 'h')",
" pm.expect(moment(jsonData.from).isSame(targetDateTz)).to.eql(true)",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?from=2021-05-28T00:00:00%2B03:00&to=2021-05-28T00:00:00%2B03:00",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "from",
"value": "2021-05-28T00:00:00%2B03:00"
},
{
"key": "to",
"value": "2021-05-28T00:00:00%2B03:00"
}
]
}
},
"response": []
2021-06-11 18:41:55 +03:00
},
{
"name": "Get summary (unauthenticated)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 401\", function () {",
" pm.response.to.have.status(401);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?interval=today",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "interval",
"value": "today"
}
]
}
},
"response": []
2021-12-26 20:56:53 +03:00
},
{
"name": "Get summary (today, filtered)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const moment = require('moment')",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct user\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.user_id).to.eql(\"writeuser\");",
"});",
"",
"pm.test(\"Correct summary data\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.projects.length).to.eql(1);",
" pm.expect(jsonData.languages.length).to.eql(1);",
" pm.expect(jsonData.editors.length).to.eql(1);",
" pm.expect(jsonData.operating_systems.length).to.eql(1);",
" pm.expect(jsonData.machines.length).to.eql(1);",
" pm.expect(jsonData.branches.length).to.eql(1);",
2021-12-26 20:56:53 +03:00
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?interval=today&project=wakapi&language=Go",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "interval",
"value": "today"
},
{
"key": "project",
"value": "wakapi"
},
{
"key": "language",
"value": "Go"
}
]
}
},
"response": []
},
{
"name": "Get summary (today, filtered non-matching)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const moment = require('moment')",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct user\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.user_id).to.eql(\"writeuser\");",
"});",
"",
"pm.test(\"Correct summary data\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.projects.length).to.eql(0);",
" pm.expect(jsonData.languages.length).to.eql(0);",
" pm.expect(jsonData.editors.length).to.eql(0);",
" pm.expect(jsonData.operating_systems.length).to.eql(0);",
" pm.expect(jsonData.machines.length).to.eql(0);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?interval=today&project=wakapi&language=JavaScript",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "interval",
"value": "today"
},
{
"key": "project",
"value": "wakapi"
},
{
"key": "language",
"value": "JavaScript"
}
]
}
},
"response": []
}
]
2021-05-29 10:52:26 +03:00
},
{
"name": "Metrics",
"item": [
{
"name": "Get admin metrics",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct Content-Type\", function () {",
" pm.expect(pm.response.headers.get(\"Content-Type\")).to.eql(\"text/plain; charset=utf-8\");",
"});",
"",
"pm.test(\"Body matches string\", function () {",
" pm.expect(pm.response.text()).to.include(\"wakatime_heartbeats_total\");",
" pm.expect(pm.response.text()).to.include(\"wakatime_admin_heartbeats_total\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{READUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/metrics",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"metrics"
]
}
},
"response": []
},
{
"name": "Get user metrics",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct Content-Type\", function () {",
" pm.expect(pm.response.headers.get(\"Content-Type\")).to.eql(\"text/plain; charset=utf-8\");",
"});",
"",
"pm.test(\"Body matches string\", function () {",
" pm.expect(pm.response.text()).to.include(\"wakatime_heartbeats_total\");",
" pm.expect(pm.response.text()).to.not.include(\"wakatime_admin_heartbeats_total\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/metrics",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"metrics"
]
}
},
"response": []
},
{
"name": "Get metrics (unauthorized)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 401\", function () {",
" pm.response.to.have.status(401);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/metrics",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"metrics"
]
}
},
"response": []
}
]
},
{
"name": "Shields",
"item": [
{
"name": "Get shields",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.message).to.eql('0 hrs 2 mins');",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
2021-06-11 18:41:55 +03:00
"type": "noauth"
2021-05-29 10:52:26 +03:00
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/shields/v1/writeuser/interval:last_7_days/project:wakapi",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"shields",
"v1",
"writeuser",
"interval:last_7_days",
"project:wakapi"
]
}
},
"response": []
},
{
"name": "Get shields (filter)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.message).to.eql('0 hrs 0 mins');",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
2021-06-11 18:41:55 +03:00
"type": "noauth"
2021-05-29 10:52:26 +03:00
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/shields/v1/writeuser/interval:last_7_days/project:nonexisting",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"shields",
"v1",
"writeuser",
"interval:last_7_days",
"project:nonexisting"
]
}
},
"response": []
},
{
"name": "Get shields (invalid range)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 403\", function () {",
" pm.response.to.have.status(403);",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
2021-06-11 18:41:55 +03:00
"type": "noauth"
2021-05-29 10:52:26 +03:00
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/shields/v1/writeuser/interval:last_30_days",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"shields",
"v1",
"writeuser",
"interval:last_30_days"
]
}
},
"response": []
},
{
"name": "Get shields (not sharing)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 403\", function () {",
" pm.response.to.have.status(403);",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
2021-06-11 18:41:55 +03:00
"raw": "{{BASE_URL}}/api/compat/shields/v1/readuser/interval:today",
2021-05-29 10:52:26 +03:00
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"shields",
"v1",
"readuser",
2021-06-11 18:41:55 +03:00
"interval:today"
]
}
},
"response": []
},
{
"name": "Get shields (non-shared entity type)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 403\", function () {",
" pm.response.to.have.status(403);",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/shields/v1/writeuser/interval:today/language:Go",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"shields",
"v1",
"writeuser",
"interval:today",
"language:Go"
2021-05-29 10:52:26 +03:00
]
}
},
"response": []
}
]
2021-06-11 18:41:55 +03:00
},
{
2021-06-11 18:41:55 +03:00
"name": "WakaTime",
"item": [
{
"name": "Get all time",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
2022-04-18 17:14:58 +03:00
" pm.expect(jsonData.data.text).to.eql('0 hrs 4 mins');",
2021-06-11 18:41:55 +03:00
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current/all_time_since_today",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"current",
"all_time_since_today"
]
}
},
"response": []
},
{
"name": "Get all time (unauthenticated)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 401\", function () {",
" pm.response.to.have.status(401);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/writeuser/all_time_since_today",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"writeuser",
"all_time_since_today"
]
}
},
"response": []
},
{
"name": "Get stats (current)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.data.languages).to.eql(null); // because share_languages is false",
" pm.expect(jsonData.data.projects.length).to.eql(1);",
" pm.expect(jsonData.data.branches).to.be.undefined;",
2021-06-11 18:41:55 +03:00
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current/stats",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"current",
"stats"
]
}
},
"response": []
},
2021-12-26 20:56:53 +03:00
{
"name": "Get stats (filtered)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.data.projects.length).to.eql(1);",
" pm.expect(jsonData.data.total_seconds).to.gt(0);",
" pm.expect(jsonData.data.branches.length).to.eql(1);",
2021-12-26 20:56:53 +03:00
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current/stats?project=wakapi&language=Go",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"current",
"stats"
],
"query": [
{
"key": "project",
"value": "wakapi"
},
{
"key": "language",
"value": "Go"
}
]
}
},
"response": []
},
{
"name": "Get stats (filtered non-matching)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.data.projects.length).to.eql(0);",
" pm.expect(jsonData.data.total_seconds).to.eql(0);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current/stats?project=wakapi&language=JavaScript",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"current",
"stats"
],
"query": [
{
"key": "project",
"value": "wakapi"
},
{
"key": "language",
"value": "JavaScript"
}
]
}
},
"response": []
},
2021-09-07 19:33:07 +03:00
{
2021-09-08 00:22:22 +03:00
"name": "Get statusbar (current)",
2021-09-07 19:33:07 +03:00
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.data.grand_total.text).to.contains(\"0 hrs\");",
" pm.expect(jsonData.data.categories).to.instanceOf(Array);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current/statusbar/today",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"current",
"statusbar",
"today"
]
}
},
"response": []
},
2021-06-11 18:41:55 +03:00
{
"name": "Get stats (by user)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.data.projects.length).to.eql(1);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/writeuser/stats",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"writeuser",
"stats"
]
}
},
"response": []
},
{
"name": "Get stats (current, alt 1)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.data.languages).to.eql(null); // because share_languages is false",
" pm.expect(jsonData.data.projects.length).to.eql(1);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/v1/users/current/stats/today",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"v1",
"users",
"current",
"stats",
"today"
]
}
},
"response": []
},
{
"name": "Get stats (range)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.data.projects.length).to.eql(1);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/writeuser/stats/last_7_days",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"writeuser",
"stats",
"last_7_days"
]
}
},
"response": []
},
{
"name": "Get stats (out of range)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 403\", function () {",
" pm.response.to.have.status(403);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/writeuser/stats/30_days",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"writeuser",
"stats",
"30_days"
]
}
},
"response": []
},
{
"name": "Get stats (not sharing)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 403\", function () {",
" pm.response.to.have.status(403);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/readuser/stats/today",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"readuser",
"stats",
"today"
]
}
},
"response": []
},
{
"name": "Get projects",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.data.length).to.eql(1);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current/projects",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"current",
"projects"
]
}
},
"response": []
},
{
"name": "Get projects (unauthenticated)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 401\", function () {",
" pm.response.to.have.status(401);",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/writeuser/projects",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"writeuser",
"projects"
]
}
},
"response": []
},
{
"name": "Get user (current)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct content\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.data.id).to.eql('writeuser');",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"current"
]
}
},
"response": []
},
{
"name": "Get user (forbidden user)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 401\", function () {",
" pm.response.to.have.status(401);",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/readuser",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"readuser"
]
}
},
"response": []
},
{
"name": "Get user (unauthenticated)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 401\", function () {",
" pm.response.to.have.status(401);",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": true
},
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/writeuser",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"writeuser"
]
}
},
"response": []
}
]
},
{
"name": "Settings",
"item": [
{
"name": "Use Case: Custom Mappings",
"item": [
{
"name": "1. Login",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Body contains string\", function () {",
2021-12-16 02:18:29 +03:00
" pm.expect(pm.response.text()).to.include(\"Total Time\");",
2021-06-11 18:41:55 +03:00
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": false,
"followRedirects": true
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "username",
"value": "writeuser",
"type": "text"
},
{
"key": "password",
"value": "{{WRITEUSER_PASSWORD}}",
"type": "text"
}
]
},
"url": {
"raw": "{{BASE_URL}}/login",
"host": [
"{{BASE_URL}}"
],
"path": [
"login"
]
}
},
"response": []
},
{
"name": "2. Add custom mapping",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Body contains string\", function () {",
" pm.expect(pm.response.text()).to.include(\"Mapping added successfully\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": false,
"followRedirects": true
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "action",
"value": "add_mapping",
"type": "text"
},
{
"key": "extension",
"value": "go",
"type": "text"
},
{
"key": "language",
"value": "Gogo",
"type": "text"
}
]
},
"url": {
"raw": "{{BASE_URL}}/settings",
"host": [
"{{BASE_URL}}"
],
"path": [
"settings"
]
}
},
"response": []
},
{
"name": "3. Check summary",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct language\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.languages.length).to.eql(1);",
" pm.expect(jsonData.languages[0].key).to.eql('Gogo');",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?interval=today",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "interval",
"value": "today"
}
]
}
},
"response": []
},
{
"name": "4. Remove custom mapping",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Body contains string\", function () {",
" pm.expect(pm.response.text()).to.include(\"Mapping deleted successfully\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": false,
"followRedirects": true
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "action",
"value": "delete_mapping",
"type": "text"
},
{
"key": "mapping_id",
"value": "0",
"type": "text"
}
]
},
"url": {
"raw": "{{BASE_URL}}/settings",
"host": [
"{{BASE_URL}}"
],
"path": [
"settings"
]
}
},
"response": []
},
{
"name": "5. Check summary again",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct language\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.languages.length).to.eql(1);",
" pm.expect(jsonData.languages[0].key).to.eql('Go');",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/summary?interval=today",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"summary"
],
"query": [
{
"key": "interval",
"value": "today"
}
]
}
},
"response": []
}
]
},
{
"name": "Use Case: Change E-Mail",
"item": [
{
"name": "1. Login",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Body contains string\", function () {",
2021-12-16 02:18:29 +03:00
" pm.expect(pm.response.text()).to.include(\"Total Time\");",
2021-06-11 18:41:55 +03:00
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": false,
"followRedirects": true
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "username",
"value": "writeuser",
"type": "text"
},
{
"key": "password",
"value": "{{WRITEUSER_PASSWORD}}",
"type": "text"
}
]
},
"url": {
"raw": "{{BASE_URL}}/login",
"host": [
"{{BASE_URL}}"
],
"path": [
"login"
]
}
},
"response": []
},
{
"name": "2. Set e-mail",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Body contains string\", function () {",
" pm.expect(pm.response.text()).to.include(\"User updated successfully\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableCookies": false,
"followRedirects": true
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "action",
"value": "update_user",
"type": "text"
},
{
"key": "location",
"value": "Europe/Berlin",
"type": "text"
},
{
"key": "email",
"value": "foo@example.org",
"type": "text"
}
]
},
"url": {
"raw": "{{BASE_URL}}/settings",
"host": [
"{{BASE_URL}}"
],
"path": [
"settings"
]
}
},
"response": []
},
{
"name": "3. Check e-mail",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Correct e-mail address\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData.data.email).to.eql('foo@example.org');",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"tlsPreferServerCiphers": true,
"disableCookies": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"wakatime",
"v1",
"users",
"current"
]
}
},
"response": []
}
]
}
]
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"const moment = require('moment')",
"",
"// pretend we're in Berlin, as this is also the time zone configured for the user",
"const userZone = 'Europe/Berlin'",
2021-06-11 18:41:55 +03:00
"",
"// postman doesn't have moment-timezone package included",
"// and we can't just use utcOffset(2), because of summer / winter time",
"// inspired by https://stackoverflow.com/a/56853085/3112139",
"function getUtcOffset(cb) {",
" let offset = pm.globals.get('utcOffset')",
" if (offset) return cb(offset)",
" pm.sendRequest(`https://worldtimeapi.org/api/timezone/${userZone}`, (err, res) => {",
" offset = res.json().utc_offset",
" pm.globals.set('utcOffset', offset)",
" return cb(offset)",
" })",
"}",
2021-06-11 18:41:55 +03:00
"",
"getUtcOffset((utcOffset) => {",
" const now = moment().utcOffset(utcOffset)",
2022-07-02 01:28:56 +03:00
" const startOfDay = now.clone().startOf('day')",
" const endOfDay = now.clone().endOf('day')",
" const endOfTomorrow = now.clone().add(1, 'd').endOf('day')",
2021-06-11 18:41:55 +03:00
"",
" // Auth stuff",
" const readApiKey = pm.variables.get('READUSER_API_KEY')",
" const writeApiKey = pm.variables.get('WRITEUSER_API_KEY')",
2021-06-11 18:41:55 +03:00
"",
" console.log(readApiKey)",
2021-06-11 18:41:55 +03:00
"",
" if (!readApiKey || !writeApiKey) {",
" throw new Error('no api key given')",
" }",
2021-06-11 18:41:55 +03:00
"",
" pm.variables.set('READUSER_TOKEN', base64encode(readApiKey))",
" pm.variables.set('WRITEUSER_TOKEN', base64encode(writeApiKey))",
"",
" function base64encode(str) {",
" return Buffer.from(str, 'utf-8').toString('base64')",
" }",
2021-06-11 18:41:55 +03:00
"",
" // Heartbeat stuff",
2022-07-02 01:28:56 +03:00
" pm.variables.set('tsNow', now.clone().format('x') / 1000)",
" pm.variables.set('tsNowMinus1Min', now.clone().add(-1, 'm').format('x') / 1000)",
" pm.variables.set('tsNowMinus2Min', now.clone().add(-2, 'm').format('x') / 1000)",
" pm.variables.set('tsNowMinus3Min', now.clone().add(-3, 'm').format('x') / 1000)",
" pm.variables.set('tsStartOfDay', startOfDay.format('x') / 1000)",
" pm.variables.set('tsEndOfDay', endOfDay.format('x') / 1000)",
" pm.variables.set('tsEndOfTomorrow', endOfTomorrow.format('x') / 1000)",
" pm.variables.set('tsStartOfDayIso', startOfDay.toISOString())",
" pm.variables.set('tsEndOfDayIso', endOfDay.toISOString())",
" pm.variables.set('tsEndOfTomorrowIso', endOfTomorrow.toISOString())",
2022-07-02 01:28:56 +03:00
" pm.variables.set('ts1', now.clone().startOf('hour').format('x') / 1000)",
" pm.variables.set('ts2', now.clone().startOf('hour').add(1, 'm').format('x') / 1000)",
" pm.variables.set('ts3', now.clone().startOf('hour').add(2, 'm').format('x') / 1000)",
"})"
2021-06-11 18:41:55 +03:00
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "BASE_URL",
"value": "http://localhost:3000"
},
{
"key": "READUSER_API_KEY",
"value": "33e7f538-0dce-4eba-8ffe-53db6814ed42"
},
{
"key": "WRITEUSER_API_KEY",
"value": "f7aa255c-8647-4d0b-b90f-621c58fd580f"
},
{
"key": "TZ",
"value": "Europe/Berlin"
},
{
"key": "TZ_OFFSET",
"value": "+02:00"
2021-06-11 18:41:55 +03:00
},
{
"key": "READUSER_PASSWORD",
"value": "testpw"
},
{
"key": "WRITEUSER_PASSWORD",
"value": "testpw"
}
]
}