Fix encoding of uris for data protocol (#6723)

* fix encoding or uris

* fix tests
This commit is contained in:
Anthony Dresser
2019-08-13 09:58:16 -07:00
committed by GitHub
parent bb010b2e53
commit 6fd4b5eaf2
4 changed files with 18 additions and 18 deletions

View File

@@ -13,11 +13,11 @@ const msInH = 3.6e6;
const msInM = 60000; const msInM = 60000;
const msInS = 1000; const msInS = 1000;
export const uriPrefixes = { export const uriPrefixes = {
default: 'connection://', default: 'connection:',
connection: 'connection://', connection: 'connection:',
dashboard: 'dashboard://', dashboard: 'dashboard:',
insights: 'insights://', insights: 'insights:',
notebook: 'notebook://' notebook: 'notebook:'
}; };

View File

@@ -217,7 +217,7 @@ suite('SQL ConnectionManagementService tests', () => {
let connectionToUse = connection ? connection : connectionProfile; let connectionToUse = connection ? connection : connectionProfile;
return new Promise<IConnectionResult>((resolve, reject) => { return new Promise<IConnectionResult>((resolve, reject) => {
let id = connectionToUse.getOptionsKey(); let id = connectionToUse.getOptionsKey();
let defaultUri = 'connection://' + (id ? id : connectionToUse.serverName + ':' + connectionToUse.databaseName); let defaultUri = 'connection:' + (id ? id : connectionToUse.serverName + ':' + connectionToUse.databaseName);
connectionManagementService.onConnectionRequestSent(() => { connectionManagementService.onConnectionRequestSent(() => {
let info: azdata.ConnectionInfoSummary = { let info: azdata.ConnectionInfoSummary = {
connectionId: error ? undefined : 'id', connectionId: error ? undefined : 'id',

View File

@@ -228,7 +228,7 @@ suite('SQL ConnectionStatusManager tests', () => {
//Verify database name changed after connection is complete //Verify database name changed after connection is complete
connections.updateDatabaseName(summary); connections.updateDatabaseName(summary);
connectionStatus = connections.findConnection(connection3Id); connectionStatus = connections.findConnection(connection3Id);
let ownerUriWithDbName = Utils.generateUriWithPrefix(connectionStatus.connectionProfile, 'connection://'); let ownerUriWithDbName = Utils.generateUriWithPrefix(connectionStatus.connectionProfile, 'connection:');
//The uri assigned to connection without db name should be the original one //The uri assigned to connection without db name should be the original one
let connectionWitDbStatus = connections.getOriginalOwnerUri(ownerUriWithDbName); let connectionWitDbStatus = connections.getOriginalOwnerUri(ownerUriWithDbName);

View File

@@ -195,7 +195,7 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
// Connection Management handlers // Connection Management handlers
$connect(handle: number, connectionUri: string, connection: azdata.ConnectionInfo): Thenable<boolean> { $connect(handle: number, connectionUri: string, connection: azdata.ConnectionInfo): Thenable<boolean> {
if (this.uriTransformer) { if (this.uriTransformer) {
connectionUri = URI.from(this.uriTransformer.transformIncoming(URI.parse(connectionUri))).toString(); connectionUri = URI.from(this.uriTransformer.transformIncoming(URI.parse(connectionUri))).toString(true);
} }
return this._resolveProvider<azdata.ConnectionProvider>(handle).connect(connectionUri, connection); return this._resolveProvider<azdata.ConnectionProvider>(handle).connect(connectionUri, connection);
} }
@@ -235,7 +235,7 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
$onConnectComplete(handle: number, connectionInfoSummary: azdata.ConnectionInfoSummary): void { $onConnectComplete(handle: number, connectionInfoSummary: azdata.ConnectionInfoSummary): void {
if (this.uriTransformer) { if (this.uriTransformer) {
connectionInfoSummary.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(connectionInfoSummary.ownerUri))).toString(); connectionInfoSummary.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(connectionInfoSummary.ownerUri))).toString(true);
} }
this._proxy.$onConnectionComplete(handle, connectionInfoSummary); this._proxy.$onConnectionComplete(handle, connectionInfoSummary);
} }
@@ -261,7 +261,7 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
$runQuery(handle: number, ownerUri: string, selection: azdata.ISelectionData, runOptions?: azdata.ExecutionPlanOptions): Thenable<void> { $runQuery(handle: number, ownerUri: string, selection: azdata.ISelectionData, runOptions?: azdata.ExecutionPlanOptions): Thenable<void> {
if (this.uriTransformer) { if (this.uriTransformer) {
ownerUri = URI.from(this.uriTransformer.transformIncoming(URI.parse(ownerUri))).toString(); ownerUri = URI.from(this.uriTransformer.transformIncoming(URI.parse(ownerUri))).toString(true);
} }
return this._resolveProvider<azdata.QueryProvider>(handle).runQuery(ownerUri, selection, runOptions); return this._resolveProvider<azdata.QueryProvider>(handle).runQuery(ownerUri, selection, runOptions);
} }
@@ -292,51 +292,51 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
$getQueryRows(handle: number, rowData: azdata.QueryExecuteSubsetParams): Thenable<azdata.QueryExecuteSubsetResult> { $getQueryRows(handle: number, rowData: azdata.QueryExecuteSubsetParams): Thenable<azdata.QueryExecuteSubsetResult> {
if (this.uriTransformer) { if (this.uriTransformer) {
rowData.ownerUri = URI.from(this.uriTransformer.transformIncoming(URI.parse(rowData.ownerUri))).toString(); rowData.ownerUri = URI.from(this.uriTransformer.transformIncoming(URI.parse(rowData.ownerUri))).toString(true);
} }
return this._resolveProvider<azdata.QueryProvider>(handle).getQueryRows(rowData); return this._resolveProvider<azdata.QueryProvider>(handle).getQueryRows(rowData);
} }
$disposeQuery(handle: number, ownerUri: string): Thenable<void> { $disposeQuery(handle: number, ownerUri: string): Thenable<void> {
if (this.uriTransformer) { if (this.uriTransformer) {
ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(ownerUri))).toString(); ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(ownerUri))).toString(true);
} }
return this._resolveProvider<azdata.QueryProvider>(handle).disposeQuery(ownerUri); return this._resolveProvider<azdata.QueryProvider>(handle).disposeQuery(ownerUri);
} }
$onQueryComplete(handle: number, result: azdata.QueryExecuteCompleteNotificationResult): void { $onQueryComplete(handle: number, result: azdata.QueryExecuteCompleteNotificationResult): void {
if (this.uriTransformer) { if (this.uriTransformer) {
result.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(result.ownerUri))).toString(); result.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(result.ownerUri))).toString(true);
} }
this._proxy.$onQueryComplete(handle, result); this._proxy.$onQueryComplete(handle, result);
} }
$onBatchStart(handle: number, batchInfo: azdata.QueryExecuteBatchNotificationParams): void { $onBatchStart(handle: number, batchInfo: azdata.QueryExecuteBatchNotificationParams): void {
if (this.uriTransformer) { if (this.uriTransformer) {
batchInfo.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(batchInfo.ownerUri))).toString(); batchInfo.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(batchInfo.ownerUri))).toString(true);
} }
this._proxy.$onBatchStart(handle, batchInfo); this._proxy.$onBatchStart(handle, batchInfo);
} }
$onBatchComplete(handle: number, batchInfo: azdata.QueryExecuteBatchNotificationParams): void { $onBatchComplete(handle: number, batchInfo: azdata.QueryExecuteBatchNotificationParams): void {
if (this.uriTransformer) { if (this.uriTransformer) {
batchInfo.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(batchInfo.ownerUri))).toString(); batchInfo.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(batchInfo.ownerUri))).toString(true);
} }
this._proxy.$onBatchComplete(handle, batchInfo); this._proxy.$onBatchComplete(handle, batchInfo);
} }
$onResultSetAvailable(handle: number, resultSetInfo: azdata.QueryExecuteResultSetNotificationParams): void { $onResultSetAvailable(handle: number, resultSetInfo: azdata.QueryExecuteResultSetNotificationParams): void {
if (this.uriTransformer) { if (this.uriTransformer) {
resultSetInfo.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(resultSetInfo.ownerUri))).toString(); resultSetInfo.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(resultSetInfo.ownerUri))).toString(true);
} }
this._proxy.$onResultSetAvailable(handle, resultSetInfo); this._proxy.$onResultSetAvailable(handle, resultSetInfo);
} }
$onResultSetUpdated(handle: number, resultSetInfo: azdata.QueryExecuteResultSetNotificationParams): void { $onResultSetUpdated(handle: number, resultSetInfo: azdata.QueryExecuteResultSetNotificationParams): void {
if (this.uriTransformer) { if (this.uriTransformer) {
resultSetInfo.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(resultSetInfo.ownerUri))).toString(); resultSetInfo.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(resultSetInfo.ownerUri))).toString(true);
} }
this._proxy.$onResultSetUpdated(handle, resultSetInfo); this._proxy.$onResultSetUpdated(handle, resultSetInfo);
} }
$onQueryMessage(handle: number, message: azdata.QueryExecuteMessageParams): void { $onQueryMessage(handle: number, message: azdata.QueryExecuteMessageParams): void {
if (this.uriTransformer) { if (this.uriTransformer) {
message.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(message.ownerUri))).toString(); message.ownerUri = URI.from(this.uriTransformer.transformOutgoing(URI.parse(message.ownerUri))).toString(true);
} }
this._proxy.$onQueryMessage(handle, message); this._proxy.$onQueryMessage(handle, message);
} }