From c69b403449c4e422acc9279adbb4ffcab67ca424 Mon Sep 17 00:00:00 2001 From: Abhijeet Shah Date: Sun, 14 May 2017 19:38:28 -0700 Subject: [PATCH 1/2] Publishing Test related packages. Adding a feature in TestFramework to accept Custom key/value pairs. Fixing Monitor Test project target framework. Updating versions for HttpRecorder, Azure.Authentication and TestFramework --- .../Monitor.Tests/Monitor.Tests.csproj | 2 +- ....ClientRuntime.Azure.Authentication.csproj | 4 +-- .../Properties/AssemblyInfo.cs | 2 +- .../ConnectionString.cs | 16 ++++++--- ...t.ClientRuntime.Azure.TestFramework.csproj | 10 ++++-- .../Properties/AssemblyInfo.cs | 11 +++--- .../Microsoft.Azure.Test.HttpRecorder.csproj | 2 +- .../Properties/AssemblyInfo.cs | 4 +-- .../ConnectionStringParseTests.cs | 34 +++++++++++++------ .../TestFramework.Tests.csproj | 33 +++++++----------- 10 files changed, 67 insertions(+), 51 deletions(-) diff --git a/src/SDKs/Monitor/Monitor.Tests/Monitor.Tests.csproj b/src/SDKs/Monitor/Monitor.Tests/Monitor.Tests.csproj index 3c85e94eed82..f22c598bd6a7 100644 --- a/src/SDKs/Monitor/Monitor.Tests/Monitor.Tests.csproj +++ b/src/SDKs/Monitor/Monitor.Tests/Monitor.Tests.csproj @@ -5,7 +5,7 @@ Monitor.Tests Class library Monitor.Tests 1.0.0-preview - net452 + netcoreapp1.1 diff --git a/src/SdkCommon/ClientRuntime.Azure.Authentication/Microsoft.Rest.ClientRuntime.Azure.Authentication.csproj b/src/SdkCommon/ClientRuntime.Azure.Authentication/Microsoft.Rest.ClientRuntime.Azure.Authentication.csproj index 7b7ea3c00810..9eb8b6b8e1b0 100644 --- a/src/SdkCommon/ClientRuntime.Azure.Authentication/Microsoft.Rest.ClientRuntime.Azure.Authentication.csproj +++ b/src/SdkCommon/ClientRuntime.Azure.Authentication/Microsoft.Rest.ClientRuntime.Azure.Authentication.csproj @@ -5,7 +5,7 @@ Provides ADAL based authentication for Azure management client libraries Microsoft.Rest.ClientRuntime.Azure.Authentication Authentication for Azure Management Clients - 2.2.13 + 2.3.0 Microsoft AutoRest ClientRuntime Authentication $(NugetCommonTags) $(NugetCommonProfileTags) @@ -16,7 +16,7 @@ - + \ No newline at end of file diff --git a/src/SdkCommon/ClientRuntime.Azure.Authentication/Properties/AssemblyInfo.cs b/src/SdkCommon/ClientRuntime.Azure.Authentication/Properties/AssemblyInfo.cs index 3ace276c62f4..a256cc4a8ee8 100644 --- a/src/SdkCommon/ClientRuntime.Azure.Authentication/Properties/AssemblyInfo.cs +++ b/src/SdkCommon/ClientRuntime.Azure.Authentication/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyTitle("Microsoft Rest Azure Client Runtime Authentication")] [assembly: AssemblyDescription("Client authentication infrastructure for Azure client libraries.")] [assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.2.13.0")] +[assembly: AssemblyFileVersion("2.3.0.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft Corporation")] diff --git a/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/ConnectionString.cs b/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/ConnectionString.cs index f7e982d75235..3618188e22b9 100644 --- a/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/ConnectionString.cs +++ b/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/ConnectionString.cs @@ -230,7 +230,7 @@ internal bool HasNonEmptyValue(string connStrKey) /// Semicolon delimented KeyValue pair(e.g. KeyName1=value1;KeyName2=value2;KeyName3=value3) public void Parse(string connString) { - string keyName; + //string keyName; string parseRegEx = @"(?[^=]+)=(?.+)"; if (_parseErrorSb != null) _parseErrorSb.Clear(); @@ -257,14 +257,22 @@ public void Parse(string connString) if (m.Groups.Count > 2) { - keyName = m.Groups["KeyName"].Value.ToLower(); + string keyName = m.Groups["KeyName"].Value; + string newValue = m.Groups["KeyValue"].Value; + if (KeyValuePairs.ContainsKey(keyName)) { - KeyValuePairs[keyName] = m.Groups["KeyValue"].Value; + string existingValue = KeyValuePairs[keyName]; + // Replace if the existing value do not match. + // We allow existing key values to be overwritten (this is especially true for endpoints) + if (!existingValue.Equals(newValue, StringComparison.OrdinalIgnoreCase)) + { + KeyValuePairs[keyName] = newValue; + } } else { - ParseErrors = string.Format("'{0}' invalid keyname", keyName); + KeyValuePairs[keyName] = newValue; } } else diff --git a/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Microsoft.Rest.ClientRuntime.Azure.TestFramework.csproj b/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Microsoft.Rest.ClientRuntime.Azure.TestFramework.csproj index f99309452091..b0d624ec0ef0 100644 --- a/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Microsoft.Rest.ClientRuntime.Azure.TestFramework.csproj +++ b/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Microsoft.Rest.ClientRuntime.Azure.TestFramework.csproj @@ -1,10 +1,9 @@  - Microsoft.Rest.ClientRuntime.Azure.TestFramework Test framework for Microsoft AutoRest Generated Clients - 1.6.0 + 1.7.0 Microsoft.Rest.ClientRuntime.Azure.TestFramework Microsoft.Rest.ClientRuntime.Azure.TestFramework Microsoft AutoRest ClientRuntime REST TestFramework @@ -15,9 +14,14 @@ - + + + + diff --git a/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Properties/AssemblyInfo.cs b/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Properties/AssemblyInfo.cs index 5d9d6bb8937b..a9f94c5d3ebb 100644 --- a/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Properties/AssemblyInfo.cs +++ b/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Properties/AssemblyInfo.cs @@ -3,12 +3,12 @@ using System.Reflection; using System.Runtime.InteropServices; -/* + [assembly: AssemblyTitle("Microsoft.Rest.ClientRuntime.Azure.TestFramework.Framework")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("Microsoft.Rest.ClientRuntime.Azure.TestFramework.Framework")] [assembly: AssemblyCopyright("Microsoft (c) 2015")] -*/ + // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. @@ -16,7 +16,6 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("6eb355e3-e1e1-4f46-bcfa-737812ccff87")] -/* -[assembly: AssemblyVersion("1.5.0.0")] -[assembly: AssemblyFileVersion("1.5.3.0")] -*/ \ No newline at end of file + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.6.0.0")] diff --git a/src/SdkCommon/TestFramework/Microsoft.Azure.Test.HttpRecorder/Microsoft.Azure.Test.HttpRecorder.csproj b/src/SdkCommon/TestFramework/Microsoft.Azure.Test.HttpRecorder/Microsoft.Azure.Test.HttpRecorder.csproj index c762cd124d88..9206bd495c7f 100644 --- a/src/SdkCommon/TestFramework/Microsoft.Azure.Test.HttpRecorder/Microsoft.Azure.Test.HttpRecorder.csproj +++ b/src/SdkCommon/TestFramework/Microsoft.Azure.Test.HttpRecorder/Microsoft.Azure.Test.HttpRecorder.csproj @@ -3,7 +3,7 @@ Microsoft.Azure.Test.HttpRecorder HttpRecorder Library for recording Clinet/Server communication in Azure - 1.7.0 + 1.8.0 Microsoft.Azure.Test.HttpRecorder Microsoft.Azure.Test.HttpRecorder Microsoft AutoRest ClientRuntime HttpRecorder REST;$(CommonNugetPackageTags) diff --git a/src/SdkCommon/TestFramework/Microsoft.Azure.Test.HttpRecorder/Properties/AssemblyInfo.cs b/src/SdkCommon/TestFramework/Microsoft.Azure.Test.HttpRecorder/Properties/AssemblyInfo.cs index fc801efb33a1..9c6fb21444f6 100644 --- a/src/SdkCommon/TestFramework/Microsoft.Azure.Test.HttpRecorder/Properties/AssemblyInfo.cs +++ b/src/SdkCommon/TestFramework/Microsoft.Azure.Test.HttpRecorder/Properties/AssemblyInfo.cs @@ -11,7 +11,6 @@ [assembly: Guid("c77934b2-fc7c-4f23-b2e1-12da90bfe716")] -/* [assembly: AssemblyTitle("HttpRecorder")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] @@ -23,5 +22,4 @@ [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.6.9.0")] -*/ \ No newline at end of file +[assembly: AssemblyFileVersion("1.8.0.0")] \ No newline at end of file diff --git a/src/SdkCommon/TestFramework/TestFramework.Tests/TestEnvironment/ConnectionStringParseTests.cs b/src/SdkCommon/TestFramework/TestFramework.Tests/TestEnvironment/ConnectionStringParseTests.cs index 2a78b6c4e3f6..21788736c066 100644 --- a/src/SdkCommon/TestFramework/TestFramework.Tests/TestEnvironment/ConnectionStringParseTests.cs +++ b/src/SdkCommon/TestFramework/TestFramework.Tests/TestEnvironment/ConnectionStringParseTests.cs @@ -60,16 +60,7 @@ public void NoKeyValueString() connStr.Parse(missingKeyValue); Assert.True(string.IsNullOrEmpty(connStr.ParseErrors)); } - - [Fact] - public void InvalidKeyValuePairString() - { - // invalid KeyValue Connection string - string legalConnStrWithInvalidKeyNames = @"foo=bar;hello=world"; - connStr.Parse(legalConnStrWithInvalidKeyNames); - Assert.False(string.IsNullOrEmpty(connStr.ParseErrors)); - } - + [Fact] public void MalformedString() { @@ -121,6 +112,29 @@ public void UserIdAndPasswordButNoSPNSecret() Assert.Equal(string.Empty, connStr.KeyValuePairs["ServicePrincipalSecret".ToLower()]); } + [Fact] + public void CustomKeyValuesInConnStr() + { + // This test will test if custome Key-Value pairs are honored. + // Also if there are duplicate keys, it will pick the last occurance of the key, + // and will overwrite earlier instances of the same key + + string clientIdButNoSPN = @"MyKey=MyValue;MyKey=NewValue;CustomKey=CustomValue;AADClientId=alsdkfjalakdsjflasdj;UserId=Hello@world.com"; + connStr.Parse(clientIdButNoSPN); + Assert.Equal(string.Empty, connStr.ParseErrors); + + //ServicePrincipal will be updated with AADClientId + Assert.NotEqual(string.Empty, connStr.KeyValuePairs["ServicePrincipal"]); + + // Earlier instance of the same key will be overwritten + Assert.NotEqual("MyValue", connStr.KeyValuePairs["MyKey"]); + + // last instance of the same key is retained + Assert.Equal("NewValue", connStr.KeyValuePairs["MyKey"]); + + Assert.Equal("CustomValue", connStr.KeyValuePairs["CustomKey"]); + } + private string CreateConnStrWithAllPossibleValues() { string sampleUrl = "http://www.somefoo.com"; diff --git a/src/SdkCommon/TestFramework/TestFramework.Tests/TestFramework.Tests.csproj b/src/SdkCommon/TestFramework/TestFramework.Tests/TestFramework.Tests.csproj index 82484a8f4380..6a02a135bd8b 100644 --- a/src/SdkCommon/TestFramework/TestFramework.Tests/TestFramework.Tests.csproj +++ b/src/SdkCommon/TestFramework/TestFramework.Tests/TestFramework.Tests.csproj @@ -11,31 +11,24 @@ true - - - - - + + + - - - + + - - + - - - PreserveNewest From 28454c01c2da23c2fd6c2854db304f276459a10f Mon Sep 17 00:00:00 2001 From: Abhijeet Shah Date: Mon, 15 May 2017 17:58:06 -0700 Subject: [PATCH 2/2] Incorporating PR feedback and reverting a version that is not to be increased --- .../ClientRuntime.Azure.TestFramework/ConnectionString.cs | 1 - .../Microsoft.Rest.ClientRuntime.Azure.TestFramework.csproj | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/ConnectionString.cs b/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/ConnectionString.cs index 3618188e22b9..bfdca3e045b5 100644 --- a/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/ConnectionString.cs +++ b/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/ConnectionString.cs @@ -230,7 +230,6 @@ internal bool HasNonEmptyValue(string connStrKey) /// Semicolon delimented KeyValue pair(e.g. KeyName1=value1;KeyName2=value2;KeyName3=value3) public void Parse(string connString) { - //string keyName; string parseRegEx = @"(?[^=]+)=(?.+)"; if (_parseErrorSb != null) _parseErrorSb.Clear(); diff --git a/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Microsoft.Rest.ClientRuntime.Azure.TestFramework.csproj b/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Microsoft.Rest.ClientRuntime.Azure.TestFramework.csproj index b0d624ec0ef0..369f492ff777 100644 --- a/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Microsoft.Rest.ClientRuntime.Azure.TestFramework.csproj +++ b/src/SdkCommon/TestFramework/ClientRuntime.Azure.TestFramework/Microsoft.Rest.ClientRuntime.Azure.TestFramework.csproj @@ -3,7 +3,7 @@ Microsoft.Rest.ClientRuntime.Azure.TestFramework Test framework for Microsoft AutoRest Generated Clients - 1.7.0 + 1.6.0 Microsoft.Rest.ClientRuntime.Azure.TestFramework Microsoft.Rest.ClientRuntime.Azure.TestFramework Microsoft AutoRest ClientRuntime REST TestFramework