Skip to content

Commit b50c49f

Browse files
committed
throw error if username not in base url
1 parent 7e7933a commit b50c49f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

api.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,14 @@ describe('other user', () => {
145145
['HEAD', 'GET', 'PUT', 'DELETE'].forEach(method => {
146146

147147
it(`rejects ${ method }`, async () => {
148+
const pattern = new RegExp(`\\/${ process.env.ACCOUNT_HANDLE }$`);
149+
150+
if (!State.baseURL?.match(pattern))
151+
throw new Error('when username is not in webfinger baseURL, set ACCOUNT_HANDLE_ALT');
152+
148153
const handle = Math.random().toString(36).slice(2);
149154
const res = await util.storage(Object.assign(util.clone(State), {
150-
baseURL: State.baseURL.replace(new RegExp(`\\/${ process.env.ACCOUNT_HANDLE }$`), `/${ handle }`),
155+
baseURL: State.baseURL.replace(pattern, `/${ handle }`),
151156
token: State.token_global,
152157
}))[method.toLowerCase()](stub.tid(), method === 'PUT' ? stub.document() : undefined);
153158
expect(res.status).to.be.oneOf([401, 403]);

0 commit comments

Comments
 (0)