From 85a30a240b0b51e4550ff4c5ec57ad7534bbf5ca Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Tue, 11 Aug 2020 21:27:37 -0700 Subject: [PATCH 1/2] Remove trusted notebooks experiment --- package.json | 4 +--- src/client/common/experiments/groups.ts | 5 ----- .../interactiveWindowTypes.ts | 1 - .../interactive-ipynb/nativeEditor.ts | 5 +---- .../interactive-ipynb/trustCommandHandler.ts | 4 ---- .../interactive-ipynb/trustService.ts | 19 +++++-------------- .../interactive-common/jupyterInfo.tsx | 16 +++++++--------- .../interactive-common/mainState.ts | 4 +--- .../interactive-common/redux/store.ts | 3 +-- .../native-editor/nativeEditor.tsx | 7 +------ .../native-editor/redux/reducers/creation.ts | 3 +-- src/datascience-ui/native-editor/toolbar.tsx | 3 +-- src/test/datascience/.vscode/settings.json | 3 +-- .../datascience/dataScienceIocContainer.ts | 3 +-- .../trustCommandHandler.unit.test.ts | 14 -------------- .../trustService.unit.test.ts | 6 +----- .../interactivePanel.functional.test.tsx | 3 +-- .../nativeEditor.toolbar.functional.test.tsx | 6 ++---- .../trustedNotebooks.functional.test.tsx | 2 -- 19 files changed, 25 insertions(+), 86 deletions(-) diff --git a/package.json b/package.json index d8137549b7e6..cea37d9ab5ca 100644 --- a/package.json +++ b/package.json @@ -2069,7 +2069,6 @@ "CollectNodeLSRequestTiming - experiment", "DeprecatePythonPath - experiment", "RunByLine - experiment", - "EnableTrustedNotebooks", "tryPylance", "All" ] @@ -2094,7 +2093,6 @@ "CollectNodeLSRequestTiming - experiment", "DeprecatePythonPath - experiment", "RunByLine - experiment", - "EnableTrustedNotebooks", "tryPylance", "All" ] @@ -3759,4 +3757,4 @@ "publisherDisplayName": "Microsoft", "publisherId": "998b010b-e2af-44a5-a6cd-0b5fd3b9b6f8" } -} \ No newline at end of file +} diff --git a/src/client/common/experiments/groups.ts b/src/client/common/experiments/groups.ts index 6a01a3a7e46a..759c40b33af2 100644 --- a/src/client/common/experiments/groups.ts +++ b/src/client/common/experiments/groups.ts @@ -87,11 +87,6 @@ export enum RemoveKernelToolbarInInteractiveWindow { experiment = 'RemoveKernelToolbarInInteractiveWindow' } -// Experiment to turn on trusted notebooks checks -export enum EnableTrustedNotebooks { - experiment = 'EnableTrustedNotebooks' -} - // Experiment to offer switch to Pylance language server export enum TryPylance { experiment = 'tryPylance' diff --git a/src/client/datascience/interactive-common/interactiveWindowTypes.ts b/src/client/datascience/interactive-common/interactiveWindowTypes.ts index c3b9d48af90b..40157d7873f9 100644 --- a/src/client/datascience/interactive-common/interactiveWindowTypes.ts +++ b/src/client/datascience/interactive-common/interactiveWindowTypes.ts @@ -343,7 +343,6 @@ export interface IRefreshVariablesRequest { export interface ILoadAllCells { cells: ICell[]; isNotebookTrusted?: boolean; - shouldShowTrustMessage?: boolean; } export interface IScrollToCell { diff --git a/src/client/datascience/interactive-ipynb/nativeEditor.ts b/src/client/datascience/interactive-ipynb/nativeEditor.ts index e002a92f6ec5..751bd5ff2099 100644 --- a/src/client/datascience/interactive-ipynb/nativeEditor.ts +++ b/src/client/datascience/interactive-ipynb/nativeEditor.ts @@ -84,7 +84,6 @@ import cloneDeep = require('lodash/cloneDeep'); import { concatMultilineString, splitMultilineString } from '../../../datascience-ui/common'; import { ServerStatus } from '../../../datascience-ui/interactive-common/mainState'; import { isTestExecution, PYTHON_LANGUAGE } from '../../common/constants'; -import { EnableTrustedNotebooks } from '../../common/experiments/groups'; import { translateKernelLanguageToMonaco } from '../common'; import { IDataViewerFactory } from '../data-viewing/types'; import { getCellHashProvider } from '../editor-integration/cellhashprovider'; @@ -699,11 +698,9 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor { private async sendInitialCellsToWebView(cells: ICell[], isNotebookTrusted: boolean): Promise { sendTelemetryEvent(Telemetry.CellCount, undefined, { count: cells.length }); - const shouldShowTrustMessage = await this.expService.inExperiment(EnableTrustedNotebooks.experiment); return this.postMessage(InteractiveWindowMessages.LoadAllCells, { cells, - isNotebookTrusted, - shouldShowTrustMessage + isNotebookTrusted }); } diff --git a/src/client/datascience/interactive-ipynb/trustCommandHandler.ts b/src/client/datascience/interactive-ipynb/trustCommandHandler.ts index 12aec409f0ff..943785985dbc 100644 --- a/src/client/datascience/interactive-ipynb/trustCommandHandler.ts +++ b/src/client/datascience/interactive-ipynb/trustCommandHandler.ts @@ -8,7 +8,6 @@ import { commands, Uri } from 'vscode'; import { IExtensionSingleActivationService } from '../../activation/types'; import { IApplicationShell, ICommandManager } from '../../common/application/types'; import { ContextKey } from '../../common/contextKey'; -import { EnableTrustedNotebooks } from '../../common/experiments/groups'; import '../../common/extensions'; import { IDisposableRegistry, IExperimentService } from '../../common/types'; import { swallowExceptions } from '../../common/utils/decorators'; @@ -33,9 +32,6 @@ export class TrustCommandHandler implements IExtensionSingleActivationService { this.activateInBackground().ignoreErrors(); } public async activateInBackground(): Promise { - if (!(await this.experiments.inExperiment(EnableTrustedNotebooks.experiment))) { - return; - } const context = new ContextKey('python.datascience.trustfeatureenabled', this.commandManager); context.set(true).ignoreErrors(); this.disposables.push(this.commandManager.registerCommand(Commands.TrustNotebook, this.onTrustNotebook, this)); diff --git a/src/client/datascience/interactive-ipynb/trustService.ts b/src/client/datascience/interactive-ipynb/trustService.ts index 47380d9c23ee..3b5516cb2e8f 100644 --- a/src/client/datascience/interactive-ipynb/trustService.ts +++ b/src/client/datascience/interactive-ipynb/trustService.ts @@ -1,8 +1,7 @@ import { createHmac } from 'crypto'; import { inject, injectable } from 'inversify'; import { EventEmitter, Uri } from 'vscode'; -import { EnableTrustedNotebooks } from '../../common/experiments/groups'; -import { IConfigurationService, IExperimentService } from '../../common/types'; +import { IConfigurationService } from '../../common/types'; import { IDigestStorage, ITrustService } from '../types'; @injectable() @@ -14,14 +13,10 @@ export class TrustService implements ITrustService { return this.configService.getSettings().datascience.alwaysTrustNotebooks; } protected readonly _onDidSetNotebookTrust = new EventEmitter(); - private enabled: Promise; constructor( - @inject(IExperimentService) private readonly experimentService: IExperimentService, @inject(IDigestStorage) private readonly digestStorage: IDigestStorage, @inject(IConfigurationService) private configService: IConfigurationService - ) { - this.enabled = this.isInExperiment(); - } + ) {} /** * When a notebook is opened, we check the database to see if a trusted checkpoint @@ -31,8 +26,8 @@ export class TrustService implements ITrustService { * markdown will be rendered until notebook as a whole is marked trusted */ public async isNotebookTrusted(uri: Uri, notebookContents: string) { - if (this.alwaysTrustNotebooks || !(await this.enabled)) { - return true; // Skip check if user manually overrode our trust checking, or if user is not in experiment + if (this.alwaysTrustNotebooks) { + return true; // Skip check if user manually overrode our trust checking } // Compute digest and see if notebook is trusted const digest = await this.computeDigest(notebookContents); @@ -45,7 +40,7 @@ export class TrustService implements ITrustService { * I.e. if the notebook has already been trusted by the user */ public async trustNotebook(uri: Uri, notebookContents: string) { - if (!this.alwaysTrustNotebooks && (await this.enabled)) { + if (!this.alwaysTrustNotebooks) { // Only update digest store if the user wants us to check trust const digest = await this.computeDigest(notebookContents); await this.digestStorage.saveDigest(uri, digest); @@ -58,8 +53,4 @@ export class TrustService implements ITrustService { hmac.update(notebookContents); return hmac.digest('hex'); } - - private async isInExperiment() { - return this.experimentService.inExperiment(EnableTrustedNotebooks.experiment); - } } diff --git a/src/datascience-ui/interactive-common/jupyterInfo.tsx b/src/datascience-ui/interactive-common/jupyterInfo.tsx index be4fa975691d..f3a771faa337 100644 --- a/src/datascience-ui/interactive-common/jupyterInfo.tsx +++ b/src/datascience-ui/interactive-common/jupyterInfo.tsx @@ -94,15 +94,13 @@ export class JupyterInfo extends React.Component { } private renderTrustMessage() { - if (this.props.shouldShowTrustMessage) { - return ( - - ); - } + return ( + + ); } private selectKernel() { diff --git a/src/datascience-ui/interactive-common/mainState.ts b/src/datascience-ui/interactive-common/mainState.ts index 7f261834e21a..250831ac5c3a 100644 --- a/src/datascience-ui/interactive-common/mainState.ts +++ b/src/datascience-ui/interactive-common/mainState.ts @@ -90,7 +90,6 @@ export type IMainState = { loaded: boolean; kernel: IServerState; isNotebookTrusted: boolean; - shouldShowTrustMessage: boolean; }; export type SelectionAndFocusedInfo = { @@ -198,8 +197,7 @@ export function generateTestState(filePath: string = '', editable: boolean = fal jupyterServerStatus: ServerStatus.NotStarted, language: PYTHON_LANGUAGE }, - isNotebookTrusted: true, - shouldShowTrustMessage: true + isNotebookTrusted: true }; } diff --git a/src/datascience-ui/interactive-common/redux/store.ts b/src/datascience-ui/interactive-common/redux/store.ts index 29b76b722420..133e19bec405 100644 --- a/src/datascience-ui/interactive-common/redux/store.ts +++ b/src/datascience-ui/interactive-common/redux/store.ts @@ -74,8 +74,7 @@ function generateDefaultState( }, settings: testMode ? getDefaultSettings() : undefined, // When testing, we don't send (or wait) for the real settings. editorOptions: testMode ? computeEditorOptions(getDefaultSettings()) : undefined, - isNotebookTrusted: true, - shouldShowTrustMessage: false + isNotebookTrusted: true }; } } diff --git a/src/datascience-ui/native-editor/nativeEditor.tsx b/src/datascience-ui/native-editor/nativeEditor.tsx index ff03e0e75665..96b1bd0fcd4d 100644 --- a/src/datascience-ui/native-editor/nativeEditor.tsx +++ b/src/datascience-ui/native-editor/nativeEditor.tsx @@ -126,12 +126,7 @@ ${buildSettingsCss(this.props.settings)}`} setTimeout(() => this.props.insertAboveFirst(), 1); } private renderToolbarPanel() { - return ( - - ); + return ; } private renderVariablePanel(baseTheme: string) { diff --git a/src/datascience-ui/native-editor/redux/reducers/creation.ts b/src/datascience-ui/native-editor/redux/reducers/creation.ts index 1b7d7c8f43d1..4d032e3e5cda 100644 --- a/src/datascience-ui/native-editor/redux/reducers/creation.ts +++ b/src/datascience-ui/native-editor/redux/reducers/creation.ts @@ -338,8 +338,7 @@ export namespace Creation { undoStack: [], cellVMs: vms, loaded: true, - isNotebookTrusted: arg.payload.data.isNotebookTrusted!, - shouldShowTrustMessage: arg.payload.data.shouldShowTrustMessage! + isNotebookTrusted: arg.payload.data.isNotebookTrusted! }; } diff --git a/src/datascience-ui/native-editor/toolbar.tsx b/src/datascience-ui/native-editor/toolbar.tsx index 97c3d76cb5b3..10cdd0d53f4d 100644 --- a/src/datascience-ui/native-editor/toolbar.tsx +++ b/src/datascience-ui/native-editor/toolbar.tsx @@ -47,7 +47,6 @@ export type INativeEditorToolbarProps = INativeEditorDataProps & { selectServer: typeof actionCreators.selectServer; launchNotebookTrustPrompt: typeof actionCreators.launchNotebookTrustPrompt; isNotebookTrusted: boolean; - shouldShowTrustMessage: boolean; }; function mapStateToProps(state: IStore): INativeEditorDataProps { @@ -264,7 +263,7 @@ export class Toolbar extends React.PureComponent { kernel={this.props.kernel} selectServer={selectServer} selectKernel={selectKernel} - shouldShowTrustMessage={this.props.shouldShowTrustMessage} + shouldShowTrustMessage={true} isNotebookTrusted={this.props.isNotebookTrusted} launchNotebookTrustPrompt={launchNotebookTrustPrompt} /> diff --git a/src/test/datascience/.vscode/settings.json b/src/test/datascience/.vscode/settings.json index 98998613cddd..90f4ac4dc843 100644 --- a/src/test/datascience/.vscode/settings.json +++ b/src/test/datascience/.vscode/settings.json @@ -14,8 +14,7 @@ "python.pythonPath": "python", "python.experiments.optInto": [ "LocalZMQKernel - experiment", - "NativeNotebook - experiment", - "EnableTrustedNotebooks" + "NativeNotebook - experiment" ], // Do not set this to "Microsoft", else it will result in LS being downloaded on CI // and that slows down tests significantly. We have other tests on CI for testing diff --git a/src/test/datascience/dataScienceIocContainer.ts b/src/test/datascience/dataScienceIocContainer.ts index 5e3443ca4a76..d5622831b3ee 100644 --- a/src/test/datascience/dataScienceIocContainer.ts +++ b/src/test/datascience/dataScienceIocContainer.ts @@ -102,7 +102,7 @@ import { import { CryptoUtils } from '../../client/common/crypto'; import { DotNetCompatibilityService } from '../../client/common/dotnet/compatibilityService'; import { IDotNetCompatibilityService } from '../../client/common/dotnet/types'; -import { EnableTrustedNotebooks, LocalZMQKernel } from '../../client/common/experiments/groups'; +import { LocalZMQKernel } from '../../client/common/experiments/groups'; import { ExperimentsManager } from '../../client/common/experiments/manager'; import { ExperimentService } from '../../client/common/experiments/service'; import { InstallationChannelManager } from '../../client/common/installer/channelManager'; @@ -621,7 +621,6 @@ export class DataScienceIocContainer extends UnitTestIocContainer { this.serviceManager.add(IStartPage, StartPage); const experimentService = mock(ExperimentService); - when(experimentService.inExperiment(EnableTrustedNotebooks.experiment)).thenResolve(true); this.serviceManager.addSingletonInstance(IExperimentService, instance(experimentService)); this.serviceManager.addSingleton(IApplicationEnvironment, ApplicationEnvironment); diff --git a/src/test/datascience/interactive-common/trustCommandHandler.unit.test.ts b/src/test/datascience/interactive-common/trustCommandHandler.unit.test.ts index cde9b602e5bf..845f7f1821b0 100644 --- a/src/test/datascience/interactive-common/trustCommandHandler.unit.test.ts +++ b/src/test/datascience/interactive-common/trustCommandHandler.unit.test.ts @@ -11,7 +11,6 @@ import { IExtensionSingleActivationService } from '../../../client/activation/ty import { IApplicationShell, ICommandManager } from '../../../client/common/application/types'; import { ContextKey } from '../../../client/common/contextKey'; import { CryptoUtils } from '../../../client/common/crypto'; -import { EnableTrustedNotebooks } from '../../../client/common/experiments/groups'; import { IDisposable, IExperimentService } from '../../../client/common/types'; import { DataScience } from '../../../client/common/utils/localize'; import { Commands } from '../../../client/datascience/constants'; @@ -57,9 +56,6 @@ suite('DataScience - Trust Command Handler', () => { experiments = mock(); when(trustService.trustNotebook(anything(), anything())).thenResolve(); - when(experiments.inExperiment(anything())).thenCall((exp) => - Promise.resolve(exp === EnableTrustedNotebooks.experiment) - ); when(commandManager.registerCommand(anything(), anything(), anything())).thenCall(() => ({ dispose: noop })); when(commandManager.registerCommand(Commands.TrustNotebook, anything(), anything())).thenCall((_, cb) => { trustNotebookCommandCallback = cb.bind(trustCommandHandler); @@ -95,16 +91,6 @@ suite('DataScience - Trust Command Handler', () => { assert.equal(contextKeySet.callCount, 0); }); - test('Context set if in experiment', async () => { - when(experiments.inExperiment(anything())).thenCall((exp) => - Promise.resolve(exp === EnableTrustedNotebooks.experiment) - ); - - await trustCommandHandler.activate(); - await clock.runAllAsync(); - - assert.equal(contextKeySet.callCount, 1); - }); test('Executing command will not update trust after dismissing the prompt', async () => { when(applicationShell.showErrorMessage(anything(), anything(), anything(), anything())).thenResolve( undefined as any diff --git a/src/test/datascience/interactive-common/trustService.unit.test.ts b/src/test/datascience/interactive-common/trustService.unit.test.ts index eb4f44cc8888..84c687bc8d6c 100644 --- a/src/test/datascience/interactive-common/trustService.unit.test.ts +++ b/src/test/datascience/interactive-common/trustService.unit.test.ts @@ -9,7 +9,6 @@ import { anything, instance, mock, when } from 'ts-mockito'; import * as typemoq from 'typemoq'; import { Uri } from 'vscode'; import { ConfigurationService } from '../../../client/common/configuration/service'; -import { ExperimentService } from '../../../client/common/experiments/service'; import { IExtensionContext } from '../../../client/common/types'; import { DataScienceFileSystem } from '../../../client/datascience/dataScienceFileSystem'; import { DigestStorage } from '../../../client/datascience/interactive-ipynb/digestStorage'; @@ -21,7 +20,6 @@ suite('DataScience - TrustService', () => { setup(() => { alwaysTrustNotebooks = false; const configService = mock(ConfigurationService); - const experimentService = mock(ExperimentService); const fileSystem = mock(DataScienceFileSystem); const context = typemoq.Mock.ofType(); context.setup((c) => c.globalStoragePath).returns(() => os.tmpdir()); @@ -33,10 +31,8 @@ suite('DataScience - TrustService', () => { when(fileSystem.readLocalFile(anything())).thenCall((f) => fs.readFile(f)); when(fileSystem.createLocalDirectory(anything())).thenCall((d) => fs.mkdir(d)); when(fileSystem.localDirectoryExists(anything())).thenCall((d) => fs.pathExists(d)); - when(experimentService.inExperiment(anything())).thenResolve(true); // Pretend we're in an experiment so that trust checks proceed - const digestStorage = new DigestStorage(instance(fileSystem), context.object); - trustService = new TrustService(instance(experimentService), digestStorage, instance(configService)); + trustService = new TrustService(digestStorage, instance(configService)); }); test('Trusting a notebook', async () => { diff --git a/src/test/datascience/interactivePanel.functional.test.tsx b/src/test/datascience/interactivePanel.functional.test.tsx index c146648bdee9..ebe18855a98a 100644 --- a/src/test/datascience/interactivePanel.functional.test.tsx +++ b/src/test/datascience/interactivePanel.functional.test.tsx @@ -116,8 +116,7 @@ suite('DataScience Interactive Panel', () => { setVariableExplorerHeight: noopAny, editorOptions: {}, settings: { showCellInputCode: true, allowInput: true, extraSettings: { editor: {} } } as any, - isNotebookTrusted: true, - shouldShowTrustMessage: false + isNotebookTrusted: true }; }); test('Input Cell is displayed', () => { diff --git a/src/test/datascience/nativeEditor.toolbar.functional.test.tsx b/src/test/datascience/nativeEditor.toolbar.functional.test.tsx index eaee1f433ffb..b1e86f026daa 100644 --- a/src/test/datascience/nativeEditor.toolbar.functional.test.tsx +++ b/src/test/datascience/nativeEditor.toolbar.functional.test.tsx @@ -65,8 +65,7 @@ suite('DataScience Native Toolbar', () => { setVariableExplorerHeight: sinon.stub(), launchNotebookTrustPrompt: sinon.stub(), variablesVisible: false, - isNotebookTrusted: true, - shouldShowTrustMessage: true + isNotebookTrusted: true }; }); function mountToolbar() { @@ -266,8 +265,7 @@ suite('DataScience Native Toolbar', () => { setVariableExplorerHeight: sinon.stub(), launchNotebookTrustPrompt: sinon.stub(), variablesVisible: false, - isNotebookTrusted: false, - shouldShowTrustMessage: true + isNotebookTrusted: false }; }); test('All toolbar buttons are disabled unless explicitly added to allowlist', () => { diff --git a/src/test/datascience/trustedNotebooks.functional.test.tsx b/src/test/datascience/trustedNotebooks.functional.test.tsx index 6b9b0c02335e..57d5daef5269 100644 --- a/src/test/datascience/trustedNotebooks.functional.test.tsx +++ b/src/test/datascience/trustedNotebooks.functional.test.tsx @@ -6,7 +6,6 @@ import * as chaiAsPromised from 'chai-as-promised'; import { ReactWrapper } from 'enzyme'; import * as fs from 'fs-extra'; import { Disposable } from 'vscode'; -import { EnableTrustedNotebooks } from '../../client/common/experiments/groups'; import { noop } from '../../client/common/utils/misc'; import { InteractiveWindowMessages } from '../../client/datascience/interactive-common/interactiveWindowTypes'; import { INotebookEditor, INotebookEditorProvider, ITrustService } from '../../client/datascience/types'; @@ -163,7 +162,6 @@ suite('Notebook trust', () => { ioc = new DataScienceIocContainer(); ioc.registerDataScienceTypes(false); ioc.forceDataScienceSettingsChanged({ alwaysTrustNotebooks: false }); - ioc.setExperimentState(EnableTrustedNotebooks.experiment, true); return ioc.activate(); } function simulateKeyPressOnCell(cellIndex: number, keyboardEvent: Partial & { code: string }) { From 2f3bbaea7ccb1aef2f5e3209f3811d5420d68f1f Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Tue, 11 Aug 2020 23:45:20 -0700 Subject: [PATCH 2/2] Fixes --- .../interactive-ipynb/nativeEditor.ts | 3 +-- .../interactive-ipynb/trustCommandHandler.ts | 5 ++--- .../trustCommandHandler.unit.test.ts | 16 ++-------------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/client/datascience/interactive-ipynb/nativeEditor.ts b/src/client/datascience/interactive-ipynb/nativeEditor.ts index 751bd5ff2099..b43a3dbba677 100644 --- a/src/client/datascience/interactive-ipynb/nativeEditor.ts +++ b/src/client/datascience/interactive-ipynb/nativeEditor.ts @@ -180,7 +180,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor { notebookProvider: INotebookProvider, useCustomEditorApi: boolean, private trustService: ITrustService, - private expService: IExperimentService, + expService: IExperimentService, private _model: INotebookModel, webviewPanel: WebviewPanel | undefined, selector: KernelSelector @@ -224,7 +224,6 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor { selector ); asyncRegistry.push(this); - asyncRegistry.push(this.trustService.onDidSetNotebookTrust(this.monitorChangesToTrust, this)); this.synchronizer.subscribeToUserActions(this, this.postMessage.bind(this)); diff --git a/src/client/datascience/interactive-ipynb/trustCommandHandler.ts b/src/client/datascience/interactive-ipynb/trustCommandHandler.ts index 943785985dbc..3718379cc804 100644 --- a/src/client/datascience/interactive-ipynb/trustCommandHandler.ts +++ b/src/client/datascience/interactive-ipynb/trustCommandHandler.ts @@ -9,7 +9,7 @@ import { IExtensionSingleActivationService } from '../../activation/types'; import { IApplicationShell, ICommandManager } from '../../common/application/types'; import { ContextKey } from '../../common/contextKey'; import '../../common/extensions'; -import { IDisposableRegistry, IExperimentService } from '../../common/types'; +import { IDisposableRegistry } from '../../common/types'; import { swallowExceptions } from '../../common/utils/decorators'; import { DataScience } from '../../common/utils/localize'; import { sendTelemetryEvent } from '../../telemetry'; @@ -25,8 +25,7 @@ export class TrustCommandHandler implements IExtensionSingleActivationService { @inject(INotebookStorageProvider) private readonly storageProvider: INotebookStorageProvider, @inject(ICommandManager) private readonly commandManager: ICommandManager, @inject(IApplicationShell) private readonly applicationShell: IApplicationShell, - @inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry, - @inject(IExperimentService) private readonly experiments: IExperimentService + @inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry ) {} public async activate(): Promise { this.activateInBackground().ignoreErrors(); diff --git a/src/test/datascience/interactive-common/trustCommandHandler.unit.test.ts b/src/test/datascience/interactive-common/trustCommandHandler.unit.test.ts index 845f7f1821b0..7a4c1c05b021 100644 --- a/src/test/datascience/interactive-common/trustCommandHandler.unit.test.ts +++ b/src/test/datascience/interactive-common/trustCommandHandler.unit.test.ts @@ -11,7 +11,7 @@ import { IExtensionSingleActivationService } from '../../../client/activation/ty import { IApplicationShell, ICommandManager } from '../../../client/common/application/types'; import { ContextKey } from '../../../client/common/contextKey'; import { CryptoUtils } from '../../../client/common/crypto'; -import { IDisposable, IExperimentService } from '../../../client/common/types'; +import { IDisposable } from '../../../client/common/types'; import { DataScience } from '../../../client/common/utils/localize'; import { Commands } from '../../../client/datascience/constants'; import { TrustCommandHandler } from '../../../client/datascience/interactive-ipynb/trustCommandHandler'; @@ -35,7 +35,6 @@ suite('DataScience - Trust Command Handler', () => { let disposables: IDisposable[] = []; let clock: fakeTimers.InstalledClock; let contextKeySet: sinon.SinonStub<[boolean], Promise>; - let experiments: IExperimentService; let model: INotebookModel; let trustNotebookCommandCallback: (uri: Uri) => Promise; let testIndex = 0; @@ -53,8 +52,6 @@ suite('DataScience - Trust Command Handler', () => { when(storageProvider.getOrCreateModel(anything())).thenResolve(model); disposables = []; - experiments = mock(); - when(trustService.trustNotebook(anything(), anything())).thenResolve(); when(commandManager.registerCommand(anything(), anything(), anything())).thenCall(() => ({ dispose: noop })); when(commandManager.registerCommand(Commands.TrustNotebook, anything(), anything())).thenCall((_, cb) => { @@ -68,8 +65,7 @@ suite('DataScience - Trust Command Handler', () => { instance(storageProvider), instance(commandManager), instance(applicationShell), - disposables, - instance(experiments) + disposables ); clock = fakeTimers.install(); @@ -83,14 +79,6 @@ suite('DataScience - Trust Command Handler', () => { clock.uninstall(); }); - test('Context not set if not in experiment', async () => { - when(experiments.inExperiment(anything())).thenResolve(false); - - await trustCommandHandler.activate(); - await clock.runAllAsync(); - - assert.equal(contextKeySet.callCount, 0); - }); test('Executing command will not update trust after dismissing the prompt', async () => { when(applicationShell.showErrorMessage(anything(), anything(), anything(), anything())).thenResolve( undefined as any