-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: remove mock seedless controller from performance tests #28713
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
Open
grvgoel81
wants to merge
17
commits into
main
Choose a base branch
from
fix/perforamce-tests-remove-mock-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ba17afe
initial commit
grvgoel81 ae192c6
modify metro configuration
grvgoel81 1bee392
use real toprf auth with uat oAuth config
grvgoel81 790758e
update clientId in mocks
grvgoel81 75aa2c2
update client_id
grvgoel81 dbf37d2
update client_id
grvgoel81 577bdeb
wait up to threshold for wallet in seedless onboarding tests
grvgoel81 981644d
modify perf onboarding tests
grvgoel81 5fb19bf
update unit-tests
grvgoel81 e6160df
update unit-tests
grvgoel81 45112da
resolve cursor comments
grvgoel81 e3e8264
increase unit-tests coverage
grvgoel81 3294e46
trust user CAs in network security config for BrowserStack logs
grvgoel81 fc0a212
update OAuth mocks
grvgoel81 118ead7
resolve sonar warnings
grvgoel81 56b6db3
Merge branch 'main' into fix/perforamce-tests-remove-mock-api
grvgoel81 44e542b
update client-id to env vars
grvgoel81 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,10 +1,15 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <network-security-config> | ||
| <base-config cleartextTrafficPermitted="${isDebug}"> | ||
| <trust-anchors> | ||
| <certificates src="system" /> | ||
| <certificates src="user" /> | ||
| </trust-anchors> | ||
| </base-config> | ||
| <domain-config cleartextTrafficPermitted="true"> | ||
| <domain includeSubdomains="true">sslip.io</domain> | ||
| <domain includeSubdomains="true">sslip.io</domain> | ||
| <domain includeSubdomains="false">localhost</domain> | ||
| <domain includeSubdomains="false">10.0.2.2</domain> | ||
| <domain includeSubdomains="false">10.0.3.2</domain> | ||
| </domain-config> | ||
| <base-config cleartextTrafficPermitted="${isDebug}" /> | ||
| </network-security-config> |
This file contains hidden or 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 hidden or 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
83 changes: 83 additions & 0 deletions
83
app/core/OAuthService/OAuthLoginHandlers/oauthBuildType.test.ts
This file contains hidden or 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,83 @@ | ||
| import { BUILD_TYPE, OAUTH_CONFIG } from './config'; | ||
| import { buildTypeMapping } from './oauthBuildType'; | ||
|
|
||
| describe('buildTypeMapping', () => { | ||
| const originalDevOAuth = process.env.DEV_OAUTH_CONFIG; | ||
|
|
||
| afterEach(() => { | ||
| if (originalDevOAuth === undefined) { | ||
| delete process.env.DEV_OAUTH_CONFIG; | ||
| } else { | ||
| process.env.DEV_OAUTH_CONFIG = originalDevOAuth; | ||
| } | ||
| }); | ||
|
|
||
| it('returns development when DEV_OAUTH_CONFIG is true and isDev', () => { | ||
| process.env.DEV_OAUTH_CONFIG = 'true'; | ||
| expect(buildTypeMapping('main', true, false)).toBe(BUILD_TYPE.development); | ||
| }); | ||
|
|
||
| it('maps qa to main_uat', () => { | ||
| expect(buildTypeMapping('qa', false, false)).toBe(BUILD_TYPE.main_uat); | ||
| }); | ||
|
|
||
| it('maps main with QA channel to main_uat', () => { | ||
| expect(buildTypeMapping('main', false, true)).toBe(BUILD_TYPE.main_uat); | ||
| }); | ||
|
|
||
| it('maps main without QA to main_dev when isDev', () => { | ||
| expect(buildTypeMapping('main', true, false)).toBe(BUILD_TYPE.main_dev); | ||
| }); | ||
|
|
||
| it('maps main without QA to main_prod when not isDev', () => { | ||
| expect(buildTypeMapping('main', false, false)).toBe(BUILD_TYPE.main_prod); | ||
| }); | ||
|
|
||
| it('maps flask with QA channel to flask_uat', () => { | ||
| expect(buildTypeMapping('flask', false, true)).toBe(BUILD_TYPE.flask_uat); | ||
| }); | ||
|
|
||
| it('maps flask without QA to flask_dev when isDev', () => { | ||
| expect(buildTypeMapping('flask', true, false)).toBe(BUILD_TYPE.flask_dev); | ||
| }); | ||
|
|
||
| it('maps flask without QA to flask_prod when not isDev', () => { | ||
| expect(buildTypeMapping('flask', false, false)).toBe(BUILD_TYPE.flask_prod); | ||
| }); | ||
|
|
||
| it('returns development for unknown build type', () => { | ||
| expect(buildTypeMapping('unknown', false, false)).toBe( | ||
| BUILD_TYPE.development, | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('resolveOAuthConfigKey', () => { | ||
| const originalOauthBuildType = process.env.OAUTH_BUILD_TYPE; | ||
|
|
||
| afterEach(() => { | ||
| if (originalOauthBuildType === undefined) { | ||
| delete process.env.OAUTH_BUILD_TYPE; | ||
| } else { | ||
| process.env.OAUTH_BUILD_TYPE = originalOauthBuildType; | ||
| } | ||
| }); | ||
|
|
||
| it('returns OAUTH_BUILD_TYPE when set to a valid config key', () => { | ||
| jest.resetModules(); | ||
| process.env.OAUTH_BUILD_TYPE = BUILD_TYPE.main_prod; | ||
| // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires -- Jest reload after resetModules; dynamic import needs experimental-vm-modules | ||
| const { resolveOAuthConfigKey } = require('./oauthBuildType'); | ||
| expect(resolveOAuthConfigKey()).toBe(BUILD_TYPE.main_prod); | ||
| }); | ||
|
|
||
| it('ignores OAUTH_BUILD_TYPE when not a key of OAUTH_CONFIG', () => { | ||
| jest.resetModules(); | ||
| process.env.OAUTH_BUILD_TYPE = 'not_a_real_key'; | ||
| // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires | ||
| const { resolveOAuthConfigKey } = require('./oauthBuildType'); | ||
| const key = resolveOAuthConfigKey(); | ||
| expect(key).not.toBe('not_a_real_key'); | ||
| expect(key in OAUTH_CONFIG).toBe(true); | ||
| }); | ||
| }); |
56 changes: 56 additions & 0 deletions
56
app/core/OAuthService/OAuthLoginHandlers/oauthBuildType.ts
This file contains hidden or 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,56 @@ | ||
| import AppConstants from '../../AppConstants'; | ||
| import { isQa } from '../../../util/test/utils'; | ||
| import { BUILD_TYPE, OAUTH_CONFIG } from './config'; | ||
|
|
||
| /** | ||
| * Maps MetaMask build type + dev/QA flags to OAuth config keys. | ||
| * @param buildType - e.g. main, qa, flask | ||
| * @param isDev - development build | ||
| * @param isQaChannel - QA / e2e / exp channel | ||
| */ | ||
| export function buildTypeMapping( | ||
| buildType: string, | ||
| isDev: boolean, | ||
| isQaChannel: boolean, | ||
| ): BUILD_TYPE { | ||
| if (process.env.DEV_OAUTH_CONFIG === 'true' && isDev) { | ||
| return BUILD_TYPE.development; | ||
| } | ||
|
|
||
| switch (buildType) { | ||
| case 'qa': | ||
| return BUILD_TYPE.main_uat; | ||
| case 'main': { | ||
| if (isQaChannel) return BUILD_TYPE.main_uat; | ||
| if (isDev) return BUILD_TYPE.main_dev; | ||
| return BUILD_TYPE.main_prod; | ||
| } | ||
| case 'flask': { | ||
| if (isQaChannel) return BUILD_TYPE.flask_uat; | ||
| if (isDev) return BUILD_TYPE.flask_dev; | ||
| return BUILD_TYPE.flask_prod; | ||
| } | ||
| default: | ||
| return BUILD_TYPE.development; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Resolves which {@link OAUTH_CONFIG} entry applies (env override or build mapping). | ||
| */ | ||
| export function resolveOAuthConfigKey(): keyof typeof OAUTH_CONFIG { | ||
| const fromEnv = process.env.OAUTH_BUILD_TYPE; | ||
| if ( | ||
| typeof fromEnv === 'string' && | ||
| fromEnv.length > 0 && | ||
| fromEnv in OAUTH_CONFIG | ||
| ) { | ||
| return fromEnv as keyof typeof OAUTH_CONFIG; | ||
| } | ||
|
|
||
| return buildTypeMapping( | ||
| AppConstants.METAMASK_BUILD_TYPE || 'main', | ||
| AppConstants.IS_DEV, | ||
| isQa, | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.