Handle null passwords when creating SecureStrings in AdminService (#457)

This commit is contained in:
Matt Irvine
2017-09-14 11:06:15 -07:00
committed by GitHub
parent 84ea045572
commit 52913aa815
2 changed files with 47 additions and 4 deletions

View File

@@ -0,0 +1,36 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System.Security;
using Xunit;
using Microsoft.SqlTools.ServiceLayer.Admin;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Admin
{
/// <summary>
/// Tests for AdminService Class
/// </summary>
public class AdminServiceTests
{
[Fact]
public void TestBuildingSecureStringFromPassword()
{
string password = "test_password";
var secureString = AdminService.BuildSecureStringFromPassword(password);
Assert.Equal(password.Length, secureString.Length);
}
[Fact]
public void TestBuildingSecureStringFromNullPassword()
{
string password = null;
var secureString = AdminService.BuildSecureStringFromPassword(password);
Assert.Equal(0, secureString.Length);
}
}
}