mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-18 01:25:41 -05:00
New tool to store SQL connection configs locally (#218)
* added a new tool to store SQL connections locally. Modified the peek definition tests to create test database before running test * fixed failing test QueryExecutionPlanInvalidParamsTest * Fixes based on code review comments * fixed failing test GetSignatureHelpReturnsNotNullIfParseInfoInitialized
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>6cf2e945-c7d1-44b5-9e28-addd09e3e983</ProjectGuid>
|
||||
<RootNamespace>Microsoft.SqlTools.ServiceLayer.TestEnvConfig</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
115
test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig/Program.cs
Normal file
115
test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig/Program.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TestEnvConfig
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
string arg = args[0];
|
||||
|
||||
if (arg.Equals("-?", StringComparison.OrdinalIgnoreCase) ||
|
||||
arg.Equals("/?", StringComparison.OrdinalIgnoreCase) ||
|
||||
arg.Equals("-help", StringComparison.OrdinalIgnoreCase) ||
|
||||
arg.Equals("/help", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ShowUsage();
|
||||
}
|
||||
else if (File.Exists(arg) == false)
|
||||
{
|
||||
Console.WriteLine("setting file {0} does not exist.", arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
SaveSettings(arg);
|
||||
Console.WriteLine("Completed saving the settings");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error encountered: {0}", ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowUsage();
|
||||
}
|
||||
}
|
||||
|
||||
private static void ShowUsage()
|
||||
{
|
||||
Console.WriteLine(@"Usage:
|
||||
TestEnvConfig
|
||||
Show this help message
|
||||
|
||||
TestEnvConfig -?
|
||||
Show this help message
|
||||
|
||||
TestEnvConfig setting_file
|
||||
Run the program as a command line application
|
||||
The program reads the test configurations from the setting_file and
|
||||
saves them locally. the passwords will be stored in the credential store
|
||||
|
||||
The following is an example of a setting_file:
|
||||
|
||||
<Configuration>
|
||||
<Instance Name=""defaultSql2005"">
|
||||
<DataSource>SQL2005 servername</DataSource>
|
||||
<BackupMethod>RemoteShare</BackupMethod>
|
||||
<RemoteShare>SQL 2005 remote share</RemoteShare>
|
||||
</Instance>
|
||||
<Instance Name=""defaultSql2008"">
|
||||
<DataSource>SQL2008 servername</DataSource>
|
||||
<BackupMethod>RemoteShare</BackupMethod>
|
||||
<RemoteShare>SQL 2008 remote share</RemoteShare>
|
||||
</Instance>
|
||||
<Instance Name=""defaultSql2011"">
|
||||
<DataSource>SQL2011 servername</DataSource>
|
||||
<BackupMethod>RemoteShare</BackupMethod>
|
||||
<RemoteShare>SQL 20011 remote share</RemoteShare>
|
||||
</Instance>
|
||||
<Instance Name=""defaultSqlAzureV12"">
|
||||
<DataSource>SQLAzure servername</DataSource>
|
||||
<BackupMethod>RemoteShare</BackupMethod>
|
||||
<RemoteShare>SQLAzure remote share</RemoteShare>
|
||||
<UserId>user id</UserId>
|
||||
<Password>password</Password>
|
||||
</Instance>
|
||||
</Configuration>
|
||||
");
|
||||
}
|
||||
|
||||
private static void SaveSettings(string settingFile)
|
||||
{
|
||||
|
||||
var xdoc = XDocument.Load(settingFile);
|
||||
var settings =
|
||||
from setting in xdoc.Descendants("Instance")
|
||||
select new InstanceInfo(setting.Attribute("VersionKey").Value) // VersionKey is required
|
||||
{
|
||||
ServerName = setting.Element("DataSource").Value, // DataSource is required
|
||||
ConnectTimeoutAsString = (string)setting.Element("ConnectTimeout"), //ConnectTimeout is optional
|
||||
User = (string)setting.Element("UserId"), // UserID is optional
|
||||
Password = (string)setting.Element("Password"),
|
||||
RemoteSharePath = (string)setting.Element("RemoteShare"), // RemoteShare is optional
|
||||
AuthenticationType = string.IsNullOrEmpty((string)setting.Element("UserId")) ? AuthenticationType.Integrated : AuthenticationType.SqlLogin
|
||||
};
|
||||
|
||||
TestConfigPersistenceHelper.Write(settings);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Microsoft.SqlTools.ServiceLayer.TestEnvConfig")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("6cf2e945-c7d1-44b5-9e28-addd09e3e983")]
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"buildOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"Microsoft.SqlTools.ServiceLayer.Test.Common": "1.0.0-*"
|
||||
},
|
||||
"testRunner": "xunit",
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
},
|
||||
"imports": [
|
||||
"dotnet5.4",
|
||||
"portable-net451+win8"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user