mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-06 01:25:38 -05:00
Allow 'ApplicationName' to be specified for MSSQL connections (#22890)
This commit is contained in:
@@ -41,6 +41,7 @@ export interface SqlArgs {
|
||||
aad?: boolean; // deprecated - used by SSMS - authenticationType should be used instead
|
||||
integrated?: boolean; // deprecated - used by SSMS - authenticationType should be used instead.
|
||||
showDashboard?: boolean;
|
||||
applicationName?: string;
|
||||
}
|
||||
|
||||
//#region decorators
|
||||
@@ -307,7 +308,10 @@ export class CommandLineWorkbenchContribution implements IWorkbenchContribution,
|
||||
Constants.AuthenticationType.Integrated;
|
||||
|
||||
profile.connectionName = '';
|
||||
profile.setOptionValue('applicationName', Constants.applicationName);
|
||||
const applicationName = args.applicationName
|
||||
? args.applicationName + '-' + Constants.applicationName
|
||||
: Constants.applicationName;
|
||||
profile.setOptionValue('applicationName', applicationName);
|
||||
profile.setOptionValue('databaseDisplayName', profile.databaseName);
|
||||
profile.setOptionValue('groupId', profile.groupId);
|
||||
return this._connectionManagementService ? this.tryMatchSavedProfile(profile) : profile;
|
||||
|
||||
@@ -95,6 +95,7 @@ class TestParsedArgs implements NativeParsedArgs, SqlArgs {
|
||||
wait?: boolean;
|
||||
waitMarkerFilePath?: string;
|
||||
authenticationType?: string;
|
||||
applicationName?: string;
|
||||
}
|
||||
suite('commandLineService tests', () => {
|
||||
|
||||
@@ -196,12 +197,14 @@ suite('commandLineService tests', () => {
|
||||
args.database = 'mydatabase';
|
||||
args.user = 'myuser';
|
||||
args.authenticationType = Constants.AuthenticationType.SqlLogin;
|
||||
args.applicationName = 'myapplication';
|
||||
|
||||
connectionManagementService.setup((c) => c.showConnectionDialog()).verifiable(TypeMoq.Times.never());
|
||||
connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => true).verifiable(TypeMoq.Times.atMostOnce());
|
||||
connectionManagementService.setup(c => c.getConnectionGroups(TypeMoq.It.isAny())).returns(() => []);
|
||||
let originalProfile: IConnectionProfile = undefined;
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.AuthenticationType.SqlLogin), 'connection', true))
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(
|
||||
p => p.serverName === 'myserver' && p.authenticationType === Constants.AuthenticationType.SqlLogin && p.options['applicationName'] === 'myapplication-azdata'), 'connection', true))
|
||||
.returns((conn) => {
|
||||
originalProfile = conn;
|
||||
return Promise.resolve('unused');
|
||||
@@ -212,6 +215,7 @@ suite('commandLineService tests', () => {
|
||||
const logService = new NullLogService();
|
||||
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, undefined, logService);
|
||||
await contribution.processCommandLine(args);
|
||||
assert.equal(originalProfile.options['applicationName'], 'myapplication-azdata', 'Application Name not received as expected.');
|
||||
connectionManagementService.verifyAll();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user