mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 09:59:48 -05:00
* CredentialService initial impl with Win32 support - Basic CredentialService APIs for Save, Read, Delete - E2E unit tests for Credential Service - Win32 implementation with unit tests * Save Password support on Mac v1 - Basic keychain support on Mac using Interop with the KeyChain APIs - All but 1 unit test passing. This will pass once API is changed, but checking this in with the existing API so that if we decide to alter behavior, we have a reference point. * Remove Username from Credentials API - Removed Username option from Credentials as this caused conflicting behavior on Mac vs Windows * Cleanup Using Statements and add Copyright * Linux CredentialStore Prototype * Linux credential store support - Full support for Linux credential store with tests * Plumbed CredentialService into Program init * Addressing Pull Request comments
100 lines
2.9 KiB
C#
100 lines
2.9 KiB
C#
//
|
|
// Code originally from http://credentialmanagement.codeplex.com/,
|
|
// Licensed under the Apache License 2.0
|
|
//
|
|
|
|
using System;
|
|
using Microsoft.SqlTools.ServiceLayer.Credentials.Win32;
|
|
using Microsoft.SqlTools.ServiceLayer.Test.Utility;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.Test.Credentials
|
|
{
|
|
public class CredentialSetTests
|
|
{
|
|
[Fact]
|
|
public void CredentialSetCreate()
|
|
{
|
|
TestUtils.RunIfWindows(() =>
|
|
{
|
|
Assert.NotNull(new CredentialSet());
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void CredentialSetCreateWithTarget()
|
|
{
|
|
TestUtils.RunIfWindows(() =>
|
|
{
|
|
Assert.NotNull(new CredentialSet("target"));
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void CredentialSetShouldBeIDisposable()
|
|
{
|
|
TestUtils.RunIfWindows(() =>
|
|
{
|
|
Assert.True(new CredentialSet() is IDisposable, "CredentialSet needs to implement IDisposable Interface.");
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void CredentialSetLoad()
|
|
{
|
|
TestUtils.RunIfWindows(() =>
|
|
{
|
|
Win32Credential credential = new Win32Credential
|
|
{
|
|
Username = "username",
|
|
Password = "password",
|
|
Target = "target",
|
|
Type = CredentialType.Generic
|
|
};
|
|
credential.Save();
|
|
|
|
CredentialSet set = new CredentialSet();
|
|
set.Load();
|
|
Assert.NotNull(set);
|
|
Assert.NotEmpty(set);
|
|
|
|
credential.Delete();
|
|
|
|
set.Dispose();
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void CredentialSetLoadShouldReturnSelf()
|
|
{
|
|
TestUtils.RunIfWindows(() =>
|
|
{
|
|
CredentialSet set = new CredentialSet();
|
|
Assert.IsType<CredentialSet>(set.Load());
|
|
|
|
set.Dispose();
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void CredentialSetLoadWithTargetFilter()
|
|
{
|
|
TestUtils.RunIfWindows(() =>
|
|
{
|
|
Win32Credential credential = new Win32Credential
|
|
{
|
|
Username = "filteruser",
|
|
Password = "filterpassword",
|
|
Target = "filtertarget"
|
|
};
|
|
credential.Save();
|
|
|
|
CredentialSet set = new CredentialSet("filtertarget");
|
|
Assert.Equal(1, set.Load().Count);
|
|
set.Dispose();
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|