Skip to content

test: mock cdn response files#23062

Merged
seaona merged 10 commits intodevelopfrom
test-mock-cdn
Mar 22, 2024
Merged

test: mock cdn response files#23062
seaona merged 10 commits intodevelopfrom
test-mock-cdn

Conversation

@seaona
Copy link
Copy Markdown
Member

@seaona seaona commented Feb 20, 2024

Description

Particularities of these mocks:

  • since the returned cdn files are signed, we should make sure that the validateSignature works. For that, we should mock both the response headers and the response body of the requests
  • we first mock the ppom-version.json response, which contains the version, checksum, signature, hashSignature for each file and each supported chain
  • we mock the 3 cdn response for the config, stale and stale_diff files
    • the response is compressed in Brotli
    • we need to mock the return headers too, with the correct Etag. The rest of the headers can be omitted

Next steps:

Related issues

Fixes: #23639

Manual testing steps

  1. Check ci jobs

Screenshots/Recordings

Response data compressed (Brotli)

Screenshot from 2024-02-20 11-19-50

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@seaona seaona added the team-confirmations-secure-ux-PR PRs from the confirmations team label Feb 20, 2024
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

'0x985c30949c92df7a0bd42e0f3e3d539ece98db24',
'1',
);
await sendScreenToConfirmScreen(driver, mockMaliciousAddress, '1');
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

for some reason, the address set previously was not the malicious address. Here I fixed it by adding the malicious address

it('should not show security alerts for benign requests', async function () {
if (process.env.MULTICHAIN) {
return;
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the flow for the multichain build needs to be updated altogether. It's left out of scope of this PR, since this purely focuses on enabling mocks. The update multichain flow should be tackled in a subsequent PR (see description)

@seaona seaona marked this pull request as ready for review March 22, 2024 09:37
@seaona seaona requested a review from a team as a code owner March 22, 2024 09:37
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.57%. Comparing base (a246dc3) to head (4dcffb1).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #23062   +/-   ##
========================================
  Coverage    68.57%   68.57%           
========================================
  Files         1163     1163           
  Lines        44134    44134           
  Branches     11813    11813           
========================================
  Hits         30262    30262           
  Misses       13872    13872           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -0,0 +1,3 @@
{
"Etag": "bb28e40153ff052671b8ad835d368d89"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

only the etag is needed to verify the file signature

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [4dcffb1]
Page Load Metrics (811 ± 548 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint692401254321
domContentLoaded125824136
load5635898111142548
domInteractive125824136
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@seaona seaona merged commit fd6b6ca into develop Mar 22, 2024
@seaona seaona deleted the test-mock-cdn branch March 22, 2024 12:38
@github-actions github-actions bot locked and limited conversation to collaborators Mar 22, 2024
@metamaskbot metamaskbot added release-11.14.1 Issue or pull request that will be included in release 11.14.1 release-11.14.0 Issue or pull request that will be included in release 11.14.0 and removed release-11.14.1 Issue or pull request that will be included in release 11.14.1 labels Mar 22, 2024
@metamaskbot
Copy link
Copy Markdown
Collaborator

Missing release label release-11.14.0 on PR. Adding release label release-11.14.0 on PR and removing other release labels(release-11.14.1), as PR was added to branch 11.14.0 when release was cut.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-11.14.0 Issue or pull request that will be included in release 11.14.0 team-confirmations-secure-ux-PR PRs from the confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[e2e] Infra - PPOM - Add default cdn mocks

6 participants