-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: transfer ownership of auth & profile sync E2E from notificatio…
…ns to identity (#12569) ## **Description** This PR takes care of all the necessary changes in order to decouple Auth & Profile Sync E2E from the notifications feature. This also underlines the ownership change from @MetaMask/notifications to @MetaMask/identity. The changes made here will help transitioning to cleaner separation of concerns for features leveraging profile sync (i.e Notifications, Account syncing...).⚠️ This PR does not add missing tests nor introduces any changes. This is only moving files around and separating concerns. ☝️ This PR has the "No E2E Smoke Needed" label since, even though we're moving e2e files, these E2E tests are not ran yet (they were - and still are - commented in `bitrise.yml`) ## **Related issues** Fixes: ## **Manual testing steps** No testing steps since this PR does not change the implementation of existing features. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] 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.
- Loading branch information
1 parent
011560f
commit fcb68ad
Showing
12 changed files
with
119 additions
and
49 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// As we rely on profile syncing for most of our features, we need to use the same SRP for all of our tests | ||
export const IDENTITY_TEAM_SEED_PHRASE = | ||
'leisure swallow trip elbow prison wait rely keep supply hole general mountain'; | ||
export const IDENTITY_TEAM_PASSWORD = 'notify_password'; | ||
// You can use the storage key below to generate mock data | ||
export const IDENTITY_TEAM_STORAGE_KEY = | ||
'0d55d30da233959674d14076737198c05ae3fb8631a17e20d3c28c60dddd82f7'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const determineIfFeatureEntryFromURL = (url) => { | ||
const decodedUrl = decodeURIComponent(url); | ||
return ( | ||
decodedUrl.substring(decodedUrl.lastIndexOf('userstorage') + 12).split('/') | ||
.length === 2 | ||
); | ||
}; | ||
|
||
export const getDecodedProxiedURL = (url) => | ||
decodeURIComponent(String(new URL(url).searchParams.get('url'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { AuthenticationController } from '@metamask/profile-sync-controller'; | ||
import { UserStorageMockttpController } from './user-storage/userStorageMockttpController'; | ||
import { getDecodedProxiedURL } from './helpers'; | ||
|
||
const AuthMocks = AuthenticationController.Mocks; | ||
|
||
/** | ||
* E2E mock setup for identity APIs (Auth, UserStorage, Profile syncing) | ||
* | ||
* @param server - server obj used to mock our endpoints | ||
* @param userStorageMockttpController - optional controller to mock user storage endpoints | ||
*/ | ||
export async function mockIdentityServices(server) { | ||
// Auth | ||
mockAPICall(server, AuthMocks.getMockAuthNonceResponse()); | ||
mockAPICall(server, AuthMocks.getMockAuthLoginResponse()); | ||
mockAPICall(server, AuthMocks.getMockAuthAccessTokenResponse()); | ||
|
||
// Storage | ||
const userStorageMockttpControllerInstance = | ||
new UserStorageMockttpController(); | ||
|
||
userStorageMockttpControllerInstance.setupPath('accounts', server); | ||
userStorageMockttpControllerInstance.setupPath('networks', server); | ||
|
||
return { | ||
userStorageMockttpControllerInstance, | ||
}; | ||
} | ||
|
||
function mockAPICall(server, response) { | ||
let requestRuleBuilder; | ||
|
||
if (response.requestMethod === 'GET') { | ||
requestRuleBuilder = server.forGet('/proxy'); | ||
} | ||
|
||
if (response.requestMethod === 'POST') { | ||
requestRuleBuilder = server.forPost('/proxy'); | ||
} | ||
|
||
if (response.requestMethod === 'PUT') { | ||
requestRuleBuilder = server.forPut('/proxy'); | ||
} | ||
|
||
if (response.requestMethod === 'DELETE') { | ||
requestRuleBuilder = server.forDelete('/proxy'); | ||
} | ||
|
||
requestRuleBuilder | ||
?.matching((request) => { | ||
const url = getDecodedProxiedURL(request.url); | ||
|
||
return url.includes(String(response.url)); | ||
}) | ||
.thenCallback(() => ({ | ||
statusCode: 200, | ||
json: response.response, | ||
})); | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters