mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fix issue with SQL Database Projects unable to connect due to default encryption (#21010)
This commit is contained in:
@@ -32,6 +32,7 @@ export class ConnectionService {
|
|||||||
const azdataApi = utils.getAzdataApi();
|
const azdataApi = utils.getAzdataApi();
|
||||||
const vscodeMssqlApi = azdataApi ? undefined : await utils.getVscodeMssqlApi();
|
const vscodeMssqlApi = azdataApi ? undefined : await utils.getVscodeMssqlApi();
|
||||||
if (azdataApi) {
|
if (azdataApi) {
|
||||||
|
// TODO receive encrypt/trustservercertificate from profile.
|
||||||
const connectionProfile = {
|
const connectionProfile = {
|
||||||
password: profile.password,
|
password: profile.password,
|
||||||
serverName: `${profile.serverName},${profile.port}`,
|
serverName: `${profile.serverName},${profile.port}`,
|
||||||
@@ -42,7 +43,10 @@ export class ConnectionService {
|
|||||||
saveProfile: false,
|
saveProfile: false,
|
||||||
id: '',
|
id: '',
|
||||||
connectionName: profile.profileName,
|
connectionName: profile.profileName,
|
||||||
options: [],
|
options: {
|
||||||
|
'encrypt': true,
|
||||||
|
'trustServerCertificate': true
|
||||||
|
},
|
||||||
authenticationType: azdataApi.connection.AuthenticationType.SqlLogin
|
authenticationType: azdataApi.connection.AuthenticationType.SqlLogin
|
||||||
};
|
};
|
||||||
return await azdataApi.connection.connect(connectionProfile, saveConnectionAndPassword, false);
|
return await azdataApi.connection.connect(connectionProfile, saveConnectionAndPassword, false);
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
|
|||||||
this.groupFullName = model.groupFullName;
|
this.groupFullName = model.groupFullName;
|
||||||
this.savePassword = model.savePassword;
|
this.savePassword = model.savePassword;
|
||||||
this.saveProfile = model.saveProfile;
|
this.saveProfile = model.saveProfile;
|
||||||
|
|
||||||
this.azureTenantId = model.azureTenantId;
|
this.azureTenantId = model.azureTenantId;
|
||||||
|
|
||||||
// Special case setting properties to support both IConnectionProfile and azdata.connection.ConnectionProfile
|
// Special case setting properties to support both IConnectionProfile and azdata.connection.ConnectionProfile
|
||||||
@@ -68,6 +67,13 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
|
|||||||
let appNameKey = appNameOption.name;
|
let appNameKey = appNameOption.name;
|
||||||
this.options[appNameKey] = Constants.applicationName;
|
this.options[appNameKey] = Constants.applicationName;
|
||||||
}
|
}
|
||||||
|
// Set values for advanced options received in model.
|
||||||
|
Object.keys(model.options).forEach(a => {
|
||||||
|
let option = options.find(opt => opt.name === a);
|
||||||
|
if (option !== undefined) {
|
||||||
|
this.options[option.name] = model.options[a];
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (model.options.registeredServerDescription) {
|
if (model.options.registeredServerDescription) {
|
||||||
this.registeredServerDescription = model.options.registeredServerDescription;
|
this.registeredServerDescription = model.options.registeredServerDescription;
|
||||||
|
|||||||
@@ -44,7 +44,10 @@ suite('SQL ConnectionProfileInfo tests', () => {
|
|||||||
groupFullName: 'g2/g2-2',
|
groupFullName: 'g2/g2-2',
|
||||||
groupId: 'group id',
|
groupId: 'group id',
|
||||||
providerId: mssqlProviderName,
|
providerId: mssqlProviderName,
|
||||||
options: {},
|
options: {
|
||||||
|
'encrypt': true,
|
||||||
|
'trustServerCertificate': true
|
||||||
|
},
|
||||||
saveProfile: true,
|
saveProfile: true,
|
||||||
connectionId: 'my id'
|
connectionId: 'my id'
|
||||||
};
|
};
|
||||||
@@ -137,7 +140,33 @@ suite('SQL ConnectionProfileInfo tests', () => {
|
|||||||
isRequired: true,
|
isRequired: true,
|
||||||
specialValueType: ConnectionOptionSpecialType.password,
|
specialValueType: ConnectionOptionSpecialType.password,
|
||||||
valueType: ServiceOptionType.string
|
valueType: ServiceOptionType.string
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
name: 'encrypt',
|
||||||
|
displayName: undefined!,
|
||||||
|
description: undefined!,
|
||||||
|
groupName: undefined!,
|
||||||
|
categoryValues: undefined!,
|
||||||
|
defaultValue: "true",
|
||||||
|
isIdentity: false,
|
||||||
|
showOnConnectionDialog: true,
|
||||||
|
isRequired: false,
|
||||||
|
specialValueType: undefined,
|
||||||
|
valueType: ServiceOptionType.boolean
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'trustServerCertificate',
|
||||||
|
displayName: undefined!,
|
||||||
|
description: undefined!,
|
||||||
|
groupName: undefined!,
|
||||||
|
categoryValues: undefined!,
|
||||||
|
defaultValue: "false",
|
||||||
|
isIdentity: false,
|
||||||
|
showOnConnectionDialog: true,
|
||||||
|
isRequired: false,
|
||||||
|
specialValueType: undefined,
|
||||||
|
valueType: ServiceOptionType.boolean
|
||||||
|
},
|
||||||
];
|
];
|
||||||
msSQLCapabilities = {
|
msSQLCapabilities = {
|
||||||
providerId: mssqlProviderName,
|
providerId: mssqlProviderName,
|
||||||
@@ -199,6 +228,8 @@ suite('SQL ConnectionProfileInfo tests', () => {
|
|||||||
assert.strictEqual(conn.groupFullName, connectionProfile.groupFullName);
|
assert.strictEqual(conn.groupFullName, connectionProfile.groupFullName);
|
||||||
assert.strictEqual(conn.savePassword, connectionProfile.savePassword);
|
assert.strictEqual(conn.savePassword, connectionProfile.savePassword);
|
||||||
assert.strictEqual(conn.providerName, connectionProfile.providerId);
|
assert.strictEqual(conn.providerName, connectionProfile.providerId);
|
||||||
|
assert.strictEqual(conn.options['encrypt'], connectionProfile.options['encrypt']);
|
||||||
|
assert.strictEqual(conn.options['trustServerCertificate'], connectionProfile.options['trustServerCertificate']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getOptionsKey should create a valid unique id', () => {
|
test('getOptionsKey should create a valid unique id', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user