Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions dotnet/DotNetStandardClasses.sln
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestMockDBAccess", "src\ext
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneXus.Programs.Common", "src\extensions\Azure\test\GeneXus.Programs.Common\GeneXus.Programs.Common.csproj", "{DCEC0B38-93B6-4003-81E6-9FBC2BB4F163}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GXAmazonSQS", "src\dotnetcore\Providers\Messaging\GXAmazonSQS\GXAmazonSQS.csproj", "{F8BA0D65-267D-491F-BFAB-33F5E5B61AD7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GXAmazonSQS", "src\dotnetcore\Providers\Messaging\GXAmazonSQS\GXAmazonSQS.csproj", "{F8BA0D65-267D-491F-BFAB-33F5E5B61AD7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "apiattractions", "src\extensions\Azure\test\apiattractions\apiattractions.csproj", "{E85FDB0F-FA81-4CDD-8BF3-865269CE2DB3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectHealthTest", "test\ProjectHealthTest\ProjectHealthTest.csproj", "{65048104-212A-4819-AECF-89CA9C08C83F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetRedisTest", "test\DotNetRedisTest\DotNetRedisTest.csproj", "{48430E50-043A-47A2-8278-B86A4420758A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectHealthTest", "test\ProjectHealthTest\ProjectHealthTest.csproj", "{65048104-212A-4819-AECF-89CA9C08C83F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetRedisTest", "test\DotNetRedisTest\DotNetRedisTest.csproj", "{48430E50-043A-47A2-8278-B86A4420758A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCoreWebUnitTest", "test\DotNetCoreWebUnitTest\DotNetCoreWebUnitTest.csproj", "{531863CA-93A0-42AA-AB5C-FA0E672C03B8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -520,6 +524,10 @@ Global
{48430E50-043A-47A2-8278-B86A4420758A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48430E50-043A-47A2-8278-B86A4420758A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48430E50-043A-47A2-8278-B86A4420758A}.Release|Any CPU.Build.0 = Release|Any CPU
{531863CA-93A0-42AA-AB5C-FA0E672C03B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{531863CA-93A0-42AA-AB5C-FA0E672C03B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{531863CA-93A0-42AA-AB5C-FA0E672C03B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{531863CA-93A0-42AA-AB5C-FA0E672C03B8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -624,6 +632,7 @@ Global
{E85FDB0F-FA81-4CDD-8BF3-865269CE2DB3} = {7BA5A2CE-7992-4F87-9D84-91AE4D046F5A}
{65048104-212A-4819-AECF-89CA9C08C83F} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
{48430E50-043A-47A2-8278-B86A4420758A} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
{531863CA-93A0-42AA-AB5C-FA0E672C03B8} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E18684C9-7D76-45CD-BF24-E3944B7F174C}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


[assembly: InternalsVisibleTo("DotNetCoreUnitTest")]
[assembly: InternalsVisibleTo("DotNetCoreWebUnitTest")]
[assembly: InternalsVisibleTo("GxNetCoreStartup")]
[assembly: InternalsVisibleTo("GeneXus.Deploy.AzureFunctions.Handlers")]
[assembly: InternalsVisibleTo("AzureFunctionsTest")]
1 change: 1 addition & 0 deletions dotnet/src/dotnetcore/GxClasses/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[assembly: InternalsVisibleTo("AzureFunctionsTest")]
[assembly: InternalsVisibleTo("GXQueue")]
[assembly: InternalsVisibleTo("DotNetCoreUnitTest")]
[assembly: InternalsVisibleTo("DotNetCoreWebUnitTest")]
[assembly: InternalsVisibleTo("GeneXus.Deploy.AzureFunctions.Handlers")]
[assembly: InternalsVisibleTo("AzureFunctionsTest")]
[assembly: InternalsVisibleTo("GXMessageBroker")]
16 changes: 13 additions & 3 deletions dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
Expand All @@ -32,24 +33,28 @@ namespace GeneXus.Application
public class Program
{
const string DEFAULT_PORT = "80";
static string DEFAULT_SCHEMA = Uri.UriSchemeHttp;
public static void Main(string[] args)
{
try
{
string port = DEFAULT_PORT;
string schema = DEFAULT_SCHEMA;
if (args.Length > 2)
{
Startup.VirtualPath = args[0];
Startup.LocalPath = args[1];
port = args[2];
if (args.Length > 3 && Uri.UriSchemeHttps.Equals(args[3], StringComparison.OrdinalIgnoreCase))
schema = Uri.UriSchemeHttps;
}
if (port == DEFAULT_PORT)
{
BuildWebHost(null).Run();
}
else
{
BuildWebHostPort(null, port).Run();
BuildWebHostPort(null, port, schema).Run();
}
}
catch (Exception e)
Expand All @@ -66,10 +71,14 @@ public static IWebHost BuildWebHost(string[] args) =>
.Build();

public static IWebHost BuildWebHostPort(string[] args, string port)
{
return BuildWebHostPort(args, port, DEFAULT_SCHEMA);
}
static IWebHost BuildWebHostPort(string[] args, string port, string schema)
{
return WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(logging => logging.AddConsole())
.UseUrls(Preferences.HttpProtocolSecure() ? $"{Uri.UriSchemeHttps}://*:{port}" : $"{Uri.UriSchemeHttp}://*:{port}")
.UseUrls($"{schema}://*:{port}")
.UseStartup<Startup>()
.Build();
}
Expand Down Expand Up @@ -116,8 +125,9 @@ public class Startup

private GXRouting gxRouting;

public Startup(Microsoft.AspNetCore.Hosting.IHostingEnvironment env)
public Startup(IConfiguration configuration, IHostingEnvironment env)
{
Config.ConfigRoot = configuration;
GXRouting.ContentRootPath = env.ContentRootPath;
GXRouting.UrlTemplateControllerWithParms = "controllerWithParms";
GxContext.IsHttpContext = true;
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public static CultureInfo GetCultureForLang(string lang)
}

#if NETCORE
public static IConfigurationRoot ConfigRoot { get; set; }
public static IConfiguration ConfigRoot { get; set; }
const string Log4NetShortName = "log4net";
static Version Log4NetVersion = new Version(2, 0, 11);

Expand Down
13 changes: 0 additions & 13 deletions dotnet/test/DotNetCoreUnitTest/DotNetCoreUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
<ProjectReference Include="..\..\src\dotnetcore\GxClasses.Web\GxClasses.Web.csproj" />
<ProjectReference Include="..\..\src\dotnetcore\GxClasses\GxClasses.csproj" />
<ProjectReference Include="..\..\src\dotnetcore\GxMail\GxMail.csproj" />
<ProjectReference Include="..\..\src\dotnetcore\GxNetCoreStartup\GxNetCoreStartup.csproj" />
<ProjectReference Include="..\..\src\dotnetcore\GxPdfReportsCS\GxPdfReportsCS.csproj" />
<ProjectReference Include="..\..\src\dotnetcore\Providers\Cache\GxMemcached\GxMemcached.csproj" />
<ProjectReference Include="..\..\src\dotnetcore\GxSearch\GxSearch.csproj" />
Expand All @@ -89,15 +88,6 @@


<ItemGroup>
<None Update="apps\append.svc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="apps\httpcors.svc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="apps\saveimage.svc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="confmapping.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -155,9 +145,6 @@
<None Update="resources\text.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="uruguay.flag.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>


Expand Down
3 changes: 2 additions & 1 deletion dotnet/test/DotNetCoreUnitTest/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"HTTP_PROTOCOL": "Unsecure",
"SAMESITE_COOKIE": "Lax",
"CACHE_INVALIDATION_TOKEN": "20216211291931",
"CORS_ALLOW_ORIGIN": "https://normal-website.com"
"CORS_ALLOW_ORIGIN": "https://normal-website.com",
"MY_CUSTOM_PTY": "DEFAULT_VALUE"
},
"languages": {
"English": {
Expand Down
71 changes: 71 additions & 0 deletions dotnet/test/DotNetCoreWebUnitTest/DotNetCoreWebUnitTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<NoWarn>CS8032;1701;1702;NU1701</NoWarn>
<RollForward>Major</RollForward>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>TRACE;NETCORE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>DEBUG;TRACE;NETCORE</DefineConstants>
</PropertyGroup>



<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.5" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.0.19269.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.5.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\dotnetcore\GxClasses.Web\GxClasses.Web.csproj" />
<ProjectReference Include="..\..\src\dotnetcore\GxClasses\GxClasses.csproj" />
<ProjectReference Include="..\..\src\dotnetcore\GxNetCoreStartup\GxNetCoreStartup.csproj" />
<ProjectReference Include="..\..\src\dotnetcore\Providers\Storage\GXAmazonS3\GXAmazonS3.csproj" />
</ItemGroup>



<ItemGroup>
<None Update="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="apps\append.svc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="apps\configsettings.svc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="apps\httpcors.svc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="apps\saveimage.svc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="confmapping.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="uruguay.flag.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>



</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
using System.Threading.Tasks;
using GeneXus.Configuration;
using GeneXus.Metadata;
using Microsoft.AspNetCore.Http;
using Microsoft.Net.Http.Headers;
using Xunit;
using xUnitTesting;

namespace DotNetCoreUnitTest.Middleware
{
public class AspNetCoreTestConfigurationOverride : MiddlewareTest
{
const string ConfigSettingsProgramName = "configsettings";
const string ConfigSettingsProgramModule = "apps";
const string DEVELOPMENT_VALUE = "DEVELOPMENT_VALUE";
const string MY_CUSTOM_PTY = "MY_CUSTOM_PTY";
public AspNetCoreTestConfigurationOverride()
{
ClassLoader.FindType($"{ConfigSettingsProgramModule}.{ConfigSettingsProgramName}", $"GeneXus.Programs.{ConfigSettingsProgramModule}", ConfigSettingsProgramName, Assembly.GetExecutingAssembly(), true);//Force loading assembly
}
[Fact]
public async Task TestConfigurationSettingOverridenInDevelopment()
{
server.AllowSynchronousIO = true;
HttpClient client = server.CreateClient();

client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("ConfigurationSetting", MY_CUSTOM_PTY);

HttpResponseMessage response = await client.PostAsync($"rest/{ConfigSettingsProgramModule}/{ConfigSettingsProgramName}", null);
response.EnsureSuccessStatusCode();
Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode);

string originHeader = GetHeader(response, "ConfigurationSettingValue");
Assert.Equal(DEVELOPMENT_VALUE, originHeader);
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ public class CorsTest : MiddlewareTest
{
const string HttpCorsProgramName = "httpcors";
const string HttpCorsProgramModule = "apps";
string Origin = Preferences.CorsAllowedOrigins();
string Origin;
string[] Headers = { "authorization","cache-control", "deviceid", "devicetype", "genexus-agent", "gxtzoffset" };
public CorsTest()
{
ClassLoader.FindType($"{HttpCorsProgramModule}.{HttpCorsProgramName}", $"GeneXus.Programs.{HttpCorsProgramModule}", HttpCorsProgramName, Assembly.GetExecutingAssembly(), true);//Force loading assembly
Origin = Preferences.CorsAllowedOrigins();
Assert.NotEmpty(Origin);
}
[Fact]
Expand Down Expand Up @@ -76,14 +77,6 @@ public async Task TestCorsOnPreflightRequest()
Assert.Contains(header, headersHeader, StringComparison.OrdinalIgnoreCase);
}
}
private string GetHeader(HttpResponseMessage response, string headerName)
{
if (response.Headers.TryGetValues(headerName, out IEnumerable<string> value))
return value.First();
else
return string.Empty;

}

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using GeneXus.Application;
using GxClasses.Web.Middleware;
using Microsoft.AspNetCore;
Expand All @@ -9,11 +12,22 @@ namespace xUnitTesting
{
public class MiddlewareTest
{
const string DOTNET_ENVIRONMENT = "Development";

protected TestServer server;
public MiddlewareTest()
{
GXRouting.ContentRootPath = Directory.GetCurrentDirectory();
server = new TestServer(WebHost.CreateDefaultBuilder().UseStartup<Startup>());
server = new TestServer(WebHost.CreateDefaultBuilder().UseStartup<Startup>().UseEnvironment(DOTNET_ENVIRONMENT));
server.CreateClient();
}
protected string GetHeader(HttpResponseMessage response, string headerName)
{
if (response.Headers.TryGetValues(headerName, out IEnumerable<string> value))
return value.First();
else
return string.Empty;

}

}
Expand Down
Loading