From e1fc23027383b09b4f0798d571f5af6418add9c6 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Mon, 23 May 2022 16:01:55 -0700 Subject: [PATCH] remove password for connection string non sql auth types (#19484) * remove password for connection string non sql auth types * add comment * fix test --- extensions/sql-bindings/src/common/azureFunctionsUtils.ts | 6 ++++++ .../src/test/common/azureFunctionsUtils.test.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/extensions/sql-bindings/src/common/azureFunctionsUtils.ts b/extensions/sql-bindings/src/common/azureFunctionsUtils.ts index c2af28f004..a6ce631a06 100644 --- a/extensions/sql-bindings/src/common/azureFunctionsUtils.ts +++ b/extensions/sql-bindings/src/common/azureFunctionsUtils.ts @@ -578,6 +578,12 @@ export async function promptConnectionStringPasswordAndUpdateConnectionString(co // or user chooses to not include password (or if user cancels out of include password prompt), or authentication type is not SQL login connectionString = await vscodeMssqlApi.getConnectionString(connectionDetails, false, false); + if (connectionInfo.authenticationType !== 'SqlLogin') { + // temporarily fix until STS is fix to not include the placeholder: https://github.com/microsoft/sqltoolsservice/issues/1508 + // if authentication type is not SQL login, remove password in connection string + connectionString = connectionString.replace(`Password=${constants.passwordPlaceholder};`, ''); + } + if (!connectionInfo.password && connectionInfo.authenticationType === 'SqlLogin') { // if a connection exists but does not have password saved we ask user if they would like to enter it and save it in local.settings.json userPassword = await vscode.window.showInputBox({ diff --git a/extensions/sql-bindings/src/test/common/azureFunctionsUtils.test.ts b/extensions/sql-bindings/src/test/common/azureFunctionsUtils.test.ts index 399e718a9c..4a6eb70f69 100644 --- a/extensions/sql-bindings/src/test/common/azureFunctionsUtils.test.ts +++ b/extensions/sql-bindings/src/test/common/azureFunctionsUtils.test.ts @@ -177,7 +177,7 @@ describe('Tests to verify Azure Functions Utils functions', function (): void { should(quickInputSpy.notCalled).be.true('showInputBox should not have been called'); should(warningSpy.notCalled).be.true('showWarningMessage should not have been called'); // returned connection string should NOT include password - should(getConnectionString).equals(`Server=${connectionInfo.server};Initial Catalog=${connectionInfo.database};User ID=${connectionInfo.user};Password=${constants.passwordPlaceholder};`); + should(getConnectionString).equals(`Server=${connectionInfo.server};Initial Catalog=${connectionInfo.database};User ID=${connectionInfo.user};`); }); it('Should ask user to enter password and set password to connection string when connection info does not contain password and auth type is SQL', async () => {