Skip to content

Commit

Permalink
Net 8 upgrade, NetFramework test project added, HttpClient test added
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorium committed Mar 15, 2024
1 parent 22f52f1 commit 1913193
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 37 deletions.
68 changes: 37 additions & 31 deletions GeoblockingMiddleware.sln
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "GeoblockingMiddleware", "src\GeoblockingMiddleware\GeoblockingMiddleware.fsproj", "{0AC1014E-B6C5-4B5B-A1BF-68CC0889EC71}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "GeoblockingMiddleware.Tests", "src\GeoblockingMiddleware.Tests\GeoblockingMiddleware.Tests.fsproj", "{BAF74CB6-8536-4727-83D0-0DBC5ACD6097}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0AC1014E-B6C5-4B5B-A1BF-68CC0889EC71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0AC1014E-B6C5-4B5B-A1BF-68CC0889EC71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0AC1014E-B6C5-4B5B-A1BF-68CC0889EC71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0AC1014E-B6C5-4B5B-A1BF-68CC0889EC71}.Release|Any CPU.Build.0 = Release|Any CPU
{BAF74CB6-8536-4727-83D0-0DBC5ACD6097}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAF74CB6-8536-4727-83D0-0DBC5ACD6097}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAF74CB6-8536-4727-83D0-0DBC5ACD6097}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAF74CB6-8536-4727-83D0-0DBC5ACD6097}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {274579CD-0A3B-4588-BF7B-417C8264483E}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "GeoblockingMiddleware", "src\GeoblockingMiddleware\GeoblockingMiddleware.fsproj", "{0AC1014E-B6C5-4B5B-A1BF-68CC0889EC71}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "GeoblockingMiddleware.Tests", "src\GeoblockingMiddleware.Tests\GeoblockingMiddleware.Tests.fsproj", "{BAF74CB6-8536-4727-83D0-0DBC5ACD6097}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "GeoblockingMiddlewareFrameworkTest", "src\GeoblockingMiddleware.FrameworkTest\GeoblockingMiddlewareFrameworkTest.fsproj", "{67B5747B-200D-4E57-8E46-9810C3607077}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0AC1014E-B6C5-4B5B-A1BF-68CC0889EC71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0AC1014E-B6C5-4B5B-A1BF-68CC0889EC71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0AC1014E-B6C5-4B5B-A1BF-68CC0889EC71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0AC1014E-B6C5-4B5B-A1BF-68CC0889EC71}.Release|Any CPU.Build.0 = Release|Any CPU
{BAF74CB6-8536-4727-83D0-0DBC5ACD6097}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAF74CB6-8536-4727-83D0-0DBC5ACD6097}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAF74CB6-8536-4727-83D0-0DBC5ACD6097}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAF74CB6-8536-4727-83D0-0DBC5ACD6097}.Release|Any CPU.Build.0 = Release|Any CPU
{67B5747B-200D-4E57-8E46-9810C3607077}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67B5747B-200D-4E57-8E46-9810C3607077}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67B5747B-200D-4E57-8E46-9810C3607077}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67B5747B-200D-4E57-8E46-9810C3607077}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {274579CD-0A3B-4588-BF7B-417C8264483E}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
<WarnOn>3390;$(WarnOn)</WarnOn>
</PropertyGroup>

<ItemGroup>
<Compile Include="Tests.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FsUnit.xUnit" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.Owin.Host.HttpListener" Version="4.2.2" />
<PackageReference Include="Microsoft.Owin.Hosting" Version="4.2.2" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Update="FSharp.Core" Version="8.0.200" />
<PackageReference Include="xunit.runner.console" Version="2.7.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GeoblockingMiddleware\GeoblockingMiddleware.fsproj" />
</ItemGroup>

</Project>
45 changes: 45 additions & 0 deletions src/GeoblockingMiddleware.FrameworkTest/Tests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace GeoblockingMiddleware.FrameworkTest


open System
open System.Threading
open System.Threading.Tasks
open GeoblockingMiddleware
open Owin
open Xunit
open System
open FsUnitTyped

type MyStartup() =
member __.Configuration(app:Owin.IAppBuilder) =
app.UseGeoblocking(Common.defaultConfig) |> ignore
()

module GeoTestClass =

[<Fact>]
let ``Should be blocked: ApiPaths hit blocked (net48)`` () =
task {
let config =
{ GeoblockingMiddleware.Common.defaultConfig with
//Example:
Countries = AllowedItems [ "XX" ]
ApiPaths = BlockedItems [ "/mypath"; "/test2" ]
Service = Disabled }

let! actualResult = Common.shouldBlock config "0.0.0.1" "http://myserver/mypath/thing.aspx"
actualResult |> shouldEqual true
}
:> Task

[<Fact(Skip = "this does actual http-call")>]
let ``Should be calling IpApi`` () =
task {
let! res = GeoblockingMiddleware.Common.serviceCallIpApi "157.24.0.105" 3000
match res with
| None -> failwith "Country not gotten"
| Some c ->
String.IsNullOrEmpty c |> shouldEqual false
}


11 changes: 11 additions & 0 deletions src/GeoblockingMiddleware.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,14 @@ module GeoTestClass =

}
:> Task


[<Fact(Skip = "this does actual http-call")>]
let ``Should be calling IpApi`` () =
task {
let! res = GeoblockingMiddleware.Common.serviceCallIpApi "157.24.0.105" 3000
match res with
| None -> failwith "Country not gotten"
| Some c ->
String.IsNullOrEmpty c |> shouldEqual false
}
12 changes: 6 additions & 6 deletions src/GeoblockingMiddleware/GeoblockingMiddleware.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<IsPackable>true</IsPackable>
<OutputType>Library</OutputType>
<IsTestProject>false</IsTestProject>
Expand Down Expand Up @@ -32,23 +32,23 @@
</PropertyGroup>

<PropertyGroup>
<DefineConstants Condition=" '$(TargetFramework)' != 'net472' ">ASPNETCORE</DefineConstants>
<DefineConstants Condition=" '$(TargetFramework)' != 'net48' ">ASPNETCORE</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Compile Include="Common.fs" />
<Compile Include="GeoblockingOwin.fs" Condition=" '$(TargetFramework)' == 'net472' " />
<Compile Include="GeoblockingCore.fs" Condition=" '$(TargetFramework)' != 'net472' " />
<Compile Include="GeoblockingOwin.fs" Condition=" '$(TargetFramework)' == 'net48' " />
<Compile Include="GeoblockingCore.fs" Condition=" '$(TargetFramework)' != 'net48' " />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<PackageReference Include="Microsoft.Owin" Version="4.2.2" />
<PackageReference Include="Owin" Version="1.0.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'net472' ">
<ItemGroup Condition=" '$(TargetFramework)' != 'net48' ">
<PackageReference Include="Microsoft.Extensions.Primitives" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
Expand Down

0 comments on commit 1913193

Please sign in to comment.