Skip to content

Commit f6de756

Browse files
committed
Move emulator tests (#7318)
1 parent c8d2ef2 commit f6de756

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+141
-155
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
],
9393
"exclude": [
9494
"src/**/*.spec.*",
95+
"src/**/testing/**/*",
9596
"src/test/**/*"
9697
]
9798
},

scripts/emulator-tests/functionsEmulator.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as logform from "logform";
1212
import { EmulatedTriggerDefinition } from "../../src/emulator/functionsEmulatorShared";
1313
import { EmulatableBackend, FunctionsEmulator } from "../../src/emulator/functionsEmulator";
1414
import { EmulatorInfo, Emulators } from "../../src/emulator/types";
15-
import { FakeEmulator } from "../../src/test/emulators/fakeEmulator";
15+
import { FakeEmulator } from "../../src/emulator/testing/fakeEmulator";
1616
import { TIMEOUT_LONG, TIMEOUT_MED, MODULE_ROOT } from "./fixtures";
1717
import { logger } from "../../src/logger";
1818
import * as registry from "../../src/emulator/registry";

scripts/storage-emulator-integration/conformance/firebase-js-sdk.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getStorage } from "firebase-admin/storage";
66
import * as fs from "fs";
77
import * as puppeteer from "puppeteer";
88
import { TEST_ENV } from "./env";
9-
import { IMAGE_FILE_BASE64 } from "../../../src/test/emulators/fixtures";
9+
import { IMAGE_FILE_BASE64 } from "../../../src/emulator/testing/fixtures";
1010
import { EmulatorEndToEndTest } from "../../integration-helpers/framework";
1111
import {
1212
createRandomFile,

scripts/storage-emulator-integration/import/tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as fs from "fs-extra";
33
import { expect } from "chai";
44
import supertest = require("supertest");
55

6-
import { createTmpDir } from "../../../src/test/emulators/fixtures";
6+
import { createTmpDir } from "../../../src/emulator/testing/fixtures";
77
import { Emulators } from "../../../src/emulator/types";
88
import { TriggerEndToEndTest } from "../../integration-helpers/framework";
99
import {

scripts/storage-emulator-integration/internal/tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
22
import * as supertest from "supertest";
3-
import { StorageRulesFiles } from "../../../src/test/emulators/fixtures";
3+
import { StorageRulesFiles } from "../../../src/emulator/testing/fixtures";
44
import { TriggerEndToEndTest } from "../../integration-helpers/framework";
55
import {
66
EMULATORS_SHUTDOWN_DELAY_MS,

scripts/storage-emulator-integration/rules/manager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
22

3-
import { createTmpDir, StorageRulesFiles } from "../../../src/test/emulators/fixtures";
3+
import { createTmpDir, StorageRulesFiles } from "../../../src/emulator/testing/fixtures";
44
import { createStorageRulesManager } from "../../../src/emulator/storage/rules/manager";
55
import { StorageRulesRuntime } from "../../../src/emulator/storage/rules/runtime";
66
import * as fs from "fs";

src/test/emulators/adminSdkConfig.test.ts renamed to src/emulator/adminSdkConfig.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import { getProjectAdminSdkConfigOrCached } from "../../emulator/adminSdkConfig";
2+
import { getProjectAdminSdkConfigOrCached } from "./adminSdkConfig";
33

44
describe("adminSdkConfig", () => {
55
describe("getProjectAdminSdkConfigOrCached", () => {

src/test/emulators/auth/batch.spec.ts renamed to src/emulator/auth/batch.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
22
import { decode as decodeJwt } from "jsonwebtoken";
3-
import { describeAuthEmulator } from "./setup";
3+
import { describeAuthEmulator } from "./testing/setup";
44
import {
55
enrollPhoneMfa,
66
expectStatusCode,
@@ -17,8 +17,8 @@ import {
1717
TEST_PHONE_NUMBER,
1818
updateAccountByLocalId,
1919
registerTenant,
20-
} from "./helpers";
21-
import { UserInfo } from "../../../emulator/auth/state";
20+
} from "./testing/helpers";
21+
import { UserInfo } from "./state";
2222

2323
describeAuthEmulator("accounts:batchGet", ({ authApi }) => {
2424
it("should allow listing all accounts", async () => {

src/test/emulators/auth/cloudFunctions.spec.ts renamed to src/emulator/auth/cloudFunctions.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { expect } from "chai";
22
import * as nock from "nock";
33

4-
import { AuthCloudFunction } from "../../../emulator/auth/cloudFunctions";
5-
import { EmulatorRegistry } from "../../../emulator/registry";
6-
import { Emulators } from "../../../emulator/types";
7-
import { FakeEmulator } from "../fakeEmulator";
4+
import { AuthCloudFunction } from "./cloudFunctions";
5+
import { EmulatorRegistry } from "../registry";
6+
import { Emulators } from "../types";
7+
import { FakeEmulator } from "../testing/fakeEmulator";
88

99
describe("cloudFunctions", () => {
1010
describe("dispatch", () => {

src/test/emulators/auth/config.spec.ts renamed to src/emulator/auth/config.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
2-
import { expectStatusCode } from "./helpers";
3-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
2+
import { expectStatusCode } from "./testing/helpers";
3+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
44

55
describeAuthEmulator("config management", ({ authApi }) => {
66
describe("updateConfig", () => {

src/test/emulators/auth/createAuthUri.spec.ts renamed to src/emulator/auth/createAuthUri.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
2-
import { PROVIDER_PASSWORD, SIGNIN_METHOD_EMAIL_LINK } from "../../../emulator/auth/state";
3-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
2+
import { PROVIDER_PASSWORD, SIGNIN_METHOD_EMAIL_LINK } from "./state";
3+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
44
import {
55
expectStatusCode,
66
registerUser,
@@ -9,7 +9,7 @@ import {
99
updateProjectConfig,
1010
registerTenant,
1111
updateConfig,
12-
} from "./helpers";
12+
} from "./testing/helpers";
1313

1414
describeAuthEmulator("accounts:createAuthUri", ({ authApi }) => {
1515
it("should report not registered user as not registered", async () => {

src/test/emulators/auth/customToken.spec.ts renamed to src/emulator/auth/customToken.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { expect } from "chai";
22
import { decode as decodeJwt, sign as signJwt, JwtHeader } from "jsonwebtoken";
3-
import { FirebaseJwtPayload, CUSTOM_TOKEN_AUDIENCE } from "../../../emulator/auth/operations";
4-
import { PROVIDER_CUSTOM } from "../../../emulator/auth/state";
5-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
3+
import { FirebaseJwtPayload, CUSTOM_TOKEN_AUDIENCE } from "./operations";
4+
import { PROVIDER_CUSTOM } from "./state";
5+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
66
import {
77
expectStatusCode,
88
getAccountInfoByIdToken,
99
updateAccountByLocalId,
1010
signInWithEmailLink,
1111
registerTenant,
12-
} from "./helpers";
12+
} from "./testing/helpers";
1313

1414
describeAuthEmulator("sign-in with custom token", ({ authApi }) => {
1515
it("should create new account from custom token (unsigned)", async () => {

src/test/emulators/auth/deleteAccount.spec.ts renamed to src/emulator/auth/deleteAccount.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { expect } from "chai";
2-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
2+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
33
import {
44
expectStatusCode,
55
registerUser,
66
signInWithFakeClaims,
77
getSigninMethods,
88
expectUserNotExistsForIdToken,
99
registerTenant,
10-
} from "./helpers";
10+
} from "./testing/helpers";
1111

1212
describeAuthEmulator("accounts:delete", ({ authApi }) => {
1313
it("should delete the user of the idToken", async () => {

src/test/emulators/auth/emailLink.spec.ts renamed to src/emulator/auth/emailLink.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect } from "chai";
22
import * as nock from "nock";
33
import { decode as decodeJwt, JwtHeader } from "jsonwebtoken";
4-
import { FirebaseJwtPayload, parseBlockingFunctionJwt } from "../../../emulator/auth/operations";
5-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
4+
import { FirebaseJwtPayload, parseBlockingFunctionJwt } from "./operations";
5+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
66
import {
77
expectStatusCode,
88
registerUser,
@@ -23,7 +23,7 @@ import {
2323
BEFORE_SIGN_IN_URL,
2424
DISPLAY_NAME,
2525
PHOTO_URL,
26-
} from "./helpers";
26+
} from "./testing/helpers";
2727

2828
describeAuthEmulator("email link sign-in", ({ authApi }) => {
2929
it("should send OOB code to new emails and create account on sign-in", async () => {

src/test/emulators/auth/idp.spec.ts renamed to src/emulator/auth/idp.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { expect } from "chai";
22
import * as nock from "nock";
33
import { decode as decodeJwt, JwtHeader } from "jsonwebtoken";
4-
import { FirebaseJwtPayload } from "../../../emulator/auth/operations";
5-
import { PROVIDER_PASSWORD, SIGNIN_METHOD_EMAIL_LINK } from "../../../emulator/auth/state";
6-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
4+
import { FirebaseJwtPayload } from "./operations";
5+
import { PROVIDER_PASSWORD, SIGNIN_METHOD_EMAIL_LINK } from "./state";
6+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
77
import {
88
expectStatusCode,
99
getAccountInfoByIdToken,
@@ -30,7 +30,7 @@ import {
3030
BLOCKING_FUNCTION_HOST,
3131
DISPLAY_NAME,
3232
PHOTO_URL,
33-
} from "./helpers";
33+
} from "./testing/helpers";
3434

3535
// Many JWT fields from IDPs use snake_case and we need to match that.
3636

src/test/emulators/auth/mfa.spec.ts renamed to src/emulator/auth/mfa.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
22
import * as nock from "nock";
3-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
3+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
44
import { decode as decodeJwt, JwtHeader } from "jsonwebtoken";
55
import {
66
BEFORE_SIGN_IN_PATH,
@@ -23,9 +23,9 @@ import {
2323
TEST_PHONE_NUMBER_OBFUSCATED,
2424
updateAccountByLocalId,
2525
updateConfig,
26-
} from "./helpers";
27-
import { MfaEnrollment } from "../../../emulator/auth/types";
28-
import { FirebaseJwtPayload } from "../../../emulator/auth/operations";
26+
} from "./testing/helpers";
27+
import { MfaEnrollment } from "./types";
28+
import { FirebaseJwtPayload } from "./operations";
2929

3030
describeAuthEmulator("mfa enrollment", ({ authApi, getClock }) => {
3131
it("should error if account does not have email verified", async () => {

src/test/emulators/auth/misc.spec.ts renamed to src/emulator/auth/misc.spec.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
11
import { expect } from "chai";
22
import { decode as decodeJwt, JwtHeader } from "jsonwebtoken";
3-
import {
4-
decodeRefreshToken,
5-
encodeRefreshToken,
6-
RefreshTokenRecord,
7-
UserInfo,
8-
} from "../../../emulator/auth/state";
3+
import { decodeRefreshToken, encodeRefreshToken, RefreshTokenRecord, UserInfo } from "./state";
94
import {
105
getAccountInfoByIdToken,
116
PROJECT_ID,
127
registerTenant,
138
signInWithPhoneNumber,
149
TEST_PHONE_NUMBER,
15-
} from "./helpers";
16-
import { describeAuthEmulator } from "./setup";
10+
} from "./testing/helpers";
11+
import { describeAuthEmulator } from "./testing/setup";
1712
import {
1813
deleteAccount,
1914
expectStatusCode,
2015
registerUser,
2116
registerAnonUser,
2217
updateAccountByLocalId,
2318
expectUserNotExistsForIdToken,
24-
} from "./helpers";
25-
import {
26-
FirebaseJwtPayload,
27-
SESSION_COOKIE_MAX_VALID_DURATION,
28-
} from "../../../emulator/auth/operations";
29-
import { toUnixTimestamp } from "../../../emulator/auth/utils";
30-
import { SingleProjectMode } from "../../../emulator/auth";
19+
} from "./testing/helpers";
20+
import { FirebaseJwtPayload, SESSION_COOKIE_MAX_VALID_DURATION } from "./operations";
21+
import { toUnixTimestamp } from "./utils";
22+
import { SingleProjectMode } from ".";
3123

3224
describeAuthEmulator("token refresh", ({ authApi, getClock }) => {
3325
it("should exchange refresh token for new tokens", async () => {

src/test/emulators/auth/oob.spec.ts renamed to src/emulator/auth/oob.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
2+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
33
import {
44
expectStatusCode,
55
registerUser,
@@ -9,7 +9,7 @@ import {
99
inspectOobs,
1010
registerTenant,
1111
updateConfig,
12-
} from "./helpers";
12+
} from "./testing/helpers";
1313

1414
describeAuthEmulator("accounts:sendOobCode", ({ authApi, getClock }) => {
1515
it("should generate OOB code for verify email", async () => {

src/test/emulators/auth/password.spec.ts renamed to src/emulator/auth/password.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect } from "chai";
22
import * as nock from "nock";
33
import { decode as decodeJwt, JwtHeader } from "jsonwebtoken";
4-
import { FirebaseJwtPayload } from "../../../emulator/auth/operations";
5-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
4+
import { FirebaseJwtPayload } from "./operations";
5+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
66
import {
77
BEFORE_SIGN_IN_PATH,
88
BEFORE_SIGN_IN_URL,
@@ -16,7 +16,7 @@ import {
1616
TEST_MFA_INFO,
1717
updateAccountByLocalId,
1818
updateConfig,
19-
} from "./helpers";
19+
} from "./testing/helpers";
2020

2121
describeAuthEmulator("accounts:signInWithPassword", ({ authApi, getClock }) => {
2222
it("should issue tokens when email and password are valid", async () => {

src/test/emulators/auth/phone.spec.ts renamed to src/emulator/auth/phone.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect } from "chai";
22
import * as nock from "nock";
33
import { decode as decodeJwt, JwtHeader } from "jsonwebtoken";
4-
import { FirebaseJwtPayload } from "../../../emulator/auth/operations";
5-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
4+
import { FirebaseJwtPayload } from "./operations";
5+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
66
import {
77
expectStatusCode,
88
registerAnonUser,
@@ -23,7 +23,7 @@ import {
2323
PHOTO_URL,
2424
BEFORE_SIGN_IN_PATH,
2525
BEFORE_SIGN_IN_URL,
26-
} from "./helpers";
26+
} from "./testing/helpers";
2727

2828
describeAuthEmulator("phone auth sign-in", ({ authApi }) => {
2929
it("should return fake recaptcha params", async () => {

src/test/emulators/auth/rest.spec.ts renamed to src/emulator/auth/rest.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
2-
import { expectStatusCode, registerTenant, registerUser } from "./helpers";
3-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
2+
import { expectStatusCode, registerTenant, registerUser } from "./testing/helpers";
3+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
44

55
describeAuthEmulator("REST API mapping", ({ authApi }) => {
66
it("should respond to status checks", async () => {

src/test/emulators/auth/setAccountInfo.spec.ts renamed to src/emulator/auth/setAccountInfo.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect } from "chai";
22
import { decode as decodeJwt, JwtHeader } from "jsonwebtoken";
3-
import { FirebaseJwtPayload } from "../../../emulator/auth/operations";
4-
import { ProviderUserInfo, PROVIDER_PASSWORD, PROVIDER_PHONE } from "../../../emulator/auth/state";
5-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
3+
import { FirebaseJwtPayload } from "./operations";
4+
import { ProviderUserInfo, PROVIDER_PASSWORD, PROVIDER_PHONE } from "./state";
5+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
66
import {
77
expectStatusCode,
88
getAccountInfoByIdToken,
@@ -21,7 +21,7 @@ import {
2121
TEST_PHONE_NUMBER_3,
2222
TEST_INVALID_PHONE_NUMBER,
2323
registerTenant,
24-
} from "./helpers";
24+
} from "./testing/helpers";
2525

2626
describeAuthEmulator("accounts:update", ({ authApi, getClock }) => {
2727
it("should allow updating and deleting displayName and photoUrl", async () => {

src/test/emulators/auth/signUp.spec.ts renamed to src/emulator/auth/signUp.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect } from "chai";
22
import * as nock from "nock";
33
import { decode as decodeJwt, JwtHeader } from "jsonwebtoken";
4-
import { FirebaseJwtPayload } from "../../../emulator/auth/operations";
5-
import { describeAuthEmulator, PROJECT_ID } from "./setup";
4+
import { FirebaseJwtPayload } from "./operations";
5+
import { describeAuthEmulator, PROJECT_ID } from "./testing/setup";
66
import {
77
expectStatusCode,
88
getAccountInfoByIdToken,
@@ -26,7 +26,7 @@ import {
2626
BEFORE_SIGN_IN_PATH,
2727
DISPLAY_NAME,
2828
PHOTO_URL,
29-
} from "./helpers";
29+
} from "./testing/helpers";
3030

3131
describeAuthEmulator("accounts:signUp", ({ authApi }) => {
3232
it("should throw error if no email provided", async () => {

src/test/emulators/auth/tenant.spec.ts renamed to src/emulator/auth/tenant.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from "chai";
2-
import { Tenant } from "../../../emulator/auth/state";
3-
import { expectStatusCode, registerTenant } from "./helpers";
4-
import { describeAuthEmulator } from "./setup";
2+
import { Tenant } from "./state";
3+
import { expectStatusCode, registerTenant } from "./testing/helpers";
4+
import { describeAuthEmulator } from "./testing/setup";
55

66
describeAuthEmulator("tenant management", ({ authApi }) => {
77
describe("createTenant", () => {

src/test/emulators/auth/helpers.ts renamed to src/emulator/auth/testing/helpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { STATUS_CODES } from "http";
22
import { inspect } from "util";
33
import * as supertest from "supertest";
44
import { expect, AssertionError } from "chai";
5-
import { IdpJwtPayload } from "../../../emulator/auth/operations";
6-
import { OobRecord, PhoneVerificationRecord, Tenant, UserInfo } from "../../../emulator/auth/state";
5+
import { IdpJwtPayload } from "../operations";
6+
import { OobRecord, PhoneVerificationRecord, Tenant, UserInfo } from "../state";
77
import { TestAgent, PROJECT_ID } from "./setup";
8-
import { MfaEnrollment, MfaEnrollments, Schemas } from "../../../emulator/auth/types";
8+
import { MfaEnrollment, MfaEnrollments, Schemas } from "../types";
99

1010
export { PROJECT_ID };
1111
export const TEST_PHONE_NUMBER = "+15555550100";

0 commit comments

Comments
 (0)