Files
VLoop/test/account.json
2025-12-07 16:49:41 +08:00

190 lines
5.3 KiB
JSON

{
"info": {
"name": "FeedSystem Account API",
"_postman_id": "1f4c3ab3-6e6e-4a73-8b28-65f9d73f7dc4",
"description": "Account endpoints for feedsystem_video_go. Run Login first to capture jwt_token for protected calls.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"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",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test(\"login ok\", function () {",
" pm.response.to.have.status(200);",
" var data = pm.response.json();",
" pm.expect(data.token).to.exist;",
" pm.collectionVariables.set(\"jwt_token\", data.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": "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": "Find Account 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": "Find Account By Username",
"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": "Rename Account (JWT protected)",
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"if (!pm.collectionVariables.get(\"jwt_token\")) {",
" throw new Error(\"Please run Login to set jwt_token\");",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "Authorization", "value": "Bearer {{jwt_token}}" }
],
"body": {
"mode": "raw",
"raw": "{\n \"id\": {{accountId}},\n \"new_username\": \"{{newUsername}}\"\n}"
},
"url": {
"raw": "{{host}}/account/rename",
"host": ["{{host}}"],
"path": ["account", "rename"]
}
}
},
{
"name": "Logout (JWT protected)",
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"if (!pm.collectionVariables.get(\"jwt_token\")) {",
" throw new Error(\"Please run Login to set jwt_token\");",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "Authorization", "value": "Bearer {{jwt_token}}" }
],
"body": {
"mode": "raw",
"raw": "{\n \"id\": {{accountId}}\n}"
},
"url": {
"raw": "{{host}}/account/logout",
"host": ["{{host}}"],
"path": ["account", "logout"]
}
}
}
],
"variable": [
{ "key": "host", "value": "http://localhost:8080" },
{ "key": "username", "value": "alice" },
{ "key": "password", "value": "pass123" },
{ "key": "newPassword", "value": "newpass456" },
{ "key": "newUsername", "value": "alice_new" },
{ "key": "accountId", "value": "1" },
{ "key": "jwt_token", "value": "" }
]
}