Skip to content

Commit

Permalink
Merge pull request #1 from Binkus/develop
Browse files Browse the repository at this point in the history
Update target netcoreapp 2.2 & netstandard 2.0 & Fix RecaptchaOptions.ResponseValidationEndpoint
  • Loading branch information
Binkus authored Mar 16, 2019
2 parents e23562b + 58c35ce commit 22b9d23
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 159 deletions.
4 changes: 2 additions & 2 deletions PaulMiami.AspNetCore.Mvc.Recaptcha.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.3
# Visual Studio Version 16
VisualStudioVersion = 16.0.28711.60
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8A038906-433E-4FFC-BA5F-E01077E81A98}"
EndProject
Expand Down
17 changes: 8 additions & 9 deletions sample/TestWebApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
using System.IO;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;

namespace TestWebApp
{
public class Program
public static class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
BuildWebHost(args).Run();
}

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();

host.Run();
}
}
}
}
17 changes: 5 additions & 12 deletions sample/TestWebApp/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand All @@ -9,18 +8,12 @@ namespace TestWebApp
{
public class Startup
{

public Startup(IHostingEnvironment env)
public Startup(IConfiguration configuration)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddUserSecrets();

Configuration = builder.Build();
Configuration = configuration;
}

public IConfigurationRoot Configuration { get; }
public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
Expand All @@ -35,7 +28,7 @@ public void ConfigureServices(IServiceCollection services)
ValidationMessage = "Are you a robot?"
});
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
Expand All @@ -54,4 +47,4 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
});
}
}
}
}
62 changes: 26 additions & 36 deletions sample/TestWebApp/TestWebApp.csproj
Original file line number Diff line number Diff line change
@@ -1,50 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>TestWebApp</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>TestWebApp</PackageId>
<UserSecretsId>TestWebApp-45EC5266-9512-4AF0-9BA1-F9C3DC7D57D0</UserSecretsId>
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;dnxcore50;portable-net45+win8</PackageTargetFallback>
</PropertyGroup>

<AssetTargetFallback>$(AssetTargetFallback);portable-net47+win8+wp8+wpa81;</AssetTargetFallback>
</PropertyGroup>

<ItemGroup>
<None Update="wwwroot\**\*;Views\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>

<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>

</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\PaulMiami.AspNetCore.Mvc.Recaptcha\PaulMiami.AspNetCore.Mvc.Recaptcha.csproj" />
</ItemGroup>

<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.2.0" PrivateAssets="All" />
</ItemGroup>

<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
<UserSecretsId>recaptcha-testweb-d2ab3bfe-f40f-4885-850b-9a303a9398ea</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.2" />
</ItemGroup>

<ProjectReference Include="..\..\src\PaulMiami.AspNetCore.Mvc.Recaptcha\PaulMiami.AspNetCore.Mvc.Recaptcha.csproj" />
</ItemGroup>

<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<Exec Command="bower install" />
</Target>

</Target>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>

</Project>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>This is a helper library for google reCAPTCHA 2.0
<Description>
This is a helper library for google reCAPTCHA 2.0

Getting started guide:
https://github.com/PaulMiami/reCAPTCHA/wiki/Getting-started
Getting started guide:
https://github.com/PaulMiami/reCAPTCHA/wiki/Getting-started

Change log:
https://github.com/PaulMiami/reCAPTCHA/wiki/Change-log</Description>
Change log:
https://github.com/PaulMiami/reCAPTCHA/wiki/Change-log
</Description>
<AssemblyTitle>reCAPTCHA 2.0 for ASPNET Core </AssemblyTitle>
<VersionPrefix>1.2.1</VersionPrefix>
<Authors>Paul Biccherai</Authors>
<TargetFrameworks>netstandard1.6;net451</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>PaulMiami.AspNetCore.Mvc.Recaptcha</AssemblyName>
<PackageId>PaulMiami.AspNetCore.Mvc.Recaptcha</PackageId>
Expand All @@ -20,7 +22,7 @@ https://github.com/PaulMiami/reCAPTCHA/wiki/Change-log</Description>
<PackageLicenseUrl>https://raw.githubusercontent.com/PaulMiami/reCAPTCHA/master/LICENSE</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/PaulMiami/reCAPTCHA</RepositoryUrl>
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
<NetStandardImplicitPackageVersion>2.0.0</NetStandardImplicitPackageVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
Expand All @@ -32,18 +34,18 @@ https://github.com/PaulMiami/reCAPTCHA/wiki/Change-log</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="1.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<Reference Include="System" />
<Reference Include="System.Net.Http" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

</Project>
</Project>
2 changes: 1 addition & 1 deletion src/PaulMiami.AspNetCore.Mvc.Recaptcha/RecaptchaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public RecaptchaControlSettings ControlSettings

public async Task ValidateResponseAsync(string response, string remoteIp)
{
var request = new HttpRequestMessage(HttpMethod.Post, RecaptchaDefaults.ResponseValidationEndpoint);
var request = new HttpRequestMessage(HttpMethod.Post, _options.ResponseValidationEndpoint);
var paramaters = new Dictionary<string, string>();
paramaters["secret"] = _options.SecretKey;
paramaters["response"] = response;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
<Project Sdk="Microsoft.NET.Sdk">

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>PaulMiami.AspNetCore.Mvc.Recaptcha.Test</AssemblyName>
<PackageId>PaulMiami.AspNetCore.Mvc.Recaptcha.Test</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;dnxcore50;portable-net45+win8</PackageTargetFallback>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>

</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\PaulMiami.AspNetCore.Mvc.Recaptcha\PaulMiami.AspNetCore.Mvc.Recaptcha.csproj" />
<ProjectReference Include="..\WebSites\TestSite\TestSite.csproj" />
</ItemGroup>

</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="1.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="1.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="1.2.0-preview1-23565" />
<PackageReference Include="Moq" Version="4.7.99" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.2.0" />
<PackageReference Include="Moq" Version="4.10.1" />
</ItemGroup>

<!--<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<!--
Found solution at https://github.com/aspnet/Razor/issues/1212
Work around https://github.com/NuGet/Home/issues/4412. MVC uses DependencyContext.Load() which looks next to a .dll
for a .deps.json. Information isn't available elsewhere. Need the .deps.json file for all web site applications.
-->
<Target Name="CopyDepsFiles" AfterTargets="Build" Condition="'$(TargetFramework)'!=''">
<ItemGroup>
<DepsFilePaths Include="$([System.IO.Path]::ChangeExtension('%(_ResolvedProjectReferencePaths.FullPath)', '.deps.json'))" />
</ItemGroup>

<Copy SourceFiles="%(DepsFilePaths.FullPath)" DestinationFolder="$(OutputPath)" Condition="Exists('%(DepsFilePaths.FullPath)')" />
</Target>

</Project>
</ItemGroup>-->

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<!--
Found solution at https://github.com/aspnet/Razor/issues/1212
Work around https://github.com/NuGet/Home/issues/4412. MVC uses DependencyContext.Load() which looks next to a .dll
for a .deps.json. Information isn't available elsewhere. Need the .deps.json file for all web site applications.
-->
<Target Name="CopyDepsFiles" AfterTargets="Build" Condition="'$(TargetFramework)'!=''">
<ItemGroup>
<DepsFilePaths Include="$([System.IO.Path]::ChangeExtension('%(_ResolvedProjectReferencePaths.FullPath)', '.deps.json'))" />
</ItemGroup>

<Copy SourceFiles="%(DepsFilePaths.FullPath)" DestinationFolder="$(OutputPath)" Condition="Exists('%(DepsFilePaths.FullPath)')" />
</Target>

</Project>
33 changes: 33 additions & 0 deletions test/PaulMiami.AspNetCore.Mvc.Recaptcha.Test/TestLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace PaulMiami.AspNetCore.Mvc.Recaptcha.Test
{
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;

public class TestLogger : ILogger, IDisposable
{
public List<string> Log { get; } = new List<string>();
public int ScopeCount { get; set; } = 0;

public void Dispose()
{
// Method intentionally left empty.
}

IDisposable ILogger.BeginScope<TState>(TState state)
{
ScopeCount++;
return this;
}

bool ILogger.IsEnabled(LogLevel logLevel)
{
return true;
}

void ILogger.Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
Log.Add(formatter(state, exception));
}
}
}
Loading

0 comments on commit 22b9d23

Please sign in to comment.