-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: seedless existing user e2e test #28855
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
base: main
Are you sure you want to change the base?
Changes from 19 commits
ba17afe
ae192c6
1bee392
790758e
75aa2c2
dbf37d2
577bdeb
981644d
5fb19bf
e6160df
45112da
e3e8264
7b7e425
f83be06
c3b1f3f
b80d00f
cff8545
15fba65
6a43546
91f5fbf
ce319ed
ab92f1d
7a6b194
9e7657f
b8a5299
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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> | ||
| 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); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| 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': | ||
| return isQaChannel | ||
| ? BUILD_TYPE.main_uat | ||
| : isDev | ||
| ? BUILD_TYPE.main_dev | ||
| : BUILD_TYPE.main_prod; | ||
|
Check warning on line 28 in app/core/OAuthService/OAuthLoginHandlers/oauthBuildType.ts
|
||
| case 'flask': | ||
| return isQaChannel | ||
| ? BUILD_TYPE.flask_uat | ||
| : isDev | ||
| ? BUILD_TYPE.flask_dev | ||
| : BUILD_TYPE.flask_prod; | ||
|
Check warning on line 34 in app/core/OAuthService/OAuthLoginHandlers/oauthBuildType.ts
|
||
| 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, | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.