Connection Store Refactor (#4632)

* various clean ups

* formatting

* remove linting

* formatting

* IConfigurationService is even better

* messing with connection config tests

* update tests

* formatting

* foramtting

* remove unused code

* add more tests

* working through tests

* formatting

* more factoring of connection store and increase code coverage

* formatting

* fix tests
This commit is contained in:
Anthony Dresser
2019-03-22 01:07:32 -07:00
committed by GitHub
parent 5f637036bc
commit 756f77063a
19 changed files with 896 additions and 1007 deletions

View File

@@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { ICredentialsService, CredentialManagementEvents } from 'sql/platform/credentials/common/credentialsService';
import { Credential } from 'azdata';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Emitter } from 'vs/base/common/event';
export class TestCredentialsService implements ICredentialsService {
_serviceBrand: any;
public credentials = new Map<string, Credential>();
private _onCredential = new Emitter<Credential>();
public readonly onCredential = this._onCredential.event;
saveCredential(credentialId: string, password: string): Promise<boolean> {
let credential = { credentialId, password };
this.credentials.set(credentialId, credential);
this._onCredential.fire(credential);
return Promise.resolve(true);
}
readCredential(credentialId: string): Promise<Credential> {
let cred = this.credentials.get(credentialId);
if (cred) {
return Promise.resolve<Credential>(cred);
} else {
return Promise.reject('');
}
}
deleteCredential(credentialId: string): Promise<boolean> {
return Promise.resolve(this.credentials.delete(credentialId));
}
addEventListener(handle: number, events: CredentialManagementEvents): IDisposable {
throw new Error('Method not implemented.');
}
}