diff --git a/app/test/config.test.js b/app/test/config.test.js index d673eab..d3f6001 100644 --- a/app/test/config.test.js +++ b/app/test/config.test.js @@ -104,6 +104,21 @@ test('loadConfig 於 GITEA_REPOSITORY 邊界格式(空段/缺斜線/多段) } }); +test('loadConfig 於 GITEA_REPOSITORY 含非法字元或超長段時拋錯', () => { + const bad = [ + 'ow ner/repo', + 'owner/re*po', + 'owner/re:po', + `${'a'.repeat(101)}/repo`, + ]; + for (const repo of bad) { + assert.throws(() => loadConfig({ + GITEA_SERVER_URL: 'https://gitea.example.com', + GITEA_REPOSITORY: repo, + }), /GITEA_REPOSITORY 格式錯誤/, `應拒絕:${repo}`); + } +}); + test('loadConfig 接受含點號的合法 owner/repo', () => { const config = loadConfig({ GITEA_SERVER_URL: 'https://gitea.example.com',