Skip to content

Commit bb344c2

Browse files
committed
test(identity): update the identity mocks to adapt to the Env changes
Signed-off-by: Mircea Nistor <mirceanis@gmail.com>
1 parent 99bd385 commit bb344c2

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
"attributions:generate": "./development/generate-attributions.sh"
130130
},
131131
"resolutions": {
132-
"@metamask/profile-sync-controller": "npm:@metamask-previews/profile-sync-controller@21.0.0-preview-91d59c3",
132+
"@metamask/profile-sync-controller": "npm:@metamask-previews/profile-sync-controller@21.0.0-preview-34e39226",
133133
"http-cache-semantics": "^4.1.1",
134134
"semver-regex": "^3.1.4",
135135
"base-x@^3.0.x": "^3.0.11",

privacy-snapshot.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"app.ens.domains",
1313
"arbitrum-mainnet.infura.io",
1414
"auth-service.dev-api.cx.metamask.io",
15-
"authentication.api.cx.metamask.io",
15+
"authentication.dev-api.cx.metamask.io",
1616
"bafkreifvhjdf6ve4jfv6qytqtux5nd4nwnelioeiqx5x2ez5yrgrzk7ypi.ipfs.dweb.link",
1717
"bafybeidxfmwycgzcp4v2togflpqh2gnibuexjy4m4qqwxp7nh3jx5zlh4y.ipfs.dweb.link",
1818
"base-mainnet.infura.io",
@@ -65,7 +65,7 @@
6565
"node-4.dev-node.web3auth.io",
6666
"node-5.dev-node.web3auth.io",
6767
"notification.api.cx.metamask.io",
68-
"oidc.api.cx.metamask.io",
68+
"oidc.dev-api.cx.metamask.io",
6969
"on-ramp-content.api.cx.metamask.io",
7070
"on-ramp-content.uat-api.cx.metamask.io",
7171
"phishing-detection.api.cx.metamask.io",
@@ -102,7 +102,7 @@
102102
"tx-sentinel-ethereum-mainnet.api.cx.metamask.io",
103103
"unresponsive-rpc.test",
104104
"unresponsive-rpc.url",
105-
"user-storage.api.cx.metamask.io",
105+
"user-storage.dev-api.cx.metamask.io",
106106
"verify.walletconnect.com",
107107
"www.4byte.directory"
108108
]

test/e2e/tests/identity/mocks.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { Mockttp, RequestRuleBuilder } from 'mockttp';
22
import { AuthenticationController } from '@metamask/profile-sync-controller';
3-
import { USER_STORAGE_FEATURE_NAMES } from '@metamask/profile-sync-controller/sdk';
3+
import {
4+
Env,
5+
USER_STORAGE_FEATURE_NAMES,
6+
} from '@metamask/profile-sync-controller/sdk';
47
import {
58
UserStorageMockttpController,
69
UserStorageResponseData,
@@ -12,22 +15,26 @@ type MockResponse = {
1215
url: string | RegExp;
1316
requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE';
1417
response: unknown;
18+
statusCode?: number;
1519
};
1620

1721
/**
1822
* E2E mock setup for identity APIs (Auth, UserStorage, Backup and sync)
1923
*
2024
* @param server - server obj used to mock our endpoints
2125
* @param userStorageMockttpControllerInstance - optional instance of UserStorageMockttpController, useful if you need persisted user storage between tests
26+
* @param env - optional environment (defaults to Env.DEV)
2227
*/
2328
export async function mockIdentityServices(
2429
server: Mockttp,
2530
userStorageMockttpControllerInstance: UserStorageMockttpController = new UserStorageMockttpController(),
31+
env: Env = Env.DEV,
2632
) {
2733
// Auth
28-
mockAPICall(server, AuthMocks.getMockAuthNonceResponse());
29-
mockAPICall(server, AuthMocks.getMockAuthLoginResponse());
30-
mockAPICall(server, AuthMocks.getMockAuthAccessTokenResponse());
34+
mockAPICall(server, AuthMocks.getMockAuthNonceResponse(env));
35+
mockAPICall(server, AuthMocks.getMockAuthLoginResponse(env));
36+
mockAPICall(server, AuthMocks.getMockAuthAccessTokenResponse(env));
37+
mockAPICall(server, AuthMocks.getMockPairSocialTokenResponse(env));
3138

3239
// Storage
3340
if (
@@ -114,7 +121,7 @@ function mockAPICall(server: Mockttp, response: MockResponse) {
114121
)(requestBody, path, getE2ESrpIdentifierForPublicKey);
115122

116123
return {
117-
statusCode: 200,
124+
statusCode: response.statusCode ?? 200,
118125
json,
119126
};
120127
});
@@ -123,6 +130,7 @@ function mockAPICall(server: Mockttp, response: MockResponse) {
123130
type MockInfuraAndAccountSyncOptions = {
124131
accountsToMockBalances?: string[];
125132
accountsSyncResponse?: UserStorageResponseData[];
133+
env?: Env;
126134
};
127135

128136
const MOCK_ETH_BALANCE = '0xde0b6b3a7640000';
@@ -177,7 +185,11 @@ export async function mockInfuraAndAccountSync(
177185
});
178186
}
179187

180-
mockIdentityServices(mockServer, userStorageMockttpController);
188+
await mockIdentityServices(
189+
mockServer,
190+
userStorageMockttpController,
191+
options.env ?? Env.DEV,
192+
);
181193
}
182194

183195
/**

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7073,9 +7073,9 @@ __metadata:
70737073
languageName: node
70747074
linkType: hard
70757075

7076-
"@metamask/profile-sync-controller@npm:@metamask-previews/profile-sync-controller@21.0.0-preview-91d59c3":
7077-
version: 21.0.0-preview-91d59c3
7078-
resolution: "@metamask-previews/profile-sync-controller@npm:21.0.0-preview-91d59c3"
7076+
"@metamask/profile-sync-controller@npm:@metamask-previews/profile-sync-controller@21.0.0-preview-34e39226":
7077+
version: 21.0.0-preview-34e39226
7078+
resolution: "@metamask-previews/profile-sync-controller@npm:21.0.0-preview-34e39226"
70797079
dependencies:
70807080
"@metamask/base-controller": "npm:^8.0.1"
70817081
"@metamask/snaps-sdk": "npm:^9.0.0"
@@ -7092,7 +7092,7 @@ __metadata:
70927092
"@metamask/seedless-onboarding-controller": ^2.1.0
70937093
"@metamask/snaps-controllers": ^14.0.0
70947094
webextension-polyfill: ^0.10.0 || ^0.11.0 || ^0.12.0
7095-
checksum: 10/4fb18215ad06ef6a2676835ee4c8ad2093e176c4ec674f7e5f8f16a5423225df827c291c260df92d3a0090363885142650c9b934b45a657727a104d9c2e632fe
7095+
checksum: 10/4ec53e7eeca1bcce0adb74c85b8048b4406b208779623ac90352649f54c8b2c0e6e9de8d09c7b0837f2b44acad598d1254953ffd51ed0f3890a5bbc9458efb81
70967096
languageName: node
70977097
linkType: hard
70987098

0 commit comments

Comments
 (0)