1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 13:23:34 +00:00

Auth/PM-13114 - WebEnvService Refactor + Unit Tests to support QA Env Selector (#11397)

* PM-13114 - WebEnvSvc - use hostname vs domain check for init and setEnv (tests TODO)

* PM-13114 - WebEnvSvc + URLs webpack config - use expected string variable on process.env.URLS to ensure tests can properly mock the WebEnvSvc

* PM-13114 - WebEnvSvc - setEnvironment - fix issue with returning currentRegion urls instead of currentEnv urls.

* PM-13114 - WebEnvSvc - setEnv - refactor names to improve clarity.

* PM-13114 - WebEnvSvc spec file - Test all prod scenarios

* PM-13144 - Work with Justin to move process.env.Urls access into injection token and remove webpack string type conversion.

* PM-13114 - WIP on getting additionalRegionConfigs injected via injection token to default env service.

* PM-13114 - Update all background inits to pass process.env.ADDITIONAL_REGIONS as unknown as RegionConfig[] to env service.

* PM-13114 - WebEnvSvc - adjust order of constructor deps

* PM-13114 - WebEnvSvc - add WebRegionConfig to extend RegionConfig type and be accurate for what the WebEnvSvc uses.

* PM-13114 - WebEnvSvc Tests - US QA tested

* PM-13114 - WebEnvSvc tests - refactor QA naming to make it more clear.

* PM-13114 - WebEnvSvc - test QA EU

* PM-13114 - WebEnvSvc - remove promise resolve per PR feedback.
This commit is contained in:
Jared Snider
2024-10-04 14:57:40 -04:00
committed by GitHub
parent e6ff647343
commit 87cb45c520
12 changed files with 560 additions and 33 deletions

View File

@@ -3,6 +3,7 @@ import { Observable, Subject } from "rxjs";
import { LogoutReason } from "@bitwarden/auth/common";
import { ClientType } from "@bitwarden/common/enums";
import { RegionConfig } from "@bitwarden/common/platform/abstractions/environment.service";
import {
AbstractStorageService,
ObservableStorageService,
@@ -58,3 +59,12 @@ export const CLIENT_TYPE = new SafeInjectionToken<ClientType>("CLIENT_TYPE");
export const REFRESH_ACCESS_TOKEN_ERROR_CALLBACK = new SafeInjectionToken<() => void>(
"REFRESH_ACCESS_TOKEN_ERROR_CALLBACK",
);
/**
* Injection token for injecting the NodeJS process.env additional regions into services.
* Using an injection token allows services to be tested without needing to
* mock the process.env.
*/
export const ENV_ADDITIONAL_REGIONS = new SafeInjectionToken<RegionConfig[]>(
"ENV_ADDITIONAL_REGIONS",
);

View File

@@ -141,7 +141,10 @@ import { ConfigService } from "@bitwarden/common/platform/abstractions/config/co
import { CryptoFunctionService as CryptoFunctionServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto-function.service";
import { CryptoService as CryptoServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import {
EnvironmentService,
RegionConfig,
} from "@bitwarden/common/platform/abstractions/environment.service";
import { FileUploadService as FileUploadServiceAbstraction } from "@bitwarden/common/platform/abstractions/file-upload/file-upload.service";
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
import { KeyGenerationService as KeyGenerationServiceAbstraction } from "@bitwarden/common/platform/abstractions/key-generation.service";
@@ -298,6 +301,7 @@ import {
INTRAPROCESS_MESSAGING_SUBJECT,
CLIENT_TYPE,
REFRESH_ACCESS_TOKEN_ERROR_CALLBACK,
ENV_ADDITIONAL_REGIONS,
} from "./injection-tokens";
import { ModalService } from "./modal.service";
@@ -530,10 +534,14 @@ const safeProviders: SafeProvider[] = [
useClass: CollectionService,
deps: [CryptoServiceAbstraction, EncryptService, I18nServiceAbstraction, StateProvider],
}),
safeProvider({
provide: ENV_ADDITIONAL_REGIONS,
useValue: process.env.ADDITIONAL_REGIONS as unknown as RegionConfig[],
}),
safeProvider({
provide: EnvironmentService,
useClass: DefaultEnvironmentService,
deps: [StateProvider, AccountServiceAbstraction],
deps: [StateProvider, AccountServiceAbstraction, ENV_ADDITIONAL_REGIONS],
}),
safeProvider({
provide: InternalUserDecryptionOptionsServiceAbstraction,