The easiest way to run Mongo is using docker.
You will need the DESKPRO_TICKET_QUEUE service running locally:
sm2 --start DESKPRO_TICKET_QUEUETo start the application locally with the test-only endpoints enabled,
./run.shYou should then be able to navigate to the following endpoints:
- http://localhost:9250/contact/contact-hmrc?service=foo
- http://localhost:9250/contact/report-technical-problem?service=foo
- http://localhost:9250/contact/survey?ticketId=ABCD-EFGH-ASDF&serviceId=foo
- http://localhost:9250/contact/beta-feedback?service=foo
- http://localhost:9250/contact/accessibility?service=foo
To run the Scala unit and integration tests,
sbt test it/testTo execute the UI acceptance tests on your local machine, follow the guidance in the contact-frontend-ui-tests repository. These will also run the accessibility tests via ui-test-runner.
We are using MADRs to record architecturally significant decisions in this service. To find out more visit MADR
See our architectural decision log (ADL) for a list of past decisions.
-
Install Node if you do not have this already. Node includes npm.
-
Install
adr-logif you do not have this alreadynpm install -g adr-log
-
Copy template.md as NNNN-title-of-decision.md, and fill in the fields. Do not feel you have to fill in all the fields, only fill in fields that are strictly necessary. Some decisions will merit more detail than others.
-
To re-generate the table of contents, run
./generate-adl.sh
Validation of email addresses on the server side within contact-frontend has some complexity to consider.
Specifically, there is a known unhappy path that can occur:
-
End user submits a form via
contact-frontend, with an email addresses that passes validation withincontact-frontendon the server side controller -
Ticket is created in the encrypted Mongo-backed queue within
deskpro-ticket-queue -
Ticket is sent asynchronously to Deskpro, which may use different email validation rules. If the ticket has been created with an email addresses that does not pass Deskpro's validation rules, it will be repeatedly submitted to Deskpro as a scheduled POST until it reaches a maximum number of retries, at which point it is marked as permanently failed and deleted after the TTL expires (at time of writing, 200 days).
The decision has therefore been taken to align contact-frontend with the email validation rules in Deskpro. These are
written in PHP Perl Compatible Regular Expressions (PCRE) syntax.
Most of the regex syntax used by PCRE is standard and does not need any modification to be usable in Scala. However, there are a few things of which to be aware.
- In the Deskpro PCRE regexes in their provided source code,
the
#symbol is used as a delimiter at the start and end of the regex. When converting to Scala, these can be deleted.
'#^[a-Z0-9]{1}#'
becomes
"""^[a-Z0-9]{1}""".r- The PCRE regexes use a final
ito denote that a regex is case-insensitive. In Scala, this should be leading(?i)
'#^[hello world]{1}#i'
becomes
"""(?i)^[hello world]{1}""".r- PCRE regexes may escape the
#and other special character that may be used as delimiters. These do not need to be escaped in Scala.
'#^[a-z0-9!\\#$%&\'*+/=?^_`{|}~-]+#i'
becomes
"""(?i)[a-z0-9!#$%&'*+/=?^_`{|}~-]+""".r