Skip to content

Commit

Permalink
Revert "Workspace trust - add tracing to track down integration test …
Browse files Browse the repository at this point in the history
…failure (microsoft#142609)"

This reverts commit 0fb0a6d.
  • Loading branch information
lszomoru committed Apr 19, 2022
1 parent bab1b25 commit 02a92ee
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 59 deletions.
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/web.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export class BrowserMain extends Disposable {
const workspaceTrustEnablementService = new WorkspaceTrustEnablementService(configurationService, environmentService);
serviceCollection.set(IWorkspaceTrustEnablementService, workspaceTrustEnablementService);

const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, configurationService, workspaceTrustEnablementService, logService);
const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, configurationService, workspaceTrustEnablementService);
serviceCollection.set(IWorkspaceTrustManagementService, workspaceTrustManagementService);

// Update workspace trust so that configuration is updated accordingly
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/electron-sandbox/desktop.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export class DesktopMain extends Disposable {
const workspaceTrustEnablementService = new WorkspaceTrustEnablementService(configurationService, environmentService);
serviceCollection.set(IWorkspaceTrustEnablementService, workspaceTrustEnablementService);

const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, configurationService, workspaceTrustEnablementService, logService);
const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, configurationService, workspaceTrustEnablementService);
serviceCollection.set(IWorkspaceTrustManagementService, workspaceTrustManagementService);

// Update workspace trust so that configuration is updated accordingly
Expand Down
53 changes: 2 additions & 51 deletions src/vs/workbench/services/workspaces/common/workspaceTrust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import { Memento, MementoObject } from 'vs/workbench/common/memento';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { isEqualAuthority } from 'vs/base/common/resources';
import { ILogService } from 'vs/platform/log/common/log';
import { isCI, isWeb } from 'vs/base/common/platform';
import { isWeb } from 'vs/base/common/platform';

export const WORKSPACE_TRUST_ENABLED = 'security.workspace.trust.enabled';
export const WORKSPACE_TRUST_STARTUP_PROMPT = 'security.workspace.trust.startupPrompt';
Expand Down Expand Up @@ -119,8 +118,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IWorkspaceContextService private readonly workspaceService: IWorkspaceContextService,
@IWorkspaceTrustEnablementService private readonly workspaceTrustEnablementService: IWorkspaceTrustEnablementService,
@ILogService protected readonly _logService: ILogService,
@IWorkspaceTrustEnablementService private readonly workspaceTrustEnablementService: IWorkspaceTrustEnablementService
) {
super();

Expand All @@ -147,26 +145,16 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
//#region initialize

private initializeWorkspaceTrust(): void {
if (isCI) {
this._logService.info(`[WT] Enter initializeWorkspaceTrust()...`);
}

// Resolve canonical Uris
this.resolveCanonicalUris()
.then(async () => {
this._canonicalUrisResolved = true;
await this.updateWorkspaceTrust();
})
.finally(() => {
if (isCI) {
this._logService.info(`[WT] Open workspaceResolved gate...`);
}
this._workspaceResolvedPromiseResolve();

if (!this.environmentService.remoteAuthority) {
if (isCI) {
this._logService.info(`[WT] Open workspaceTrustInitialized gate...`);
}
this._workspaceTrustInitializedPromiseResolve();
}
});
Expand Down Expand Up @@ -211,16 +199,8 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
}

private async getCanonicalUri(uri: URI): Promise<URI> {
if (isCI) {
this._logService.info('[WT] Enter getCanonicalUri()...');
}

let canonicalUri = uri;
if (this.environmentService.remoteAuthority && uri.scheme === Schemas.vscodeRemote) {
if (isCI) {
this._logService.info('[WT] Return this.remoteAuthorityResolverService.getCanonicalURI(uri)...');
}

canonicalUri = await this.remoteAuthorityResolverService.getCanonicalURI(uri);
} else if (uri.scheme === 'vscode-vfs') {
const index = uri.authority.indexOf('+');
Expand All @@ -234,10 +214,6 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
}

private async resolveCanonicalUris(): Promise<void> {
if (isCI) {
this._logService.info('[WT] Enter resolveCanonicalUris()...');
}

// Open editors
const filesToOpen: IPath[] = [];
if (this.environmentService.filesToOpenOrCreate) {
Expand All @@ -255,32 +231,16 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
this._canonicalStartupFiles.push(...canonicalFilesToOpen.filter(uri => this._canonicalStartupFiles.every(u => !this.uriIdentityService.extUri.isEqual(uri, u))));
}

if (isCI) {
this._logService.info('[WT] Done processing open editors...');
}

// Workspace
const workspaceUris = this.workspaceService.getWorkspace().folders.map(f => f.uri);
const canonicalWorkspaceFolders = await Promise.all(workspaceUris.map(uri => this.getCanonicalUri(uri)));

if (isCI) {
this._logService.info('[WT] Done processing workspace folders...');
}

let canonicalWorkspaceConfiguration = this.workspaceService.getWorkspace().configuration;
if (canonicalWorkspaceConfiguration && isSavedWorkspace(canonicalWorkspaceConfiguration, this.environmentService)) {
canonicalWorkspaceConfiguration = await this.getCanonicalUri(canonicalWorkspaceConfiguration);
}

if (isCI) {
this._logService.info('[WT] Done processing workspace configuration...');
}

this._canonicalWorkspace = new CanonicalWorkspace(this.workspaceService.getWorkspace(), canonicalWorkspaceFolders, canonicalWorkspaceConfiguration);

if (isCI) {
this._logService.info('[WT] Exit resolveCanonicalUris()...');
}
}

private loadTrustInfo(): IWorkspaceTrustInfo {
Expand Down Expand Up @@ -362,16 +322,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
}

private async updateWorkspaceTrust(trusted?: boolean): Promise<void> {
if (isCI) {
this._logService.info(`[WT] Enter updateWorkspaceTrust()...`);
}

if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
if (isCI) {
this._logService.info(`[WT] Workspace trust is disabled.`);
this._logService.info(`[WT] Exit updateWorkspaceTrust()...`);
}

return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { FileService } from 'vs/platform/files/common/fileService';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
import { NullLogService } from 'vs/platform/log/common/log';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
Expand All @@ -28,7 +28,6 @@ suite('Workspace Trust', () => {
let instantiationService: TestInstantiationService;
let configurationService: TestConfigurationService;
let environmentService: IWorkbenchEnvironmentService;
let logService: ILogService;

setup(async () => {
instantiationService = new TestInstantiationService();
Expand All @@ -39,10 +38,7 @@ suite('Workspace Trust', () => {
environmentService = {} as IWorkbenchEnvironmentService;
instantiationService.stub(IWorkbenchEnvironmentService, environmentService);

logService = new NullLogService();
instantiationService.stub(ILogService, logService);

instantiationService.stub(IUriIdentityService, new UriIdentityService(new FileService(logService)));
instantiationService.stub(IUriIdentityService, new UriIdentityService(new FileService(new NullLogService())));
instantiationService.stub(IRemoteAuthorityResolverService, new class extends mock<IRemoteAuthorityResolverService>() { });
});

Expand Down

0 comments on commit 02a92ee

Please sign in to comment.