Workspace trust - add tracing to track down integration test failure (#142609)

This commit is contained in:
Ladislau Szomoru
2022-02-09 11:26:45 +01:00
committed by GitHub
parent ccd7649e35
commit 0fb0a6df31
4 changed files with 40 additions and 5 deletions
+1 -1
View File
@@ -243,7 +243,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);
const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, configurationService, workspaceTrustEnablementService, logService);
serviceCollection.set(IWorkspaceTrustManagementService, workspaceTrustManagementService);
// Update workspace trust so that configuration is updated accordingly
@@ -284,7 +284,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);
const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, configurationService, workspaceTrustEnablementService, logService);
serviceCollection.set(IWorkspaceTrustManagementService, workspaceTrustManagementService);
// Update workspace trust so that configuration is updated accordingly
@@ -21,6 +21,8 @@ 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 } from 'vs/base/common/platform';
export const WORKSPACE_TRUST_ENABLED = 'security.workspace.trust.enabled';
export const WORKSPACE_TRUST_STARTUP_PROMPT = 'security.workspace.trust.startupPrompt';
@@ -117,7 +119,8 @@ 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
@IWorkspaceTrustEnablementService private readonly workspaceTrustEnablementService: IWorkspaceTrustEnablementService,
@ILogService protected readonly _logService: ILogService,
) {
super();
@@ -144,6 +147,10 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
//#region initialize
private initializeWorkspaceTrust(): void {
if (isCI) {
this._logService.info(`Enter initializeWorkspaceTrust()...`);
}
// Resolve canonical Uris
this.resolveCanonicalUris()
.then(async () => {
@@ -151,8 +158,16 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
await this.updateWorkspaceTrust();
})
.finally(() => {
if (isCI) {
this._logService.info(`Open workspaceResolved gate...`);
}
this._workspaceResolvedPromiseResolve();
if (!this.environmentService.remoteAuthority) {
if (isCI) {
this._logService.info(`Open workspaceTrustInitialized gate...`);
}
this._workspaceTrustInitializedPromiseResolve();
}
});
@@ -212,6 +227,10 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
}
private async resolveCanonicalUris(): Promise<void> {
if (isCI) {
this._logService.info('Enter resolveCanonicalUris()...');
}
// Open editors
const filesToOpen: IPath[] = [];
if (this.environmentService.filesToOpenOrCreate) {
@@ -239,6 +258,10 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
}
this._canonicalWorkspace = new CanonicalWorkspace(this.workspaceService.getWorkspace(), canonicalWorkspaceFolders, canonicalWorkspaceConfiguration);
if (isCI) {
this._logService.info('Exit resolveCanonicalUris()...');
}
}
private loadTrustInfo(): IWorkspaceTrustInfo {
@@ -320,7 +343,15 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
}
private async updateWorkspaceTrust(trusted?: boolean): Promise<void> {
if (isCI) {
this._logService.info(`Enter updateWorkspaceTrust()...`);
}
if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
if (isCI) {
this._logService.info(`Workspace trust is disabled.`);
}
return;
}
@@ -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 { NullLogService } from 'vs/platform/log/common/log';
import { ILogService, 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';
@@ -28,6 +28,7 @@ suite('Workspace Trust', () => {
let instantiationService: TestInstantiationService;
let configurationService: TestConfigurationService;
let environmentService: IWorkbenchEnvironmentService;
let logService: ILogService;
setup(async () => {
instantiationService = new TestInstantiationService();
@@ -38,7 +39,10 @@ suite('Workspace Trust', () => {
environmentService = {} as IWorkbenchEnvironmentService;
instantiationService.stub(IWorkbenchEnvironmentService, environmentService);
instantiationService.stub(IUriIdentityService, new UriIdentityService(new FileService(new NullLogService())));
logService = new NullLogService();
instantiationService.stub(ILogService, logService);
instantiationService.stub(IUriIdentityService, new UriIdentityService(new FileService(logService)));
instantiationService.stub(IRemoteAuthorityResolverService, new class extends mock<IRemoteAuthorityResolverService>() { });
});