test: change test json of postman
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"info": {
|
"info": {
|
||||||
"name": "FeedSystem Account API",
|
"name": "FeedSystem Account API",
|
||||||
"_postman_id": "d5b2888b-1a7d-4c38-9f6b-13ab3e8ffb51",
|
"_postman_id": "1f4c3ab3-6e6e-4a73-8b28-65f9d73f7dc4",
|
||||||
"description": "Basic user endpoints for feedsystem_video_go",
|
"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"
|
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||||
},
|
},
|
||||||
"item": [
|
"item": [
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
],
|
],
|
||||||
"body": {
|
"body": {
|
||||||
"mode": "raw",
|
"mode": "raw",
|
||||||
"raw": "{\n \"username\": \"alice\",\n \"password\": \"pass123\"\n}"
|
"raw": "{\n \"username\": \"{{username}}\",\n \"password\": \"{{password}}\"\n}"
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"raw": "{{host}}/account/register",
|
"raw": "{{host}}/account/register",
|
||||||
@@ -25,7 +25,23 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Rename Account",
|
"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": {
|
"request": {
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"header": [
|
"header": [
|
||||||
@@ -33,12 +49,12 @@
|
|||||||
],
|
],
|
||||||
"body": {
|
"body": {
|
||||||
"mode": "raw",
|
"mode": "raw",
|
||||||
"raw": "{\n \"id\": 1,\n \"new_username\": \"alice_new\"\n}"
|
"raw": "{\n \"username\": \"{{username}}\",\n \"password\": \"{{password}}\"\n}"
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"raw": "{{host}}/account/rename",
|
"raw": "{{host}}/account/login",
|
||||||
"host": ["{{host}}"],
|
"host": ["{{host}}"],
|
||||||
"path": ["account", "rename"]
|
"path": ["account", "login"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -51,7 +67,7 @@
|
|||||||
],
|
],
|
||||||
"body": {
|
"body": {
|
||||||
"mode": "raw",
|
"mode": "raw",
|
||||||
"raw": "{\n \"username\": \"alice\",\n \"old_password\": \"pass123\",\n \"new_password\": \"newpass456\"\n}"
|
"raw": "{\n \"username\": \"{{username}}\",\n \"old_password\": \"{{password}}\",\n \"new_password\": \"{{newPassword}}\"\n}"
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"raw": "{{host}}/account/changePassword",
|
"raw": "{{host}}/account/changePassword",
|
||||||
@@ -69,7 +85,7 @@
|
|||||||
],
|
],
|
||||||
"body": {
|
"body": {
|
||||||
"mode": "raw",
|
"mode": "raw",
|
||||||
"raw": "{\n \"id\": 1\n}"
|
"raw": "{\n \"id\": {{accountId}}\n}"
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"raw": "{{host}}/account/findByID",
|
"raw": "{{host}}/account/findByID",
|
||||||
@@ -87,7 +103,7 @@
|
|||||||
],
|
],
|
||||||
"body": {
|
"body": {
|
||||||
"mode": "raw",
|
"mode": "raw",
|
||||||
"raw": "{\n \"username\": \"alice_new\"\n}"
|
"raw": "{\n \"username\": \"{{username}}\"\n}"
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"raw": "{{host}}/account/findByUsername",
|
"raw": "{{host}}/account/findByUsername",
|
||||||
@@ -95,12 +111,79 @@
|
|||||||
"path": ["account", "findByUsername"]
|
"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": [
|
"variable": [
|
||||||
{
|
{ "key": "host", "value": "http://localhost:8080" },
|
||||||
"key": "host",
|
{ "key": "username", "value": "alice" },
|
||||||
"value": "http://localhost:8080"
|
{ "key": "password", "value": "pass123" },
|
||||||
}
|
{ "key": "newPassword", "value": "newpass456" },
|
||||||
|
{ "key": "newUsername", "value": "alice_new" },
|
||||||
|
{ "key": "accountId", "value": "1" },
|
||||||
|
{ "key": "jwt_token", "value": "" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
128
test/auth.json
128
test/auth.json
@@ -1,128 +0,0 @@
|
|||||||
{
|
|
||||||
"info": {
|
|
||||||
"_postman_id": "2a6b02fb-7ab2-4f4c-a1c6-6e19e7d9f2ba",
|
|
||||||
"name": "feedsystem auth flow",
|
|
||||||
"description": "使用 Postman 验证 /auth/login 与 /auth/logout 接口。先运行 Login 请求以保存 token,再运行 Logout 请求;Logout 会自动把 token 放到 Authorization 头里。",
|
|
||||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
|
||||||
},
|
|
||||||
"item": [
|
|
||||||
{
|
|
||||||
"name": "Login",
|
|
||||||
"request": {
|
|
||||||
"method": "POST",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"value": "application/json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"mode": "raw",
|
|
||||||
"raw": "{\n \"username\": \"{{username}}\",\n \"password\": \"{{password}}\"\n}"
|
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
"raw": "{{baseUrl}}/auth/login",
|
|
||||||
"host": [
|
|
||||||
"{{baseUrl}}"
|
|
||||||
],
|
|
||||||
"path": [
|
|
||||||
"auth",
|
|
||||||
"login"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"event": [
|
|
||||||
{
|
|
||||||
"listen": "test",
|
|
||||||
"script": {
|
|
||||||
"type": "text/javascript",
|
|
||||||
"exec": [
|
|
||||||
"pm.test(\"登录成功\", 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);",
|
|
||||||
"});"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Logout",
|
|
||||||
"event": [
|
|
||||||
{
|
|
||||||
"listen": "prerequest",
|
|
||||||
"script": {
|
|
||||||
"type": "text/javascript",
|
|
||||||
"exec": [
|
|
||||||
"if (!pm.collectionVariables.get(\"jwt_token\")) {",
|
|
||||||
" throw new Error(\"请先运行 Login 请求以获取 token\");",
|
|
||||||
"}"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"listen": "test",
|
|
||||||
"script": {
|
|
||||||
"type": "text/javascript",
|
|
||||||
"exec": [
|
|
||||||
"pm.test(\"登出成功\", function () {",
|
|
||||||
" pm.response.to.have.status(200);",
|
|
||||||
"});"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"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": "{{baseUrl}}/auth/logout",
|
|
||||||
"host": [
|
|
||||||
"{{baseUrl}}"
|
|
||||||
],
|
|
||||||
"path": [
|
|
||||||
"auth",
|
|
||||||
"logout"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"variable": [
|
|
||||||
{
|
|
||||||
"key": "baseUrl",
|
|
||||||
"value": "http://localhost:8080"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "username",
|
|
||||||
"value": "demo"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "password",
|
|
||||||
"value": "demo123"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "accountId",
|
|
||||||
"value": "1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "jwt_token",
|
|
||||||
"value": ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
149
test/video.json
Normal file
149
test/video.json
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
{
|
||||||
|
"info": {
|
||||||
|
"name": "FeedSystem Video API",
|
||||||
|
"_postman_id": "05c51174-a3e4-4c86-9a79-2b0ca8856106",
|
||||||
|
"description": "Postman collection for video endpoints, including public queries and the JWT-protected publish action.",
|
||||||
|
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||||
|
},
|
||||||
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "List Latest Videos",
|
||||||
|
"event": [
|
||||||
|
{
|
||||||
|
"listen": "test",
|
||||||
|
"script": {
|
||||||
|
"type": "text/javascript",
|
||||||
|
"exec": [
|
||||||
|
"pm.test(\"latest videos fetched\", function () {",
|
||||||
|
" pm.response.to.have.status(200);",
|
||||||
|
"});"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"header": [
|
||||||
|
{ "key": "Content-Type", "value": "application/json" }
|
||||||
|
],
|
||||||
|
"body": { "mode": "raw", "raw": "{}" },
|
||||||
|
"url": {
|
||||||
|
"raw": "{{host}}/video/listLatest",
|
||||||
|
"host": ["{{host}}"],
|
||||||
|
"path": ["video", "listLatest"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "List Videos By Author ID",
|
||||||
|
"event": [
|
||||||
|
{
|
||||||
|
"listen": "test",
|
||||||
|
"script": {
|
||||||
|
"type": "text/javascript",
|
||||||
|
"exec": [
|
||||||
|
"pm.test(\"author videos fetched\", function () {",
|
||||||
|
" pm.response.to.have.status(200);",
|
||||||
|
"});"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "Get Video Detail",
|
||||||
|
"event": [
|
||||||
|
{
|
||||||
|
"listen": "test",
|
||||||
|
"script": {
|
||||||
|
"type": "text/javascript",
|
||||||
|
"exec": [
|
||||||
|
"pm.test(\"video detail fetched\", function () {",
|
||||||
|
" pm.response.to.have.status(200);",
|
||||||
|
"});"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "Publish Video (JWT protected)",
|
||||||
|
"event": [
|
||||||
|
{
|
||||||
|
"listen": "prerequest",
|
||||||
|
"script": {
|
||||||
|
"type": "text/javascript",
|
||||||
|
"exec": [
|
||||||
|
"if (!pm.collectionVariables.get(\"jwt_token\")) {",
|
||||||
|
" throw new Error(\"Set jwt_token first (usually the login API response)\");",
|
||||||
|
"}"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"listen": "test",
|
||||||
|
"script": {
|
||||||
|
"type": "text/javascript",
|
||||||
|
"exec": [
|
||||||
|
"pm.test(\"video published\", function () {",
|
||||||
|
" pm.response.to.have.status(200);",
|
||||||
|
"});"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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\": \"auto generated via Postman\",\n \"play_url\": \"http://example.com/demo.mp4\"\n}"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"raw": "{{host}}/video/publish",
|
||||||
|
"host": ["{{host}}"],
|
||||||
|
"path": ["video", "publish"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"variable": [
|
||||||
|
{ "key": "host", "value": "http://localhost:8080" },
|
||||||
|
{ "key": "authorId", "value": "1" },
|
||||||
|
{ "key": "videoId", "value": "1" },
|
||||||
|
{ "key": "jwt_token", "value": "" }
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user