Files
VLoop/test/postman.json

488 lines
17 KiB
JSON
Raw Normal View History

2025-12-16 18:45:52 +08:00
{
"info": {
"name": "FeedSystem API (All-in-One)",
"_postman_id": "1a41aef7-6f8a-4bc4-8f55-0c6b12b930d2",
"description": "All endpoints in one collection.\n\nSuggested run order:\n1) Account/Register\n2) Account/Login (auto-saves jwt_token)\n3) Account/Find By Username (auto-saves accountId)\n4) Video/Publish (auto-saves videoId)\n5) Like/* (optional)\n6) Feed/* (optional; copy next fields for pagination)\n\nNotes:\n- JWT protected endpoints require Authorization: Bearer {{jwt_token}}.\n- Pagination vars:\n - /feed/listLatest: response.next_time (unix seconds) -> feedLatestTime\n - /feed/listLikesCount: response.next_likes_count_before -> feedLikesCountBefore",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"const ensure = (k, v) => {",
" const cur = pm.collectionVariables.get(k);",
" if (cur === undefined || cur === null || cur === \"\") pm.collectionVariables.set(k, v);",
"};",
"ensure(\"host\", \"http://localhost:8080\");",
"ensure(\"username\", `user_${Date.now()}`);",
"ensure(\"password\", \"pass123\");",
"ensure(\"newPassword\", \"newpass456\");",
"ensure(\"newUsername\", `user_renamed_${Date.now()}`);",
"ensure(\"jwt_token\", \"\");",
"ensure(\"accountId\", \"1\");",
"ensure(\"authorId\", \"1\");",
"ensure(\"videoId\", \"1\");",
"ensure(\"feedLimit\", \"10\");",
"ensure(\"feedLatestTime\", \"0\");",
"ensure(\"feedLikesCountBefore\", \"0\");",
"ensure(\"commentContent\", `comment_${Date.now()}`);",
"ensure(\"commentId\", \"1\");"
]
}
}
],
"item": [
{
"name": "Account",
"item": [
{
"name": "Register Account",
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": {
"mode": "raw",
"raw": "{\n \"username\": \"{{username}}\",\n \"password\": \"{{password}}\"\n}"
},
"url": {
"raw": "{{host}}/account/register",
"host": ["{{host}}"],
"path": ["account", "register"]
}
}
},
{
"name": "Login (save jwt_token)",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"let json = {};",
"try { json = pm.response.json(); } catch (e) {}",
"if (json && json.token) pm.collectionVariables.set(\"jwt_token\", json.token);",
"pm.test(\"Login returns token\", function () {",
" pm.expect(json).to.have.property(\"token\");",
"});"
]
}
}
],
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": {
"mode": "raw",
"raw": "{\n \"username\": \"{{username}}\",\n \"password\": \"{{password}}\"\n}"
},
"url": {
"raw": "{{host}}/account/login",
"host": ["{{host}}"],
"path": ["account", "login"]
}
}
},
{
"name": "Find By Username (save accountId)",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"let json = {};",
"try { json = pm.response.json(); } catch (e) {}",
"if (json && json.id) pm.collectionVariables.set(\"accountId\", String(json.id));",
"pm.test(\"FindByUsername returns id\", function () {",
" pm.expect(json).to.have.property(\"id\");",
"});"
]
}
}
],
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": {
"mode": "raw",
"raw": "{\n \"username\": \"{{username}}\"\n}"
},
"url": {
"raw": "{{host}}/account/findByUsername",
"host": ["{{host}}"],
"path": ["account", "findByUsername"]
}
}
},
{
"name": "Find By ID",
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": {
"mode": "raw",
"raw": "{\n \"id\": {{accountId}}\n}"
},
"url": {
"raw": "{{host}}/account/findByID",
"host": ["{{host}}"],
"path": ["account", "findByID"]
}
}
},
{
"name": "Change Password",
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": {
"mode": "raw",
"raw": "{\n \"username\": \"{{username}}\",\n \"old_password\": \"{{password}}\",\n \"new_password\": \"{{newPassword}}\"\n}"
},
"url": {
"raw": "{{host}}/account/changePassword",
"host": ["{{host}}"],
"path": ["account", "changePassword"]
}
}
},
{
"name": "Rename (JWT protected)",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"let json = {};",
"try { json = pm.response.json(); } catch (e) {}",
"if (json && json.token) pm.collectionVariables.set(\"jwt_token\", json.token);",
"pm.test(\"Rename returns token\", function () {",
" pm.expect(json).to.have.property(\"token\");",
"});"
]
}
}
],
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "Authorization", "value": "Bearer {{jwt_token}}" }
],
"body": {
"mode": "raw",
"raw": "{\n \"new_username\": \"{{newUsername}}\"\n}"
},
"url": {
"raw": "{{host}}/account/rename",
"host": ["{{host}}"],
"path": ["account", "rename"]
}
}
},
{
"name": "Logout (JWT protected)",
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "Authorization", "value": "Bearer {{jwt_token}}" }
],
"body": { "mode": "raw", "raw": "{}" },
"url": {
"raw": "{{host}}/account/logout",
"host": ["{{host}}"],
"path": ["account", "logout"]
}
}
}
]
},
{
"name": "Video",
"item": [
{
"name": "Publish Video (JWT protected) (save videoId)",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"let json = {};",
"try { json = pm.response.json(); } catch (e) {}",
"if (json && json.id) pm.collectionVariables.set(\"videoId\", String(json.id));",
"if (json && json.author_id) pm.collectionVariables.set(\"authorId\", String(json.author_id));",
"pm.test(\"Publish returns id\", function () {",
" pm.expect(json).to.have.property(\"id\");",
"});"
]
}
}
],
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "Authorization", "value": "Bearer {{jwt_token}}" }
],
"body": {
"mode": "raw",
"raw": "{\n \"title\": \"demo video\",\n \"description\": \"manual request\",\n \"play_url\": \"http://example.com/demo.mp4\",\n \"cover_url\": \"http://example.com/demo.jpg\"\n}"
},
"url": {
"raw": "{{host}}/video/publish",
"host": ["{{host}}"],
"path": ["video", "publish"]
}
}
},
{
"name": "Get Video Detail",
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": { "mode": "raw", "raw": "{\n \"id\": {{videoId}}\n}" },
"url": {
"raw": "{{host}}/video/getDetail",
"host": ["{{host}}"],
"path": ["video", "getDetail"]
}
}
},
{
"name": "List Videos By Author ID",
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": { "mode": "raw", "raw": "{\n \"author_id\": {{authorId}}\n}" },
"url": {
"raw": "{{host}}/video/listByAuthorID",
"host": ["{{host}}"],
"path": ["video", "listByAuthorID"]
}
}
}
]
},
{
"name": "Like",
"item": [
{
"name": "Get Likes Count",
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": { "mode": "raw", "raw": "{\n \"video_id\": {{videoId}}\n}" },
"url": {
"raw": "{{host}}/like/getLikesCount",
"host": ["{{host}}"],
"path": ["like", "getLikesCount"]
}
}
},
{
"name": "Is Liked (JWT protected)",
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "Authorization", "value": "Bearer {{jwt_token}}" }
],
"body": { "mode": "raw", "raw": "{\n \"video_id\": {{videoId}}\n}" },
"url": {
"raw": "{{host}}/like/isLiked",
"host": ["{{host}}"],
"path": ["like", "isLiked"]
}
}
},
{
"name": "Like Video (JWT protected)",
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "Authorization", "value": "Bearer {{jwt_token}}" }
],
"body": { "mode": "raw", "raw": "{\n \"video_id\": {{videoId}}\n}" },
"url": {
"raw": "{{host}}/like/like",
"host": ["{{host}}"],
"path": ["like", "like"]
}
}
},
{
"name": "Unlike Video (JWT protected)",
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "Authorization", "value": "Bearer {{jwt_token}}" }
],
"body": { "mode": "raw", "raw": "{\n \"video_id\": {{videoId}}\n}" },
"url": {
"raw": "{{host}}/like/unlike",
"host": ["{{host}}"],
"path": ["like", "unlike"]
}
}
}
]
},
{
"name": "Comment",
"item": [
{
"name": "Publish Comment (JWT protected) (save commentId)",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"let json = {};",
"try { json = pm.response.json(); } catch (e) {}",
"if (json && json.id) pm.collectionVariables.set(\"commentId\", String(json.id));",
"pm.test(\"Publish comment returns id\", function () {",
" pm.expect(json).to.have.property(\"id\");",
"});"
]
}
}
],
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "Authorization", "value": "Bearer {{jwt_token}}" }
],
"body": {
"mode": "raw",
"raw": "{\n \"video_id\": {{videoId}},\n \"content\": \"{{commentContent}}\"\n}"
},
"url": {
"raw": "{{host}}/comment/publish",
"host": ["{{host}}"],
"path": ["comment", "publish"]
}
}
},
{
"name": "List All Comments",
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": { "mode": "raw", "raw": "{\n \"video_id\": {{videoId}}\n}" },
"url": {
"raw": "{{host}}/comment/listAll",
"host": ["{{host}}"],
"path": ["comment", "listAll"]
}
}
},
{
"name": "Delete Comment (JWT protected)",
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "Authorization", "value": "Bearer {{jwt_token}}" }
],
"body": { "mode": "raw", "raw": "{\n \"comment_id\": {{commentId}}\n}" },
"url": {
"raw": "{{host}}/comment/delete",
"host": ["{{host}}"],
"path": ["comment", "delete"]
}
}
}
]
},
{
"name": "Feed",
"item": [
{
"name": "List Latest Feed (save feedLatestTime)",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"let json = {};",
"try { json = pm.response.json(); } catch (e) {}",
"if (json && typeof json.next_time !== \"undefined\") pm.collectionVariables.set(\"feedLatestTime\", String(json.next_time));"
]
}
}
],
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": {
"mode": "raw",
"raw": "{\n \"limit\": {{feedLimit}},\n \"latest_time\": {{feedLatestTime}}\n}"
},
"url": {
"raw": "{{host}}/feed/listLatest",
"host": ["{{host}}"],
"path": ["feed", "listLatest"]
}
}
},
{
"name": "List Feed By Likes Count (save feedLikesCountBefore)",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"let json = {};",
"try { json = pm.response.json(); } catch (e) {}",
"if (json && typeof json.next_likes_count_before !== \"undefined\") pm.collectionVariables.set(\"feedLikesCountBefore\", String(json.next_likes_count_before));"
]
}
}
],
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": {
"mode": "raw",
"raw": "{\n \"limit\": {{feedLimit}},\n \"likes_count\": {{feedLikesCountBefore}}\n}"
},
"url": {
"raw": "{{host}}/feed/listLikesCount",
"host": ["{{host}}"],
"path": ["feed", "listLikesCount"]
}
}
}
]
}
],
"variable": [
{ "key": "host", "value": "http://localhost:8080" },
{ "key": "username", "value": "" },
{ "key": "password", "value": "" },
{ "key": "newPassword", "value": "" },
{ "key": "newUsername", "value": "" },
{ "key": "jwt_token", "value": "" },
{ "key": "accountId", "value": "" },
{ "key": "authorId", "value": "" },
{ "key": "videoId", "value": "" },
{ "key": "feedLimit", "value": "10" },
{ "key": "feedLatestTime", "value": "0" },
{ "key": "feedLikesCountBefore", "value": "0" },
{ "key": "commentContent", "value": "" },
{ "key": "commentId", "value": "" }
]
}