Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up the healthcheck endpoint #2704

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

cooperaj
Copy link
Contributor

Approach

Switch out to the PSR standards http client code introduced earlier for the healthcheck.

Additionally ensured that the healthcheck works locally against the configured mocks.

Checklist

  • I have performed a self-review of my own code
  • I have added relevant logging with appropriate levels to my code
  • New event_codes have been documented on the wiki page
  • I have updated documentation (Confluence/GitHub wiki/tech debt doc) where relevant
  • I have added tests to prove my work
  • I have added welsh translation tags and updated translation files
  • I have run an accessibility tool on any pages I have made changes to and fixed any issues found
  • I have notified the Interaction Designer of any content changes so that appropriate screenshots/flow diagram changes can be made
  • The product team have tested these changes

@cooperaj cooperaj requested a review from a team as a code owner July 12, 2024 16:38
@github-actions github-actions bot added php Pull requests that update Php code service-api labels Jul 12, 2024
Copy link

codecov bot commented Jul 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.17%. Comparing base (ee45e51) to head (2561ccd).
Report is 8 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #2704      +/-   ##
============================================
+ Coverage     91.14%   91.17%   +0.02%     
- Complexity     1497     1501       +4     
============================================
  Files           306      307       +1     
  Lines          6312     6332      +20     
============================================
+ Hits           5753     5773      +20     
  Misses          542      542              
  Partials         17       17              
Flag Coverage Δ
use-an-lpa-admin 79.44% <ø> (ø)
use-an-lpa-api 97.29% <100.00%> (+0.01%) ⬆️
use-an-lpa-front 89.54% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...rc/App/src/DataAccess/ApiGateway/RequestSigner.php 100.00% <100.00%> (ø)
.../src/Handler/Factory/HealthcheckHandlerFactory.php 100.00% <100.00%> (ø)
...api/app/src/App/src/Handler/HealthcheckHandler.php 87.93% <100.00%> (+1.93%) ⬆️

Comment on lines 28 to 40
$request = $this->signer->signRequest($request, $this->credentials);

foreach ($this->headers as $header => $value) {
$request = $request->withHeader($header, $value);
}

return $this->signer->signRequest($request, $this->credentials);
return $request;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may cause signing to break, since V4 signatures include the headers as part of the signature. If you add headers after signing, they'll be included in the signature AWS generates server-side and the signatures won't match,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm. Darn. Hadn't considered that.

The issue here is that the mock codes service expects a static Authorisation header value, hence overwriting it after the fact works.

If you set that value first then the aws signer overwrites it with it's own.

I guess this class needs a different approach to handle that case. I think what I'll do is treat the 'Authorization' header as a special case. If you're setting that manually then you know you're going to be breaking the aws signature side of things - which is fine for us because that only happens when doing local dev.

Comment on lines -97 to +125
* @param RequestInterface $request
* @param RequestInterface $uri
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? The PHP typehints suggest the parameter is still called $request

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what happened here. Will fix.

@cooperaj cooperaj force-pushed the healthcheck-endpoint-fix branch from ef1c98a to 8dd5a11 Compare July 17, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
php Pull requests that update Php code service-api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants