Skip to content

Commit

Permalink
Create project for bridge test
Browse files Browse the repository at this point in the history
  • Loading branch information
AydinE committed May 16, 2024
1 parent 8c51ac1 commit b34397e
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 32 deletions.
45 changes: 45 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# WARNING: Only edit this file in the Lombiq .NET Analyzers repository's "Lombiq.Analyzers" folder. A copy of this file
# anywhere else will be overwritten.

# All files
[*]

# Basics
charset = utf-8
guidelines = 120 1px solid a0ffc000, 150 1px solid 80ff0000

# Indentation and spacing
indent_size = 4
indent_style = space
trim_trailing_whitespace = true

# New line preferences
end_of_line = crlf
insert_final_newline = true
tab_width = 4

# Various config files
[*.{config,csproj,json,props,targets}]

indent_size = 2

# Markdown files
[*.md]

trim_trailing_whitespace = false

# JavaScript files
[*.js]

# Placeholder, no unique rules for JS files at the moment.


# SCSS files
[*.scss]

# Placeholder, no unique rules for SCSS files at the moment.

# PowerShell files
[*.ps1]

# Placeholder, no unique rules for PS files at the moment.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Lombiq.Hosting.MediaTheme.Bridge.Constants;
using Lombiq.Hosting.MediaTheme.Tests.UI.Extensions;
using Lombiq.Tests.UI.Extensions;
using Lombiq.Tests.UI.Services;
using OrchardCore.Media;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;

namespace Lombiq.Hosting.MediaTheme.Bridge.Tests.UI.Extensions;

public static class TestCaseUIBridgeTestContextExtensions
{
[SuppressMessage(
"Security",
"CA5400:HttpClient may be created without enabling CheckCertificateRevocationList",
Justification = "It's only disabled for local testing.")]
public static async Task TestMediaThemeTemplatePageAsync(this UITestContext context, string tenantPrefix = null)
{
await context.ExecuteMediaThemeSampleRecipeDirectlyAsync();
await context.GoToMediaThemeTestContentPageAsync();
var mediaOptions = await context.GetTenantOptionsAsync<MediaOptions>();

// Instead of going to the page directly (which will fail) we'll check the response status code directly.
var templatesPageUri = context.GetAbsoluteUri(
$"{mediaOptions.Value.AssetsRequestPath}/{Paths.MediaThemeTemplatesWebPath}/Example.liquid");
using var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
using var client = new HttpClient(handler);

var response = await client.GetAsync(templatesPageUri);

Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}
}
13 changes: 13 additions & 0 deletions Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/License.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright © 2022, [Lombiq Technologies Ltd.](https://lombiq.com)

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**</DefaultItemExcludes>
</PropertyGroup>

<PropertyGroup>
<Title>Lombiq Hosting - Media Theme for Orchard Core - UI Bridge Test Extensions</Title>
<Authors>Lombiq Technologies</Authors>
<Copyright>Copyright © 2022, Lombiq Technologies Ltd.</Copyright>
<Description>Lombiq Hosting - Media Theme for Orchard Core - UI Bridge Test Extensions: Extensions to aid in UI bridge testing Lombiq Hosting - Media Theme for Orchard Core. See the project website for detailed documentation.</Description>
<PackageIcon>NuGetIcon.png</PackageIcon>
<PackageTags>OrchardCore;Lombiq;AspNetCore;Media;Theme</PackageTags>
<RepositoryUrl>https://github.com/Lombiq/Hosting-Media-Theme</RepositoryUrl>
<PackageProjectUrl>https://github.com/Lombiq/Hosting-Media-Theme/blob/dev/Readme.md</PackageProjectUrl>
<PackageLicenseFile>License.md</PackageLicenseFile>
</PropertyGroup>

<ItemGroup>
<None Remove="node_modules\**" />
<None Include="License.md" Pack="true" PackagePath="" />
<None Include="NuGetIcon.png" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' != 'true'">
<ProjectReference Include="..\..\..\..\test\Lombiq.UITestingToolbox\Lombiq.Tests.UI\Lombiq.Tests.UI.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.Tests.UI" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Lombiq.Hosting.MediaTheme.Bridge\Lombiq.Hosting.MediaTheme.Bridge.csproj" />
<ProjectReference Include="..\Lombiq.Hosting.MediaTheme.Tests.UI\Lombiq.Hosting.MediaTheme.Tests.UI.csproj" />
</ItemGroup>

</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,41 +1,13 @@
using Atata;
using Lombiq.Hosting.MediaTheme.Bridge.Constants;
using Lombiq.Tests.UI.Extensions;
using Lombiq.Tests.UI.Services;
using OpenQA.Selenium;
using OrchardCore.Media;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;

namespace Lombiq.Hosting.MediaTheme.Tests.UI.Extensions;

public static class TestCaseUITestContextExtensions
{
[SuppressMessage(
"Security",
"CA5400:HttpClient may be created without enabling CheckCertificateRevocationList",
Justification = "It's only disabled for local testing.")]
public static async Task TestMediaThemeTemplatePageAsync(this UITestContext context, string tenantPrefix = null)
{
await context.ExecuteMediaThemeSampleRecipeDirectlyAsync();
await context.GoToMediaThemeTestContentPageAsync();
var mediaOptions = await context.GetTenantOptionsAsync<MediaOptions>();

// Instead of going to the page directly (which will fail) we'll check the response status code directly.
var templatesPageUri = context.GetAbsoluteUri(
$"{mediaOptions.Value.AssetsRequestPath}/{Paths.MediaThemeTemplatesWebPath}/Example.liquid");
using var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
using var client = new HttpClient(handler);

var response = await client.GetAsync(templatesPageUri);

Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}

public static async Task TestMediaThemeDeployedBehaviorAsync(this UITestContext context, string tenantPrefix = null)
{
await context.ExecuteMediaThemeSampleRecipeDirectlyAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,4 @@
<PackageReference Include="Lombiq.Tests.UI" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Lombiq.Hosting.MediaTheme.Bridge\Lombiq.Hosting.MediaTheme.Bridge.csproj" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions Lombiq.Hosting.MediaTheme.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Hosting.MediaTheme.T
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Hosting.MediaTheme.Targets", "Lombiq.Hosting.MediaTheme.Targets\Lombiq.Hosting.MediaTheme.Targets.csproj", "{49FF1549-F170-4B17-90C7-3F242A4BEBD6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Hosting.MediaTheme.Bridge.Tests.UI", "Lombiq.Hosting.MediaTheme.Bridge.Tests.UI\Lombiq.Hosting.MediaTheme.Bridge.Tests.UI.csproj", "{1B12DA93-22B4-4698-8FD2-D1FA77326A1E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -36,5 +38,9 @@ Global
{49FF1549-F170-4B17-90C7-3F242A4BEBD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49FF1549-F170-4B17-90C7-3F242A4BEBD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49FF1549-F170-4B17-90C7-3F242A4BEBD6}.Release|Any CPU.Build.0 = Release|Any CPU
{1B12DA93-22B4-4698-8FD2-D1FA77326A1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B12DA93-22B4-4698-8FD2-D1FA77326A1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B12DA93-22B4-4698-8FD2-D1FA77326A1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B12DA93-22B4-4698-8FD2-D1FA77326A1E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

0 comments on commit b34397e

Please sign in to comment.