Migrate cert validation error handling to mssql extension (#21829)

This commit is contained in:
Cheena Malhotra
2023-02-07 09:21:35 -08:00
committed by GitHub
parent e1b35d266a
commit 66410edf02
29 changed files with 352 additions and 92 deletions

View File

@@ -108,10 +108,9 @@ suite('ConnectionDialogService tests', () => {
testInstantiationService.stub(ICapabilitiesService, new TestCapabilitiesService());
let logService: ILogService = new NullLogService();
let telemetryService: IAdsTelemetryService = new NullAdsTelemetryService();
connectionDialogService = new ConnectionDialogService(testInstantiationService, capabilitiesService, errorMessageService.object,
new TestConfigurationService(), new BrowserClipboardService(layoutService, logService), NullCommandService, logService, telemetryService);
new TestConfigurationService(), new BrowserClipboardService(layoutService, logService), NullCommandService, logService);
(connectionDialogService as any)._connectionManagementService = mockConnectionManagementService.object;
let providerDisplayNames = ['Mock SQL Server'];
let providerNameToDisplayMap = { 'MSSQL': 'Mock SQL Server' };
@@ -290,7 +289,7 @@ suite('ConnectionDialogService tests', () => {
connected: false,
errorMessage: 'test_error',
errorCode: -1,
callStack: 'testCallStack'
messageDetails: 'testCallStack'
};
// promise only resolves upon handleDefaultOnConnect, must return it at the end
let connectionPromise = connectionDialogService.openDialogAndWait(mockConnectionManagementService.object, testConnectionParams, connectionProfile, connectionResult, false);

View File

@@ -203,7 +203,7 @@ suite('SQL ConnectionManagementService tests', () => {
TypeMoq.It.isAny(),
TypeMoq.It.is<INewConnectionParams>(p => p.connectionType === connectionType && (uri === undefined || p.input.uri === uri)),
TypeMoq.It.is<IConnectionProfile>(c => c !== undefined && c.serverName === connectionProfile.serverName),
connectionResult ? TypeMoq.It.is<IConnectionResult>(r => r.errorMessage === connectionResult.errorMessage && r.callStack === connectionResult.callStack) : undefined,
connectionResult ? TypeMoq.It.is<IConnectionResult>(r => r.errorMessage === connectionResult.errorMessage && r.messageDetails === connectionResult.messageDetails) : undefined,
options ? TypeMoq.It.isAny() : undefined),
didShow ? TypeMoq.Times.once() : TypeMoq.Times.never());
@@ -212,7 +212,7 @@ suite('SQL ConnectionManagementService tests', () => {
TypeMoq.It.isAny(),
TypeMoq.It.is<INewConnectionParams>(p => p.connectionType === connectionType && ((uri === undefined && p.input === undefined) || p.input.uri === uri)),
undefined,
connectionResult ? TypeMoq.It.is<IConnectionResult>(r => r.errorMessage === connectionResult.errorMessage && r.callStack === connectionResult.callStack) : undefined,
connectionResult ? TypeMoq.It.is<IConnectionResult>(r => r.errorMessage === connectionResult.errorMessage && r.messageDetails === connectionResult.messageDetails) : undefined,
options ? TypeMoq.It.isAny() : undefined),
didShow ? TypeMoq.Times.once() : TypeMoq.Times.never());
}
@@ -422,7 +422,7 @@ suite('SQL ConnectionManagementService tests', () => {
connected: expectedConnection,
errorMessage: error,
errorCode: errorCode,
callStack: errorCallStack
messageDetails: errorCallStack
};
let result = await connect(uri, options, false, connectionProfile, error, errorCode, errorCallStack);
@@ -450,7 +450,7 @@ suite('SQL ConnectionManagementService tests', () => {
connected: expectedConnection,
errorMessage: error,
errorCode: errorCode,
callStack: errorCallStack
messageDetails: errorCallStack
};
let result = await connect(uri, options, false, connectionProfile, error, errorCode, errorCallStack);
@@ -1097,7 +1097,7 @@ suite('SQL ConnectionManagementService tests', () => {
connected: expectedConnection,
errorMessage: error,
errorCode: errorCode,
callStack: errorCallStack
messageDetails: errorCallStack
};
let result = await connect(uri, options, false, connectionProfile, error, errorCode, errorCallStack);
@@ -1177,7 +1177,7 @@ suite('SQL ConnectionManagementService tests', () => {
connected: expectedConnection,
errorMessage: error,
errorCode: errorCode,
callStack: errorCallStack
messageDetails: errorCallStack
};
let result = await connect(uri, options, false, connectionProfile, error, errorCode, errorCallStack);
@@ -1209,7 +1209,7 @@ suite('SQL ConnectionManagementService tests', () => {
connected: expectedConnection,
errorMessage: error,
errorCode: errorCode,
callStack: errorCallStack
messageDetails: errorCallStack
};
let result = await connect(uri, options, false, connectionProfile, error, errorCode, errorCallStack);
@@ -1233,7 +1233,7 @@ suite('SQL ConnectionManagementService tests', () => {
connected: expectedConnection,
errorMessage: undefined,
errorCode: undefined,
callStack: undefined
messageDetails: undefined
};
let result = await connect(uri, options, false, connectionProfileWithEmptyUnsavedPassword);
@@ -1258,7 +1258,7 @@ suite('SQL ConnectionManagementService tests', () => {
connected: expectedConnection,
errorMessage: undefined,
errorCode: undefined,
callStack: undefined
messageDetails: undefined
};
let result = await connect(uri, options, false, connectionProfileWithEmptySavedPassword);
@@ -1294,7 +1294,7 @@ suite('SQL ConnectionManagementService tests', () => {
connected: expectedConnection,
errorMessage: undefined,
errorCode: undefined,
callStack: undefined
messageDetails: undefined
};
let result = await connect(uri, options, false, connectionProfileWithEmptySavedPassword);

View File

@@ -5,6 +5,7 @@
import { INewConnectionParams, IConnectionResult, IConnectionManagementService, IConnectionCompletionOptions } from 'sql/platform/connection/common/connectionManagement';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { IErrorDialogOptions } from 'sql/workbench/api/common/sqlExtHostTypes';
import { IConnectionDialogService } from 'sql/workbench/services/connection/common/connectionDialogService';
export class TestConnectionDialogService implements IConnectionDialogService {
@@ -29,4 +30,8 @@ export class TestConnectionDialogService implements IConnectionDialogService {
public callDefaultOnConnect(connection: IConnectionProfile, params: INewConnectionParams): Promise<void> {
return Promise.resolve(undefined);
}
public async showErrorDialogAsync(options: IErrorDialogOptions): Promise<string | undefined> {
return Promise.resolve(undefined);
}
}

View File

@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as azdata from 'azdata';
import { IConnectionResult } from 'sql/platform/connection/common/connectionManagement';
import { IErrorDiagnosticsService } from 'sql/workbench/services/diagnostics/common/errorDiagnosticsService';
export class TestErrorDiagnosticsService implements IErrorDiagnosticsService {
@@ -15,7 +16,7 @@ export class TestErrorDiagnosticsService implements IErrorDiagnosticsService {
unregisterDiagnosticsProvider(ProviderId: string): void {
}
tryHandleConnectionError(errorCode: number, errorMessage: string, providerId: string, connection: azdata.IConnectionProfile): Promise<azdata.diagnostics.ConnectionDiagnosticsResult> {
tryHandleConnectionError(connectionResult: IConnectionResult, providerId: string, connection: azdata.IConnectionProfile): Promise<azdata.diagnostics.ConnectionDiagnosticsResult> {
return Promise.resolve({ handled: false });
}
}