feat: apply UI/storage/share optimizations and quota improvements
This commit is contained in:
@@ -448,7 +448,7 @@ async function testGetDownloadUrl() {
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await request('GET', `/api/share/${testShareCode}/download-url?path=/test-file.txt`);
|
||||
const res = await request('POST', `/api/share/${testShareCode}/download-url`, { path: '/test-file.txt' });
|
||||
|
||||
// 如果文件存在
|
||||
if (res.status === 200) {
|
||||
@@ -481,7 +481,7 @@ async function testDownloadWithPassword() {
|
||||
|
||||
// 测试无密码
|
||||
try {
|
||||
const res1 = await request('GET', `/api/share/${passwordShareCode}/download-url?path=/test-file-password.txt`);
|
||||
const res1 = await request('POST', `/api/share/${passwordShareCode}/download-url`, { path: '/test-file-password.txt' });
|
||||
assert(res1.status === 401, '无密码应返回 401');
|
||||
} catch (error) {
|
||||
console.log(` [ERROR] 测试无密码下载: ${error.message}`);
|
||||
@@ -489,7 +489,7 @@ async function testDownloadWithPassword() {
|
||||
|
||||
// 测试带密码
|
||||
try {
|
||||
const res2 = await request('GET', `/api/share/${passwordShareCode}/download-url?path=/test-file-password.txt&password=test123`);
|
||||
const res2 = await request('POST', `/api/share/${passwordShareCode}/download-url`, { path: '/test-file-password.txt', password: 'test123' });
|
||||
// 密码正确,根据文件是否存在返回不同结果
|
||||
if (res2.status === 200) {
|
||||
assert(res2.data.downloadUrl, '应返回下载链接');
|
||||
@@ -535,7 +535,7 @@ async function testDownloadPathValidation() {
|
||||
|
||||
// 测试越权访问
|
||||
try {
|
||||
const res = await request('GET', `/api/share/${testShareCode}/download-url?path=/other-file.txt`);
|
||||
const res = await request('POST', `/api/share/${testShareCode}/download-url`, { path: '/other-file.txt' });
|
||||
|
||||
// 单文件分享应该禁止访问其他文件
|
||||
assert(res.status === 403 || res.status === 404, '越权访问应被拒绝');
|
||||
@@ -546,7 +546,7 @@ async function testDownloadPathValidation() {
|
||||
|
||||
// 测试路径遍历
|
||||
try {
|
||||
const res2 = await request('GET', `/api/share/${testShareCode}/download-url?path=/../../../etc/passwd`);
|
||||
const res2 = await request('POST', `/api/share/${testShareCode}/download-url`, { path: '/../../../etc/passwd' });
|
||||
assert(res2.status === 403 || res2.status === 400, '路径遍历应被拒绝');
|
||||
} catch (error) {
|
||||
console.log(` [ERROR] 路径遍历测试: ${error.message}`);
|
||||
@@ -682,7 +682,7 @@ async function testShareNotExists() {
|
||||
|
||||
// 下载
|
||||
try {
|
||||
const res3 = await request('GET', `/api/share/${nonExistentCode}/download-url?path=/test.txt`);
|
||||
const res3 = await request('POST', `/api/share/${nonExistentCode}/download-url`, { path: '/test.txt' });
|
||||
assert(res3.status === 404, '下载不存在分享应返回 404');
|
||||
} catch (error) {
|
||||
console.log(` [ERROR] ${error.message}`);
|
||||
|
||||
Reference in New Issue
Block a user