From b34397e0c21b91e17190dbf3c90fac0530e52f16 Mon Sep 17 00:00:00 2001 From: Aydin Erdas Date: Thu, 16 May 2024 10:18:19 +0200 Subject: [PATCH] Create project for bridge test --- .editorconfig | 45 ++++++++++++++++++ .../TestCaseUIBridgeTestContextExtensions.cs | 37 ++++++++++++++ .../License.md | 13 +++++ ....Hosting.MediaTheme.Bridge.Tests.UI.csproj | 39 +++++++++++++++ .../NuGetIcon.png | Bin 0 -> 4657 bytes .../TestCaseUITestContextExtensions.cs | 28 ----------- .../Lombiq.Hosting.MediaTheme.Tests.UI.csproj | 4 -- Lombiq.Hosting.MediaTheme.sln | 6 +++ 8 files changed, 140 insertions(+), 32 deletions(-) create mode 100644 .editorconfig create mode 100644 Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/Extensions/TestCaseUIBridgeTestContextExtensions.cs create mode 100644 Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/License.md create mode 100644 Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI.csproj create mode 100644 Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/NuGetIcon.png diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..574b0e9 --- /dev/null +++ b/.editorconfig @@ -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. diff --git a/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/Extensions/TestCaseUIBridgeTestContextExtensions.cs b/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/Extensions/TestCaseUIBridgeTestContextExtensions.cs new file mode 100644 index 0000000..3812abb --- /dev/null +++ b/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/Extensions/TestCaseUIBridgeTestContextExtensions.cs @@ -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(); + + // 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); + } +} diff --git a/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/License.md b/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/License.md new file mode 100644 index 0000000..ff974d8 --- /dev/null +++ b/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/License.md @@ -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. diff --git a/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI.csproj b/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI.csproj new file mode 100644 index 0000000..e4bb6bb --- /dev/null +++ b/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI.csproj @@ -0,0 +1,39 @@ + + + + net8.0 + $(DefaultItemExcludes);.git*;node_modules\** + + + + Lombiq Hosting - Media Theme for Orchard Core - UI Bridge Test Extensions + Lombiq Technologies + Copyright © 2022, Lombiq Technologies Ltd. + 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. + NuGetIcon.png + OrchardCore;Lombiq;AspNetCore;Media;Theme + https://github.com/Lombiq/Hosting-Media-Theme + https://github.com/Lombiq/Hosting-Media-Theme/blob/dev/Readme.md + License.md + + + + + + + + + + + + + + + + + + + + + + diff --git a/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/NuGetIcon.png b/Lombiq.Hosting.MediaTheme.Bridge.Tests.UI/NuGetIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..162a00508d8041833604d427216238c1b23b2d47 GIT binary patch literal 4657 zcmV-163*?3P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!Thn=~eB5))%gn$#O#QK7n$s4=L-h!O=vF^a;>Ff(Vme>2-ILt$p`^By>#th3Jf zo%mwTcYcq(e|sM=Ffi!HnCMv&IXStx>whD37Ty5YY(6YhyZU* z`lOOYjz@!+Y#0L27(o!^cm}spNxZ;7dL0%+0GcCv2#O=eyx?Vc`gIPV2NX&{?xE+f z^lJ~Gha`}M044qbL+Cjyh5$6L0{q&ILJ^D{pl{-(=dc(#fX0vrAa*1$6xZoFEQSZr z7(wvK@eI17ssIcRAOVts$TB0_jdpqtOTYI3UN3XFj3f*Ju%dMh;Pd&EP@s_mL<&Rz zN`wG)1dx-Hi@zU-9u4$`Y9Szs9MQo`12K>gq(l@_Ed*c%po9zSHwZo@h5^*`01;mT z`ZTTr{2)t5P^2*{ z(gugaA-4-MJOC@WCeUuzc2!$!Tr9nk4OKlrL<=A$CPveRp~&DtgXxuQsOkYCIs_yq zi&{?^z~AA7u04mq{oY>iHJqn+`58HK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{U00000NkvXXu0mjfi0rae literal 0 HcmV?d00001 diff --git a/Lombiq.Hosting.MediaTheme.Tests.UI/Extensions/TestCaseUITestContextExtensions.cs b/Lombiq.Hosting.MediaTheme.Tests.UI/Extensions/TestCaseUITestContextExtensions.cs index 8827f9f..ed092cc 100644 --- a/Lombiq.Hosting.MediaTheme.Tests.UI/Extensions/TestCaseUITestContextExtensions.cs +++ b/Lombiq.Hosting.MediaTheme.Tests.UI/Extensions/TestCaseUITestContextExtensions.cs @@ -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(); - - // 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(); diff --git a/Lombiq.Hosting.MediaTheme.Tests.UI/Lombiq.Hosting.MediaTheme.Tests.UI.csproj b/Lombiq.Hosting.MediaTheme.Tests.UI/Lombiq.Hosting.MediaTheme.Tests.UI.csproj index 8d5de70..b02ac50 100644 --- a/Lombiq.Hosting.MediaTheme.Tests.UI/Lombiq.Hosting.MediaTheme.Tests.UI.csproj +++ b/Lombiq.Hosting.MediaTheme.Tests.UI/Lombiq.Hosting.MediaTheme.Tests.UI.csproj @@ -31,8 +31,4 @@ - - - - diff --git a/Lombiq.Hosting.MediaTheme.sln b/Lombiq.Hosting.MediaTheme.sln index d617a0b..21a2ff9 100644 --- a/Lombiq.Hosting.MediaTheme.sln +++ b/Lombiq.Hosting.MediaTheme.sln @@ -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 @@ -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