Permalink
Browse files

Fix two credentials related unit tests

  • Loading branch information...
davidebbo committed Aug 24, 2017
1 parent 8dac71c commit 6b91936f8c4dfd6bb1f962a4717f05ba5bc3a50e
Showing with 19 additions and 14 deletions.
  1. +19 −14 Kudu.SiteManagement.Test/Configuration/KuduConfigurationFacts.cs
@@ -2,12 +2,11 @@
using System.Collections.Specialized; using System.Collections.Specialized;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net;
using System.Reflection; using System.Reflection;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using Kudu.Client.Infrastructure;
using Kudu.SiteManagement.Configuration; using Kudu.SiteManagement.Configuration;
using Kudu.SiteManagement.Configuration.Section; using Kudu.SiteManagement.Configuration.Section;
using Kudu.SiteManagement.Configuration.Section.Cert;
using Kudu.SiteManagement.Test.Configuration.Fakes; using Kudu.SiteManagement.Test.Configuration.Fakes;
using Xunit; using Xunit;
@@ -16,22 +15,28 @@ namespace Kudu.SiteManagement.Test.Configuration
public class KuduConfigurationFacts public class KuduConfigurationFacts
{ {
[Fact] [Fact]
public void BasicAuthCredential_NoConfiguration_ReturnDefaultCredential( ) { public void BasicAuthCredential_NoConfiguration_ReturnDefaultCredential()
var appSettingsFake = new NameValueCollection( ); {
var appSettingsFake = new NameValueCollection();
IKuduConfiguration config = CreateConfiguration( null , appSettingsFake ); IKuduConfiguration config = CreateConfiguration(null, appSettingsFake);
var defaultCredential = new System.Net.NetworkCredential( "admin" , "kudu" ); var defaultCredential = new NetworkCredential("admin", "kudu");
Assert.Equal( defaultCredential , config.BasicAuthCredential.GetCredentials( ) ); var configCredentials = (NetworkCredential)config.BasicAuthCredential.GetCredentials();
Assert.Equal(defaultCredential.UserName, configCredentials.UserName);
Assert.Equal(defaultCredential.Password, configCredentials.Password);
} }
[Fact] [Fact]
public void BasicAuthCredential_WithConfigurationSection_ReturnBasicAuthCredentialProvider( ) { public void BasicAuthCredential_WithConfigurationSection_ReturnBasicAuthCredentialProvider()
var configFake = new KuduConfigurationSectionFake( ); {
configFake.SetFake( "basicAuth" , BasicAuthConfigurationElementFake.Fake( "testingUser" , "testingPw" ) ); var configFake = new KuduConfigurationSectionFake();
configFake.SetFake("basicAuth", BasicAuthConfigurationElementFake.Fake("testingUser", "testingPw"));
IKuduConfiguration config = CreateConfiguration( configFake , new NameValueCollection( ) ); IKuduConfiguration config = CreateConfiguration(configFake, new NameValueCollection());
var testingCredential = new System.Net.NetworkCredential( "testingUser" , "testingPw" ); var testingCredential = new NetworkCredential("testingUser", "testingPw");
Assert.Equal( testingCredential , config.BasicAuthCredential.GetCredentials( ) ); var configCredentials = (NetworkCredential)config.BasicAuthCredential.GetCredentials();
Assert.Equal(testingCredential.UserName, configCredentials.UserName);
Assert.Equal(testingCredential.Password, configCredentials.Password);
} }
[Fact] [Fact]

0 comments on commit 6b91936

Please sign in to comment.