isomerpages / isomercms-backend

A static website builder and host for the Singapore Government
5 stars 1 forks source link

fix(sl): fix error code #1366

Closed kishore03109 closed 5 months ago

kishore03109 commented 5 months ago

Problem

There was a bug in the implementation of #1355. This worked for sites that were already launched. Newer sites which do no resolve to any host name throws a ENOTFOUND, which should be an ok error.

Solution

To fix this issue, we explicitly check for this error code as well to ensure that this does not error out.

Breaking Changes

Tests

tldr; below we are testing for

  1. domains that have caa + aaaa record (google.com)
  2. domains that dont resolve to a host name (dontexist.sg)
  3. domains that do resolve to a host name but dont have an aaaa/caa record (isomer.gov.sg)

Locally enter these values into support/routes/v2/formsg/index.ts

formsgSiteLaunchRouter
  .digAAAADomainRecords({
    primaryDomainSource: "isomer.gov.sg",
  } as SiteLaunchResult)
  .then(console.log)
  .catch(console.error)

formsgSiteLaunchRouter
  .digCAADomainRecords({
    primaryDomainSource: "isomer.gov.sg",
  } as SiteLaunchResult)
  .then(console.log)
  .catch(console.error)
formsgSiteLaunchRouter
  .digAAAADomainRecords({
    primaryDomainSource: "dontexist.sg",
  } as SiteLaunchResult)
  .then(console.log)
  .catch(console.error)

formsgSiteLaunchRouter
  .digCAADomainRecords({
    primaryDomainSource: "dontexist.sg",
  } as SiteLaunchResult)
  .then(console.log)
  .catch(console.error)
formsgSiteLaunchRouter
  .digAAAADomainRecords({
    primaryDomainSource: "google.com",
  } as SiteLaunchResult)
  .then(console.log)
  .catch(console.error)

formsgSiteLaunchRouter
  .digCAADomainRecords({
    primaryDomainSource: "google.com",
  } as SiteLaunchResult)
  .then(console.log)
  .catch(console.error)

assert that the console log outputs

support-1   | [08:59:33.272] INFO (56): Domain does not have any AAAA records.
support-1   |     module: "formsgSiteLaunch"
support-1   |     meta: {
support-1   |       "domain": "isomer.gov.sg"
support-1   |     }
support-1   | { addAWSACMCertCAA: true, addLetsEncryptCAA: false }
support-1   | [
support-1   |   {
support-1   |     domain: 'google.com',
support-1   |     type: 'AAAA',
support-1   |     value: '2404:6800:4003:c11::64'
support-1   |   },
support-1   |   {
support-1   |     domain: 'google.com',
support-1   |     type: 'AAAA',
support-1   |     value: '2404:6800:4003:c11::65'
support-1   |   },
support-1   |   {
support-1   |     domain: 'google.com',
support-1   |     type: 'AAAA',
support-1   |     value: '2404:6800:4003:c11::71'
support-1   |   },
support-1   |   {
support-1   |     domain: 'google.com',
support-1   |     type: 'AAAA',
support-1   |     value: '2404:6800:4003:c11::8b'
support-1   |   }
support-1   | ]
support-1   | []
support-1   | { addAWSACMCertCAA: false, addLetsEncryptCAA: false }
support-1   | { addAWSACMCertCAA: false, addLetsEncryptCAA: false }
support-1   | []
support-1   | [08:59:33.272] INFO (56): Domain does not have any CAA records.
support-1   |     module: "formsgSiteLaunch"
support-1   |     meta: {
support-1   |       "domain": "isomer.gov.sg"
support-1   |     }
support-1   | [08:59:33.272] INFO (56): Domain does not have any CAA records.
support-1   |     module: "formsgSiteLaunch"
support-1   |     meta: {
support-1   |       "domain": "dontexist.sg"
support-1   |     }
support-1   | [08:59:33.272] INFO (56): Domain does not have any AAAA records.
support-1   |     module: "formsgSiteLaunch"
support-1   |     meta: {
support-1   |       "domain": "dontexist.sg"
support-1   |     }
kishore03109 commented 5 months ago

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @kishore03109 and the rest of your teammates on Graphite Graphite