From e937884eb43e40d89a8c02ecea38bf1ec3f2d055 Mon Sep 17 00:00:00 2001 From: Scott Addie <10702007+scottaddie@users.noreply.github.com> Date: Wed, 19 Feb 2020 12:25:28 -0600 Subject: [PATCH 1/5] Secret Manager: Save project file without XML declaration (#14354) --- .../dotnet-user-secrets/src/Internal/InitCommand.cs | 12 +++++++++++- .../dotnet-user-secrets/test/InitCommandTest.cs | 13 +++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs b/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs index e54f04ff7c..5b8b038596 100644 --- a/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs +++ b/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs @@ -4,6 +4,7 @@ using System; using System.IO; using System.Linq; +using System.Xml; using System.Xml.Linq; using System.Xml.XPath; using Microsoft.Extensions.CommandLineUtils; @@ -122,7 +123,16 @@ namespace Microsoft.Extensions.SecretManager.Tools.Internal propertyGroup.Add(new XElement("UserSecretsId", newSecretsId)); } - projectDocument.Save(projectPath); + var settings = new XmlWriterSettings + { + Indent = true, + OmitXmlDeclaration = true, + }; + + using (var xw = XmlWriter.Create(projectPath, settings)) + { + projectDocument.Save(xw); + } context.Reporter.Output(Resources.FormatMessage_SetUserSecretsIdForProject(newSecretsId, projectPath)); } diff --git a/src/Tools/dotnet-user-secrets/test/InitCommandTest.cs b/src/Tools/dotnet-user-secrets/test/InitCommandTest.cs index 562f149ca4..ee0efce15f 100644 --- a/src/Tools/dotnet-user-secrets/test/InitCommandTest.cs +++ b/src/Tools/dotnet-user-secrets/test/InitCommandTest.cs @@ -4,6 +4,7 @@ using System; using System.IO; using System.Text; +using System.Xml.Linq; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Configuration.UserSecrets.Tests; using Microsoft.Extensions.SecretManager.Tools.Internal; @@ -90,6 +91,18 @@ namespace Microsoft.Extensions.SecretManager.Tools.Tests Assert.Equal(SecretId, idResolver.Resolve(null, null)); } + [Fact] + public void DoesNotAddXmlDeclarationToProject() + { + var projectDir = _fixture.CreateProject(null); + var projectFile = Path.Combine(projectDir, "TestProject.csproj"); + + new InitCommand(null, null).Execute(MakeCommandContext(), projectDir); + + var projectDocument = XDocument.Load(projectFile); + Assert.Null(projectDocument.Declaration); + } + [Fact] public void OverridesIdForProjectWithSecretId() { From 1e4438647c834c3ffa9474d04b48d4a72c3e8978 Mon Sep 17 00:00:00 2001 From: Kahbazi Date: Wed, 19 Feb 2020 22:54:35 +0330 Subject: [PATCH 2/5] Add Email claim (#18580) --- ...oft.Extensions.Identity.Core.netcoreapp.cs | 1 + ...Extensions.Identity.Core.netstandard2.0.cs | 1 + .../src/ClaimsIdentityOptions.cs | 7 ++++- .../src/UserClaimsPrincipalFactory.cs | 10 ++++++- .../UserClaimsPrincipalFactoryTest.cs | 28 +++++++++++++------ 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netcoreapp.cs b/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netcoreapp.cs index 13979d60ae..fa44115139 100644 --- a/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netcoreapp.cs +++ b/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netcoreapp.cs @@ -15,6 +15,7 @@ namespace Microsoft.AspNetCore.Identity public partial class ClaimsIdentityOptions { public ClaimsIdentityOptions() { } + public string EmailClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string RoleClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string SecurityStampClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string UserIdClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } diff --git a/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netstandard2.0.cs b/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netstandard2.0.cs index 13979d60ae..fa44115139 100644 --- a/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netstandard2.0.cs +++ b/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netstandard2.0.cs @@ -15,6 +15,7 @@ namespace Microsoft.AspNetCore.Identity public partial class ClaimsIdentityOptions { public ClaimsIdentityOptions() { } + public string EmailClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string RoleClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string SecurityStampClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string UserIdClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } diff --git a/src/Identity/Extensions.Core/src/ClaimsIdentityOptions.cs b/src/Identity/Extensions.Core/src/ClaimsIdentityOptions.cs index 54ba1ae069..17f383ab33 100644 --- a/src/Identity/Extensions.Core/src/ClaimsIdentityOptions.cs +++ b/src/Identity/Extensions.Core/src/ClaimsIdentityOptions.cs @@ -25,9 +25,14 @@ namespace Microsoft.AspNetCore.Identity /// public string UserIdClaimType { get; set; } = ClaimTypes.NameIdentifier; + /// + /// Gets or sets the ClaimType used for the user email claim. Defaults to . + /// + public string EmailClaimType { get; set; } = ClaimTypes.Email; + /// /// Gets or sets the ClaimType used for the security stamp claim. Defaults to "AspNet.Identity.SecurityStamp". /// public string SecurityStampClaimType { get; set; } = "AspNet.Identity.SecurityStamp"; } -} \ No newline at end of file +} diff --git a/src/Identity/Extensions.Core/src/UserClaimsPrincipalFactory.cs b/src/Identity/Extensions.Core/src/UserClaimsPrincipalFactory.cs index dd7e316423..859e78ad57 100644 --- a/src/Identity/Extensions.Core/src/UserClaimsPrincipalFactory.cs +++ b/src/Identity/Extensions.Core/src/UserClaimsPrincipalFactory.cs @@ -81,6 +81,14 @@ namespace Microsoft.AspNetCore.Identity Options.ClaimsIdentity.RoleClaimType); id.AddClaim(new Claim(Options.ClaimsIdentity.UserIdClaimType, userId)); id.AddClaim(new Claim(Options.ClaimsIdentity.UserNameClaimType, userName)); + if (UserManager.SupportsUserEmail) + { + var email = await UserManager.GetEmailAsync(user); + if (!string.IsNullOrEmpty(email)) + { + id.AddClaim(new Claim(Options.ClaimsIdentity.EmailClaimType, email)); + } + } if (UserManager.SupportsUserSecurityStamp) { id.AddClaim(new Claim(Options.ClaimsIdentity.SecurityStampClaimType, @@ -154,4 +162,4 @@ namespace Microsoft.AspNetCore.Identity return id; } } -} \ No newline at end of file +} diff --git a/src/Identity/test/Identity.Test/UserClaimsPrincipalFactoryTest.cs b/src/Identity/test/Identity.Test/UserClaimsPrincipalFactoryTest.cs index befed38dd9..bcf42f459d 100644 --- a/src/Identity/test/Identity.Test/UserClaimsPrincipalFactoryTest.cs +++ b/src/Identity/test/Identity.Test/UserClaimsPrincipalFactoryTest.cs @@ -30,22 +30,33 @@ namespace Microsoft.AspNetCore.Identity.Test } [Theory] - [InlineData(false, false, false)] - [InlineData(false, true, false)] - [InlineData(true, false, false)] - [InlineData(true, true, false)] - [InlineData(true, false, true)] - [InlineData(true, true, true)] - public async Task EnsureClaimsIdentityHasExpectedClaims(bool supportRoles, bool supportClaims, bool supportRoleClaims) + [InlineData(true, false, false, false)] + [InlineData(true, true, false, false)] + [InlineData(true, false, true, false)] + [InlineData(true, true, true, false)] + [InlineData(false, false, false, true)] + [InlineData(false, true, false, true)] + [InlineData(false, false, false, false)] + [InlineData(false, true, false, false)] + [InlineData(true, false, false, true)] + [InlineData(true, true, false, true)] + [InlineData(true, false, true, true)] + [InlineData(true, true, true, true)] + public async Task EnsureClaimsIdentityHasExpectedClaims(bool supportRoles, bool supportClaims, bool supportRoleClaims, bool supportsUserEmail) { // Setup var userManager = MockHelpers.MockUserManager(); var roleManager = MockHelpers.MockRoleManager(); - var user = new PocoUser { UserName = "Foo" }; + var user = new PocoUser { UserName = "Foo", Email = "foo@bar.com" }; userManager.Setup(m => m.SupportsUserClaim).Returns(supportClaims); userManager.Setup(m => m.SupportsUserRole).Returns(supportRoles); + userManager.Setup(m => m.SupportsUserEmail).Returns(supportsUserEmail); userManager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id); userManager.Setup(m => m.GetUserNameAsync(user)).ReturnsAsync(user.UserName); + if (supportsUserEmail) + { + userManager.Setup(m => m.GetEmailAsync(user)).ReturnsAsync(user.Email); + } var roleClaims = new[] { "Admin", "Local" }; if (supportRoles) { @@ -90,6 +101,7 @@ namespace Microsoft.AspNetCore.Identity.Test Assert.Contains( claims, c => c.Type == manager.Options.ClaimsIdentity.UserNameClaimType && c.Value == user.UserName); Assert.Contains(claims, c => c.Type == manager.Options.ClaimsIdentity.UserIdClaimType && c.Value == user.Id); + Assert.Equal(supportsUserEmail, claims.Any(c => c.Type == manager.Options.ClaimsIdentity.EmailClaimType && c.Value == user.Email)); Assert.Equal(supportRoles, claims.Any(c => c.Type == manager.Options.ClaimsIdentity.RoleClaimType && c.Value == "Admin")); Assert.Equal(supportRoles, claims.Any(c => c.Type == manager.Options.ClaimsIdentity.RoleClaimType && c.Value == "Local")); foreach (var cl in userClaims) From e3a5f03e2474b08c75911dc959f63ae37a0594f5 Mon Sep 17 00:00:00 2001 From: Brennan Date: Wed, 19 Feb 2020 13:18:12 -0800 Subject: [PATCH 3/5] Run Java tests on Helix (#18938) --- .azure/pipelines/jobs/default-build.yml | 2 +- .gitattributes | 5 ++ Directory.Build.props | 1 + Directory.Build.targets | 1 + eng/helix/content/InstallJdk.ps1 | 62 +++++++++++++++++++ eng/helix/content/installjdk.sh | 46 ++++++++++++++ eng/helix/content/installnode.sh | 12 +++- eng/targets/CSharp.Common.props | 1 - eng/targets/CSharp.Common.targets | 2 +- eng/targets/Helix.props | 14 +---- eng/targets/Helix.targets | 20 +++++- eng/targets/Npm.Common.targets | 2 +- .../CommonLibTests/CommonLibTests.vcxproj | 3 + src/SignalR/clients/java/signalr/.gitignore | 1 + src/SignalR/clients/java/signalr/build.gradle | 6 +- ...roj => signalr.client.java.Tests.javaproj} | 31 +++++++++- .../SignalR.Npm.FunctionalTests.npmproj | 3 +- 17 files changed, 188 insertions(+), 24 deletions(-) create mode 100644 eng/helix/content/InstallJdk.ps1 create mode 100644 eng/helix/content/installjdk.sh rename src/SignalR/clients/java/signalr/{signalr.client.java.javaproj => signalr.client.java.Tests.javaproj} (67%) diff --git a/.azure/pipelines/jobs/default-build.yml b/.azure/pipelines/jobs/default-build.yml index d9a4e1b58a..dad5a3b6f1 100644 --- a/.azure/pipelines/jobs/default-build.yml +++ b/.azure/pipelines/jobs/default-build.yml @@ -233,7 +233,7 @@ jobs: condition: always() inputs: testRunner: junit - testResultsFiles: '**/TEST-com.microsoft.signalr*.xml' + testResultsFiles: '**/TEST-junit-jupiter.xml' buildConfiguration: $(BuildConfiguration) buildPlatform: $(AgentOsName) mergeTestResults: true diff --git a/.gitattributes b/.gitattributes index ff67a9158f..3225eae5e0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,6 +8,11 @@ ############################################################################### *.sh eol=lf +############################################################################### +# Make gradlew always have LF as line endings +############################################################################### +gradlew eol=lf + ############################################################################### # Set default behavior for command prompt diff. # diff --git a/Directory.Build.props b/Directory.Build.props index b68fd8cb66..a4b4790b40 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -187,5 +187,6 @@ + diff --git a/Directory.Build.targets b/Directory.Build.targets index 01c320019a..c961c8db3e 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -163,5 +163,6 @@ + diff --git a/eng/helix/content/InstallJdk.ps1 b/eng/helix/content/InstallJdk.ps1 new file mode 100644 index 0000000000..a9346062fa --- /dev/null +++ b/eng/helix/content/InstallJdk.ps1 @@ -0,0 +1,62 @@ +<# +.SYNOPSIS + Installs JDK into a folder in this repo. +.DESCRIPTION + This script downloads an extracts the JDK. +.PARAMETER JdkVersion + The version of the JDK to install. If not set, the default value is read from global.json +.PARAMETER Force + Overwrite the existing installation +#> +param( + [string]$JdkVersion, + [Parameter(Mandatory = $false)] + $InstallDir +) +$ErrorActionPreference = 'Stop' +$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138 + +Set-StrictMode -Version 1 + +if ($InstallDir) { + $installDir = $InstallDir; +} +else { + $repoRoot = Resolve-Path "$PSScriptRoot\..\.." + $installDir = "$repoRoot\.tools\jdk\win-x64\" +} +$tempDir = "$installDir\obj" +if (-not $JdkVersion) { + $globalJson = Get-Content "$repoRoot\global.json" | ConvertFrom-Json + $JdkVersion = $globalJson.tools.jdk +} + +if (Test-Path $installDir) { + if ($Force) { + Remove-Item -Force -Recurse $installDir + } + else { + Write-Host "The JDK already installed to $installDir. Exiting without action. Call this script again with -Force to overwrite." + exit 0 + } +} + +Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null +mkdir $tempDir -ea Ignore | out-null +mkdir $installDir -ea Ignore | out-null +Write-Host "Starting download of JDK ${JdkVersion}" +Invoke-WebRequest -UseBasicParsing -Uri "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/java/jdk-${JdkVersion}_windows-x64_bin.zip" -OutFile "$tempDir/jdk.zip" +Write-Host "Done downloading JDK ${JdkVersion}" + +Add-Type -assembly "System.IO.Compression.FileSystem" +[System.IO.Compression.ZipFile]::ExtractToDirectory("$tempDir/jdk.zip", "$tempDir/jdk/") + +Write-Host "Expanded JDK to $tempDir" +Write-Host "Installing JDK to $installDir" +Move-Item "$tempDir/jdk/jdk-${JdkVersion}/*" $installDir +Write-Host "Done installing JDK to $installDir" +Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null + +if ($env:TF_BUILD) { + Write-Host "##vso[task.prependpath]$installDir\bin" +} diff --git a/eng/helix/content/installjdk.sh b/eng/helix/content/installjdk.sh new file mode 100644 index 0000000000..6c1c2ff5c6 --- /dev/null +++ b/eng/helix/content/installjdk.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Cause the script to fail if any subcommand fails +set -e + +pushd . + +if [ "$JAVA_HOME" != "" ]; then + echo "JAVA_HOME is set" + exit +fi + +java_version=$1 +arch=$2 +osname=`uname -s` +if [ "$osname" = "Darwin" ]; then + echo "macOS not supported, relying on the machine providing java itself" + exit 1 +else + platformarch="linux-$arch" +fi +echo "PlatformArch: $platformarch" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +output_dir="$DIR/java" +url="https://netcorenativeassets.blob.core.windows.net/resource-packages/external/linux/java/jdk-${java_version}_${platformarch}_bin.tar.gz" +echo "Downloading from: $url" +tmp="$(mktemp -d -t install-jdk.XXXXXX)" + +cleanup() { + exitcode=$? + if [ $exitcode -ne 0 ]; then + echo "Failed to install java with exit code: $exitcode" + fi + rm -rf "$tmp" + exit $exitcode +} + +trap "cleanup" EXIT +cd "$tmp" +curl -Lsfo $(basename $url) "$url" +echo "Installing java from $(basename $url) $url" +mkdir $output_dir +echo "Unpacking to $output_dir" +tar --strip-components 1 -xzf "jdk-${java_version}_${platformarch}_bin.tar.gz" --no-same-owner --directory "$output_dir" + +popd \ No newline at end of file diff --git a/eng/helix/content/installnode.sh b/eng/helix/content/installnode.sh index 0442958ac2..db5d2fa5a5 100644 --- a/eng/helix/content/installnode.sh +++ b/eng/helix/content/installnode.sh @@ -22,7 +22,17 @@ output_dir="$DIR/node" url="http://nodejs.org/dist/v$node_version/node-v$node_version-$platformarch.tar.gz" echo "Downloading from: $url" tmp="$(mktemp -d -t install-node.XXXXXX)" -trap "rm -rf $tmp" EXIT + +cleanup() { + exitcode=$? + if [ $exitcode -ne 0 ]; then + echo "Failed to install node with exit code: $exitcode" + fi + rm -rf "$tmp" + exit $exitcode +} + +trap "cleanup" EXIT cd "$tmp" curl -Lsfo $(basename $url) "$url" echo "Installing node from $(basename $url) $url" diff --git a/eng/targets/CSharp.Common.props b/eng/targets/CSharp.Common.props index 6cc6bd2dd8..4600fad635 100644 --- a/eng/targets/CSharp.Common.props +++ b/eng/targets/CSharp.Common.props @@ -35,6 +35,5 @@ - diff --git a/eng/targets/CSharp.Common.targets b/eng/targets/CSharp.Common.targets index 877665a63b..e327a7b886 100644 --- a/eng/targets/CSharp.Common.targets +++ b/eng/targets/CSharp.Common.targets @@ -30,5 +30,5 @@ - + diff --git a/eng/targets/Helix.props b/eng/targets/Helix.props index 40e9420500..d36c4a1a7a 100644 --- a/eng/targets/Helix.props +++ b/eng/targets/Helix.props @@ -15,6 +15,8 @@ false false true + false + true $(MSBuildProjectName)--$(TargetFramework) false false @@ -33,16 +35,4 @@ - - - - - - - - - - - - diff --git a/eng/targets/Helix.targets b/eng/targets/Helix.targets index f3d1ad0f16..eecd36f02a 100644 --- a/eng/targets/Helix.targets +++ b/eng/targets/Helix.targets @@ -1,10 +1,26 @@ + + + + + + + + + + + + + + + + - + @@ -91,6 +108,7 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj @(HelixPostCommand) call runtests.cmd $(TargetFileName) $(TargetFrameworkIdentifier) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) ./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) + $(HelixCommand) $(HelixTimeout) diff --git a/eng/targets/Npm.Common.targets b/eng/targets/Npm.Common.targets index fd15a8e45e..3460edde2e 100644 --- a/eng/targets/Npm.Common.targets +++ b/eng/targets/Npm.Common.targets @@ -119,7 +119,7 @@ - + diff --git a/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj index d8d0ef653b..a49803ecce 100644 --- a/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj +++ b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj @@ -1,4 +1,7 @@  + + false + Debug diff --git a/src/SignalR/clients/java/signalr/.gitignore b/src/SignalR/clients/java/signalr/.gitignore index eabba7738e..3e9534ce39 100644 --- a/src/SignalR/clients/java/signalr/.gitignore +++ b/src/SignalR/clients/java/signalr/.gitignore @@ -2,6 +2,7 @@ .gradletasknamecache .gradle/ build/ +/test-results .settings/ out/ *.class diff --git a/src/SignalR/clients/java/signalr/build.gradle b/src/SignalR/clients/java/signalr/build.gradle index 4b18bba589..b845d83949 100644 --- a/src/SignalR/clients/java/signalr/build.gradle +++ b/src/SignalR/clients/java/signalr/build.gradle @@ -6,6 +6,7 @@ buildscript { } dependencies { classpath "com.diffplug.spotless:spotless-plugin-gradle:3.14.0" + classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0' } } @@ -16,6 +17,7 @@ plugins { apply plugin: "java-library" apply plugin: "com.diffplug.gradle.spotless" +apply plugin: 'org.junit.platform.gradle.plugin' group 'com.microsoft.signalr' @@ -64,8 +66,8 @@ spotless { } } -test { - useJUnitPlatform() +junitPlatform { + reportsDir file('test-results') } task sourceJar(type: Jar) { diff --git a/src/SignalR/clients/java/signalr/signalr.client.java.javaproj b/src/SignalR/clients/java/signalr/signalr.client.java.Tests.javaproj similarity index 67% rename from src/SignalR/clients/java/signalr/signalr.client.java.javaproj rename to src/SignalR/clients/java/signalr/signalr.client.java.Tests.javaproj index 15eeed479f..d037c1468f 100644 --- a/src/SignalR/clients/java/signalr/signalr.client.java.javaproj +++ b/src/SignalR/clients/java/signalr/signalr.client.java.Tests.javaproj @@ -1,5 +1,5 @@ - - + + @@ -15,6 +15,9 @@ $(GradleOptions) -Dorg.gradle.daemon=false + $(OutputPath) + true + @@ -51,15 +54,37 @@ - + + + + + + + + + + + + + + + $(GradleOptions) -PpackageVersion="$(PackageVersion)" + chmod +x ./gradlew && ./gradlew $(GradleOptions) test + call gradlew $(GradleOptions) test + + + + + + diff --git a/src/SignalR/clients/ts/FunctionalTests/SignalR.Npm.FunctionalTests.npmproj b/src/SignalR/clients/ts/FunctionalTests/SignalR.Npm.FunctionalTests.npmproj index 6314e22990..8f89229340 100644 --- a/src/SignalR/clients/ts/FunctionalTests/SignalR.Npm.FunctionalTests.npmproj +++ b/src/SignalR/clients/ts/FunctionalTests/SignalR.Npm.FunctionalTests.npmproj @@ -9,6 +9,7 @@ <_TestSauceArgs Condition="'$(BrowserTestHostName)' != ''">$(_TestSauceArgs) --use-hostname "$(BrowserTestHostName)" run test:inner --no-color --configuration $(Configuration) run build:inner + false @@ -18,7 +19,7 @@ - + From 76d197f0dd0d0835585d82540f35acde9db5a0d5 Mon Sep 17 00:00:00 2001 From: Roman Marusyk Date: Wed, 19 Feb 2020 23:39:24 +0200 Subject: [PATCH 4/5] Add XML Documentation to ResponseCachingMiddleware and ResponseCachingExtensions (#18968) * Add XML Documentation to ResponseCachingMiddleware and ResponseCachingExtensions * Update src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs Co-Authored-By: Andrew Stanton-Nurse * Update src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs Co-Authored-By: Andrew Stanton-Nurse * Update src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs Co-Authored-By: Andrew Stanton-Nurse * Update src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs Co-Authored-By: Andrew Stanton-Nurse * Update src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs Co-Authored-By: Andrew Stanton-Nurse * Update ResponseCachingMiddleware.cs Co-authored-by: Andrew Stanton-Nurse --- .../src/ResponseCachingExtensions.cs | 7 +++++++ .../src/ResponseCachingMiddleware.cs | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs b/src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs index 45d905cea6..8dff8eb2f5 100644 --- a/src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs +++ b/src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs @@ -6,8 +6,15 @@ using Microsoft.AspNetCore.ResponseCaching; namespace Microsoft.AspNetCore.Builder { + /// + /// Extension methods for adding the to an application. + /// public static class ResponseCachingExtensions { + /// + /// Adds the for caching HTTP responses. + /// + /// The . public static IApplicationBuilder UseResponseCaching(this IApplicationBuilder app) { if (app == null) diff --git a/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs b/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs index b74d3f47cd..dd75fece9f 100644 --- a/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs +++ b/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs @@ -14,6 +14,9 @@ using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.ResponseCaching { + /// + /// Enable HTTP response caching. + /// public class ResponseCachingMiddleware { private static readonly TimeSpan DefaultExpirationTimeSpan = TimeSpan.FromSeconds(10); @@ -29,6 +32,13 @@ namespace Microsoft.AspNetCore.ResponseCaching private readonly IResponseCache _cache; private readonly IResponseCachingKeyProvider _keyProvider; + /// + /// Creates a new . + /// + /// The representing the next middleware in the pipeline. + /// The options for this middleware. + /// The used for logging. + /// The used for creating instances. public ResponseCachingMiddleware( RequestDelegate next, IOptions options, @@ -88,6 +98,11 @@ namespace Microsoft.AspNetCore.ResponseCaching _keyProvider = keyProvider; } + /// + /// Invokes the logic of the middleware. + /// + /// The . + /// A that completes when the middleware has completed processing. public async Task Invoke(HttpContext httpContext) { var context = new ResponseCachingContext(httpContext, _logger); From b6698757a85f9b6d6c63311e64dd6ac9e734ef56 Mon Sep 17 00:00:00 2001 From: Vaughan Reid Date: Thu, 20 Feb 2020 00:03:36 +0200 Subject: [PATCH 5/5] Activity.Baggage values are now be Url decoded in HostingApplicationDiagnostics. (#18948) --- .../Internal/HostingApplicationDiagnostics.cs | 3 +- .../HostingApplicationDiagnosticsTests.cs | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs b/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs index 16b36948af..41b93ac083 100644 --- a/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs +++ b/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; using System.Runtime.CompilerServices; +using System.Web; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; @@ -272,7 +273,7 @@ namespace Microsoft.AspNetCore.Hosting { if (NameValueHeaderValue.TryParse(item, out var baggageItem)) { - activity.AddBaggage(baggageItem.Name.ToString(), baggageItem.Value.ToString()); + activity.AddBaggage(baggageItem.Name.ToString(), HttpUtility.UrlDecode(baggageItem.Value.ToString())); } } } diff --git a/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs b/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs index 385424fa67..341c7c6fa4 100644 --- a/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs +++ b/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs @@ -345,6 +345,35 @@ namespace Microsoft.AspNetCore.Hosting.Tests Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2"); } + [Fact] + public void ActivityBaggageValuesAreUrlDecodedFromHeaders() + { + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); + + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { }), + s => + { + if (s.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn")) + { + return true; + } + return false; + }); + + features.Set(new HttpRequestFeature() + { + Headers = new HeaderDictionary() + { + {"Request-Id", "ParentId1"}, + {"Correlation-Context", "Key1=value1%2F1"} + } + }); + hostingApplication.CreateContext(features); + Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); + Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1/1"); + } + [Fact] public void ActivityTraceParentAndTraceStateFromHeaders()