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

Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ferdinand Mütsch 2021-06-10 23:22:58 +02:00
commit fb643571d2
3 changed files with 368 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"info": { "info": {
"_postman_id": "472dcea5-a8b1-4507-8480-61644295c35b", "_postman_id": "e7b925d5-501e-471c-abc7-eb29eec5279d",
"name": "Wakapi API Tests", "name": "Wakapi API Tests",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
}, },
@ -299,7 +299,7 @@
"header": [], "header": [],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "[{\n \"entity\": \"/home/user1/dev/proejct1/main.go\",\n \"project\": \"Project 1\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{tsNowMinus1Min}}\n},\n{\n \"entity\": \"/home/user1/dev/proejct1/main.go\",\n \"project\": \"Project 1\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{tsNowMinus2Min}}\n}]", "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},\n{\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\": {{tsNowMinus2Min}}\n}]",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"
@ -345,7 +345,7 @@
"header": [], "header": [],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "[{\n \"entity\": \"/home/user1/dev/proejct1/main.go\",\n \"project\": \"Project 1\",\n \"language\": \"Go\",\n \"is_write\": true,\n \"type\": \"file\",\n \"category\": null,\n \"branch\": null,\n \"time\": {{tsNowMinus1Min}}\n}]", "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": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"
@ -794,6 +794,358 @@
"response": [] "response": []
} }
] ]
},
{
"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": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"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": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"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": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{WRITEUSER_TOKEN}}",
"type": "string"
}
]
},
"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": {
"raw": "{{BASE_URL}}/api/compat/shields/v1/readuser/interval:week",
"host": [
"{{BASE_URL}}"
],
"path": [
"api",
"compat",
"shields",
"v1",
"readuser",
"interval:week"
]
}
},
"response": []
}
]
} }
], ],
"event": [ "event": [

View File

@ -35,7 +35,7 @@ security:
insecure_cookies: true insecure_cookies: true
cookie_max_age: 172800 cookie_max_age: 172800
allow_signup: true allow_signup: true
expose_metrics: false expose_metrics: true
sentry: sentry:
dsn: dsn:

View File

@ -1,4 +1,14 @@
BEGIN TRANSACTION; BEGIN TRANSACTION;
INSERT INTO "users" ("id","api_key","email","location","password","created_at","last_logged_in_at","share_data_max_days","share_editors","share_languages","share_projects","share_oss","share_machines","is_admin","has_data","wakatime_api_key","reset_token","reports_weekly") VALUES ('readuser','33e7f538-0dce-4eba-8ffe-53db6814ed42','','Europe/Berlin','$2a$10$RCyfAFdlZdFJVWbxKz4f2uJ/MospiE1EFAIjvRizC4Nop9GfjgKzW','2021-05-28 12:34:25','2021-05-28 14:34:34.178+02:00',0,0,0,0,0,0,0,0,'','',0); INSERT INTO "users" ("id", "api_key", "email", "location", "password", "created_at", "last_logged_in_at",
INSERT INTO "users" ("id","api_key","email","location","password","created_at","last_logged_in_at","share_data_max_days","share_editors","share_languages","share_projects","share_oss","share_machines","is_admin","has_data","wakatime_api_key","reset_token","reports_weekly") VALUES ('writeuser','f7aa255c-8647-4d0b-b90f-621c58fd580f','','Europe/Berlin','$2a$10$vsksPpiXZE9/xG9pRrZP.eKkbe/bGWW4wpPoXqvjiImZqMbN5c4Km','2021-05-28 12:34:56','2021-05-28 14:35:05.118+02:00',0,0,0,0,0,0,0,1,'','',0); "share_data_max_days", "share_editors", "share_languages", "share_projects", "share_oss",
"share_machines", "is_admin", "has_data", "wakatime_api_key", "reset_token", "reports_weekly")
VALUES ('readuser', '33e7f538-0dce-4eba-8ffe-53db6814ed42', '', 'Europe/Berlin',
'$2a$10$RCyfAFdlZdFJVWbxKz4f2uJ/MospiE1EFAIjvRizC4Nop9GfjgKzW', '2021-05-28 12:34:25',
'2021-05-28 14:34:34.178+02:00', 0, 0, 0, 0, 0, 0, 1, 0, '', '', 0);
INSERT INTO "users" ("id", "api_key", "email", "location", "password", "created_at", "last_logged_in_at",
"share_data_max_days", "share_editors", "share_languages", "share_projects", "share_oss",
"share_machines", "is_admin", "has_data", "wakatime_api_key", "reset_token", "reports_weekly")
VALUES ('writeuser', 'f7aa255c-8647-4d0b-b90f-621c58fd580f', '', 'Europe/Berlin',
'$2a$10$vsksPpiXZE9/xG9pRrZP.eKkbe/bGWW4wpPoXqvjiImZqMbN5c4Km', '2021-05-28 12:34:56',
'2021-05-28 14:35:05.118+02:00', 7, 0, 0, 1, 0, 0, 0, 1, '', '', 0);
COMMIT; COMMIT;