mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Add/update providerConnectionInfo.getOptionsKey tests (#21001)
This commit is contained in:
@@ -215,16 +215,27 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('getOptionsKey should create a valid unique id', () => {
|
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);
|
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 expectedId = 'providerName:MSSQL|authenticationType:|databaseName:database|serverName:new server|userName:user';
|
||||||
let id = conn.getOptionsKey();
|
let id = conn.getOptionsKey();
|
||||||
assert.strictEqual(id, expectedId);
|
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', () => {
|
test('getOptionsKey should create different id for different server names', () => {
|
||||||
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
|
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
|
||||||
let conn2 = new ProviderConnectionInfo(capabilitiesService, Object.assign({}, connectionProfile, { serverName: connectionProfile.serverName + '1' }));
|
let conn2 = new ProviderConnectionInfo(capabilitiesService, Object.assign({}, connectionProfile, { serverName: connectionProfile.serverName + '1' }));
|
||||||
|
|||||||
Reference in New Issue
Block a user