Skip to content

Commit

Permalink
feat: add leading dot check
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Mar 29, 2024
1 parent 964bae4 commit b627162
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/measurement/schema/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const joiValidateDomainForDns = () => (value: string, helpers: CustomHelp
return value;
}

if (validator.isFQDN('example' + value, options)) {
if (value[0] === '.' && validator.isFQDN('example' + value, options)) {
return value.substring(1);
}

Expand Down
12 changes: 10 additions & 2 deletions test/tests/e2e/cases/dns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,35 @@ describe('dns mesurement', () => {
const { id } = await got.post('http://localhost:80/v1/measurements', { json: {
target: '.',
type: 'dns',
measurementOptions: {
query: {
type: 'ANY',
},
},
} }).json();

const response = await waitMesurementFinish(id);

expect(response.body.status).to.equal('finished');
expect(response.body.results[0].result.status).to.equal('finished');
expect(response.body.results[0].result.hops.length).to.be.above(0);
expect(response).to.matchApiSchema();
});

it('should finish successfully in case of tld target', async () => {
const { id } = await got.post('http://localhost:80/v1/measurements', { json: {
target: '.com',
type: 'dns',
measurementOptions: {
query: {
type: 'ANY',
},
},
} }).json();

const response = await waitMesurementFinish(id);

expect(response.body.status).to.equal('finished');
expect(response.body.results[0].result.status).to.equal('finished');
expect(response.body.results[0].result.hops.length).to.be.above(0);
expect(response).to.matchApiSchema();
});
});

0 comments on commit b627162

Please sign in to comment.