Code coverage improvements (#121)

These are test-only changes to improve code coverage so I'll merge directly.  Please review the commit and I'll pickup those changes in the next iteration.

* Add integration test batch file

* Exclude Linux and MacOS from Windows code coverage builds

* Enable code coverage for test driver e2e tests

* Use the windows only build for code coverage runs
This commit is contained in:
Karl Burtram
2016-10-27 18:18:31 -07:00
committed by GitHub
parent d42a92dd94
commit da84ae9f3b
17 changed files with 207 additions and 52 deletions

View File

@@ -48,7 +48,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
/// Default constructor is private since it's a singleton class
/// </summary>
private CredentialService()
: this(null, new LinuxCredentialStore.StoreConfig()
: this(null, new StoreConfig()
{ CredentialFolder = DefaultSecretsFolder, CredentialFile = DefaultSecretsFile, IsRelativeToUserHomeDir = true})
{
}
@@ -56,7 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
/// <summary>
/// Internal for testing purposes only
/// </summary>
internal CredentialService(ICredentialStore store, LinuxCredentialStore.StoreConfig config)
internal CredentialService(ICredentialStore store, StoreConfig config)
{
this.credStore = store != null ? store : GetStoreForOS(config);
}
@@ -64,12 +64,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
/// <summary>
/// Internal for testing purposes only
/// </summary>
internal static ICredentialStore GetStoreForOS(LinuxCredentialStore.StoreConfig config)
internal static ICredentialStore GetStoreForOS(StoreConfig config)
{
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return new Win32CredentialStore();
}
#if !WINDOWS_ONLY_BUILD
else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return new OSXCredentialStore();
@@ -78,6 +79,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
{
return new LinuxCredentialStore(config);
}
#endif
throw new InvalidOperationException("Platform not currently supported");
}

View File

@@ -13,6 +13,9 @@ using Newtonsoft.Json;
namespace Microsoft.SqlTools.ServiceLayer.Credentials.Linux
{
#if !WINDOWS_ONLY_BUILD
public class FileTokenStorage
{
private const int OwnerAccessMode = 384; // Permission 0600 - owner read/write, nobody else has access
@@ -84,4 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials.Linux
Interop.Sys.ChMod(filePath, OwnerAccessMode);
}
}
#endif
}

View File

@@ -8,6 +8,9 @@ using System.Runtime.InteropServices;
namespace Microsoft.SqlTools.ServiceLayer.Credentials
{
#if !WINDOWS_ONLY_BUILD
internal static partial class Interop
{
/// <summary>Common Unix errno error codes.</summary>
@@ -218,4 +221,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
}
}
#endif
}

View File

@@ -8,6 +8,9 @@ using System.Runtime.InteropServices;
namespace Microsoft.SqlTools.ServiceLayer.Credentials
{
#if !WINDOWS_ONLY_BUILD
internal static partial class Interop
{
internal static partial class Sys
@@ -37,6 +40,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
internal const string SystemNative = "System.Native";
}
}
}
#endif
}

View File

@@ -3,7 +3,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -15,6 +14,18 @@ using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Credentials.Linux
{
/// <summary>
/// Store configuration struct
/// </summary>
internal struct StoreConfig
{
public string CredentialFolder { get; set; }
public string CredentialFile { get; set; }
public bool IsRelativeToUserHomeDir { get; set; }
}
#if !WINDOWS_ONLY_BUILD
/// <summary>
/// Linux implementation of the credential store.
///
@@ -25,13 +36,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials.Linux
/// </summary>
internal class LinuxCredentialStore : ICredentialStore
{
internal struct StoreConfig
{
public string CredentialFolder { get; set; }
public string CredentialFile { get; set; }
public bool IsRelativeToUserHomeDir { get; set; }
}
private string credentialFolderPath;
private string credentialFileName;
private FileTokenStorage storage;
@@ -228,4 +232,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials.Linux
}
}
}
}
#endif
}

View File

@@ -10,6 +10,9 @@ using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Credentials.OSX
{
#if !WINDOWS_ONLY_BUILD
/// <summary>
/// OSX implementation of the credential store
/// </summary>
@@ -155,4 +158,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials.OSX
}
}
}
}
#endif
}

View File

@@ -5,6 +5,16 @@
"debugType": "portable",
"emitEntryPoint": true
},
"configurations": {
"Integration": {
"buildOptions": {
"define": [
"WINDOWS_ONLY_BUILD"
],
"emitEntryPoint": true
}
}
},
"dependencies": {
"Newtonsoft.Json": "9.0.1",
"System.Data.Common": "4.1.0",