Add/update providerConnectionInfo.getOptionsKey tests (#21001)

This commit is contained in:
Charles Gagnon
2022-10-26 22:45:40 -07:00
committed by GitHub
parent 1743c7ea13
commit 39e9018b7c

View File

@@ -215,16 +215,27 @@ suite('SQL ProviderConnectionInfo tests', () => {
});
test('getOptionsKey should create a valid unique id', () => {
let options: { [key: string]: string } = {};
// Setting custom options are not yet considered for profile identity
options['encrypt'] = 'true';
connectionProfile.options = options;
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
// **IMPORTANT** This should NEVER change without thorough review and consideration of side effects. This key controls
// things like how passwords are saved, which means if its changed then serious side effects will occur.
let expectedId = 'providerName:MSSQL|authenticationType:|databaseName:database|serverName:new server|userName:user';
let id = conn.getOptionsKey();
assert.strictEqual(id, expectedId);
});
test('getOptionsKey should create the same ID regardless of optional options', () => {
const conn1 = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
let id1 = conn1.getOptionsKey();
connectionProfile.options = {
'encrypt': true
};
const conn2 = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
const id2 = conn2.getOptionsKey();
assert.strictEqual(id1, id2);
});
test('getOptionsKey should create different id for different server names', () => {
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
let conn2 = new ProviderConnectionInfo(capabilitiesService, Object.assign({}, connectionProfile, { serverName: connectionProfile.serverName + '1' }));