mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-24 09:35:39 -05:00
Fix a number of cred scan hits (#800)
Bunch of secrets in files, usually fixed by generating random password. The deleted script files didn't seem to be used anywhere.
This commit is contained in:
@@ -25,19 +25,19 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
|
||||
{
|
||||
private static readonly StoreConfig Config = new StoreConfig
|
||||
{
|
||||
CredentialFolder = ".testsecrets",
|
||||
CredentialFile = "sqltestsecrets.json",
|
||||
CredentialFolder = ".testsecrets",
|
||||
CredentialFile = "sqltestsecrets.json",
|
||||
IsRelativeToUserHomeDir = true
|
||||
};
|
||||
|
||||
private const string CredentialId = "Microsoft_SqlToolsTest_TestId";
|
||||
private const string Password1 = "P@ssw0rd1";
|
||||
private const string Password2 = "2Pass2Furious";
|
||||
private readonly string Password1 = Guid.NewGuid().ToString();
|
||||
private readonly string Password2 = Guid.NewGuid().ToString();
|
||||
|
||||
private const string OtherCredId = CredentialId + "2345";
|
||||
private const string OtherPassword = CredentialId + "2345";
|
||||
|
||||
// Test-owned credential store used to clean up before/after tests to ensure code works as expected
|
||||
// Test-owned credential store used to clean up before/after tests to ensure code works as expected
|
||||
// even if previous runs stopped midway through
|
||||
private readonly ICredentialStore credStore;
|
||||
private readonly CredentialService service;
|
||||
@@ -50,7 +50,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
|
||||
service = new CredentialService(credStore, Config);
|
||||
DeleteDefaultCreds();
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DeleteDefaultCreds();
|
||||
@@ -89,7 +89,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
|
||||
{
|
||||
string errorResponse = null;
|
||||
var contextMock = RequestContextMocks.Create<bool>(null).AddErrorHandling((msg, code) => errorResponse = msg);
|
||||
|
||||
|
||||
await service.HandleSaveCredentialRequest(new Credential(CredentialId), contextMock.Object);
|
||||
TestUtils.VerifyErrorSent(contextMock);
|
||||
Assert.True(errorResponse.Contains("ArgumentException") || errorResponse.Contains("ArgumentNullException"));
|
||||
@@ -202,7 +202,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
|
||||
TestUtils.VerifyErrorSent(contextMock);
|
||||
Assert.Contains("ArgumentNullException", errorResponse);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task ReadCredentialThrowsIfIdMissing()
|
||||
{
|
||||
@@ -232,7 +232,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
|
||||
Assert.Null(actual.Password);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteCredentialThrowsIfIdMissing()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// Code originally from http://credentialmanagement.codeplex.com/,
|
||||
// Licensed under the Apache License 2.0
|
||||
// Code originally from http://credentialmanagement.codeplex.com/,
|
||||
// Licensed under the Apache License 2.0
|
||||
//
|
||||
|
||||
using System;
|
||||
@@ -15,7 +15,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
|
||||
[Fact]
|
||||
public void CredentialSetCreate()
|
||||
{
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
{
|
||||
Assert.NotNull(new CredentialSet());
|
||||
});
|
||||
@@ -24,7 +24,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
|
||||
[Fact]
|
||||
public void CredentialSetCreateWithTarget()
|
||||
{
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
{
|
||||
Assert.NotNull(new CredentialSet("target"));
|
||||
});
|
||||
@@ -33,7 +33,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
|
||||
[Fact]
|
||||
public void CredentialSetShouldBeIDisposable()
|
||||
{
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
{
|
||||
Assert.True(new CredentialSet() is IDisposable, "CredentialSet needs to implement IDisposable Interface.");
|
||||
});
|
||||
@@ -42,7 +42,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
|
||||
[Fact]
|
||||
public void CredentialSetLoad()
|
||||
{
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
{
|
||||
Win32Credential credential = new Win32Credential
|
||||
{
|
||||
@@ -67,7 +67,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
|
||||
[Fact]
|
||||
public void CredentialSetLoadShouldReturnSelf()
|
||||
{
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
{
|
||||
CredentialSet set = new CredentialSet();
|
||||
Assert.IsType<CredentialSet>(set.Load());
|
||||
@@ -79,12 +79,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
|
||||
[Fact]
|
||||
public void CredentialSetLoadWithTargetFilter()
|
||||
{
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
RunIfWrapper.RunIfWindows(() =>
|
||||
{
|
||||
Win32Credential credential = new Win32Credential
|
||||
{
|
||||
Username = "filteruser",
|
||||
Password = "filterpassword",
|
||||
Password = Guid.NewGuid().ToString(),
|
||||
Target = "filtertarget"
|
||||
};
|
||||
credential.Save();
|
||||
|
||||
Reference in New Issue
Block a user