Skip to content

Commit

Permalink
8686: Fixing build and tests on dev (#8695)
Browse files Browse the repository at this point in the history
* Fixing that RecipeManagerTests failed due to HttpContext not being available

* Fixing OwnerEditor tests in CommonPartProviderTests as the owner editor now checks for a different permission since 5b0c82d

* Fixing typo in CommonPartProviderTests.UpdateModelStub class name

* Fixing that test cases for invalid path in FileSystemStorageProviderTests broke in a3e9bef (issue #6802, PR #6919)

I should review PRs more carefully!

* Fixing CurrentCultureWorkContextTests

* Fixing indentation in DefaultDateFormatterTests

* Updating Orchard.Azure.Web's required version of System.Web.Mvc to match the rest of the solution

* Orchard.Specs: Fixing assembly loading errors when starting up the web host by adding binding redirects

* Adding empty compile workflow from dev

* Adding the compile workflow's actual contents

* Changing default shell to pwsh (msbuild was not found in cmd?)

* Adding msbuild to PATH

* Removing unused references to System.Net.Http

* Replacing System.Net.Http references with its NuGet package to pin the correct version number (experimental)

* Upgrading Microsoft.CodeDom.Providers.DotNetCompilerPlatform to 4.1.0 (latest) to get rid of old System.Http.Net dependency

* Orchard.proj: Spec target actually depends on only the Compile target, not Package-Stage (experimental)

* Compile workflow: Testing the Test and Spec targets

* Fixing Test step

* Fixing compile workflow to also mark Razor compilation warnings as errors

* Restoring Orchard.Specs/Hosting/Orchard.Web/Web.config to match Orchard.Web's web.config closer

so that it loads assemblies from the Dependencies folder.
This fixes the error with Autofac not being able to resolve dependencies for DefaultOrchardShell

* Orchard.Specs/Hosting/Orchard.Web/Global.asax.cs: Workaround for AntiForgeryToken bug in ASP.NET MVC since version 5.2.4

aspnet/AspNetWebStack#162

* Revert "Replacing System.Net.Http references with its NuGet package to pin the correct version number (experimental)"

This reverts commit 087f284.

* Revert "Upgrading Microsoft.CodeDom.Providers.DotNetCompilerPlatform to 4.1.0 (latest) to get rid of old System.Http.Net dependency"

This reverts commit be2ba86.

* Reverting the addition of assembly binding redirects to Orchard.Specs/Hosting/Simple.Web/Web.config

since it doesn't need them like Orchard.Specs/Hosting/Orchard.Web/Web.config does

* Disabling Test and Spec execution for now

* Orchard.Framework: Making the System.Net.Http not-private to prevent an outdated version sticking around

* Orchard.Workflows: Adding assembly binding redirect for System.Net.Http to avoid Razor compilation warning

* Moving the System.Net.Http assembly redirect to Orchard.Web

* Specs: Fixing "I can create browse blog posts on several pages" Blog test's usage of "I should not see" and correcting the parameters too

because unlike "I should see", this is not a regex match, just contains

* Specs: Fixing "I can create browse blog posts on several pages" Blog test's flakyness due to timing

because the blog posts are created quickly after one another and the lack of millisecond-precision can cause
the blog posts to appear out of order of creation

* Specs: Media test simplified since the Orchard.Media feature is deprecated

* Adding step to the Compile workflow to upload the MSBuild binlog results

* Pinning the referenced version of System.Net.Http to 4.2.0.0 to prevent Razor compilation warning

System.Net.Http is known to have such problems across different framework versions ways of referencing it

The original warning is:
ASPNETCOMPILER : error : The following assembly has dependencies on a version of the .NET Framework that is higher than the target and might not load correctly during runtime causing a failure: Orchard.Workflows, Version=1.10.3.0, Culture=neutral, PublicKeyToken=null. The dependencies are: System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. You should either ensure that the dependent assembly is correct for the target framework, or ensure that the target framework you are addressing is that of the dependent assembly. [D:\a\Orchard\Orchard\src\Orchard.Web\Modules\Orchard.Workflows\Orchard.Workflows.csproj

* Re-enabling the Test step

* Re-enabling the Specs step

* Marking System.Net.Http references as private (copy local) to make sure that it's always available, because it requires a specific version

* Revert "Marking System.Net.Http references as private (copy local) to make sure that it's always available, because it requires a specific version"

This reverts commit e4f5632.

* Orchard.Specs: Adding Settings feature

* Orchard.Specs: Updating DateTime.CreatingAndUsingDateTimeFieldsInAnotherCulture structure without functional change

* Orchard.Specs: Updating Settings.AddingANewSiteCultureAndSelectingItAsTheDefaultWorks to correctly detect that a culture that wasn't added before can be set as default

* Fixing outdated assembly binding redirects

* Fixing Newtonsoft.Json references

* Updating Newtonsoft.Json reference in Orchard.Messaging.Tests.csproj

* Disabling the Test step for now

* Adding System.Net.Http 4.2.0.0 reference to Orchard.Email's web.config to fix Razor compilation warning

* Re-enabling the Test step

* Fixing HqlExpressionTests.AllDataTypesCanBeQueried

* Fixing initialization error error in StylesheetBindingStrategyTests

* Fixing initialization errors in FeatureManagerTests

* Fixing Orchard.Tests.Localization.TextTests

* Code styling and fixing warning in Orchard.Tests/UI/Resources/ResourceManagerTests.cs

* Updating Orchard.Tests/UI/Resources/ResourceManagerTests.cs according to ResourceManager API change in ac11024

and removing obsolete tests

* Orchard.Tests.Modules: Adding missing reference to Iesi.Collections (that doesn't cause a build error, just when running tests)

* Fixing initialization errors in ModuleStepTest and ThemeStepTest

* Fixing initialization errors in ShellDescriptorManagerTests

* Fixing initialization errors in AccountControllerTests

* Fixing that MembershipServiceTests should use IPasswordService, also making SaltAndPasswordShouldBeDifferentEvenWithSameSourcePassword test parameters more readable

* Specs: Updating the Newtonsoft.Json binding redirect in the spec app's web.config

* Re-enabling the Spec step

* Upgrading actions to latest versions

These actions generated the Node.js 16  deprecation warning

* Removing SpecFlow test execution from the compile workflow

* Testing the branch strategy matrix concept to be used for the nightly build

* Revert "Testing the branch strategy matrix concept to be used for the nightly build"

This reverts commit 1354e36.

* Adding workflow to run specflow tests as a nightly build

* Updating Orchard.Tests.ContentManagement.HqlExpressionTests.ShouldSortRandomly to decrease failure chance due to randomness
  • Loading branch information
BenedekFarkas authored Mar 8, 2024
1 parent e333952 commit 54ab14b
Show file tree
Hide file tree
Showing 21 changed files with 246 additions and 90 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Compile
# Compiles the solution and runs unit tests.

on:
workflow_dispatch:
Expand All @@ -18,13 +19,16 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v3.1.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Restore NuGet packages
run: nuget restore src/Orchard.sln

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.3.1
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0

- name: Compile
run: msbuild Orchard.proj /m /t:Compile /p:MvcBuildViews=true /p:TreatWarningsAsErrors=true -WarnAsError

- name: Test
run: msbuild Orchard.proj /m /t:Test
39 changes: 39 additions & 0 deletions .github/workflows/specflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: SpecFlow tests
# Compiles the solution and runs unit tests, as well the SpecFlow tests on the main development branches.

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Every day at midnight.

jobs:
compile:
name: SpecFlow tests
defaults:
run:
shell: pwsh
runs-on: windows-latest
strategy:
matrix:
branch: [dev, 1.10.x]

steps:
- name: Clone repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ matrix.branch }}

- name: Restore NuGet packages
run: nuget restore src/Orchard.sln

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0

- name: Compile
run: msbuild Orchard.proj /m /t:Compile /p:MvcBuildViews=true /p:TreatWarningsAsErrors=true -WarnAsError

- name: Test
run: msbuild Orchard.proj /m /t:Test

- name: Spec
run: msbuild Orchard.proj /m /t:Spec
2 changes: 1 addition & 1 deletion src/Orchard.Specs/Hosting/Orchard.Web/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
Expand Down
9 changes: 9 additions & 0 deletions src/Orchard.Specs/Orchard.Specs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Settings.feature.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Settings.feature</DependentUpon>
</Compile>
<Compile Include="Text.feature.cs">
<DependentUpon>Text.feature</DependentUpon>
<AutoGen>True</AutoGen>
Expand Down Expand Up @@ -372,6 +377,10 @@
<DependentUpon>HostComponents.config</DependentUpon>
</None>
<None Include="packages.config" />
<None Include="Settings.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>Settings.feature.cs</LastGenOutput>
</None>
<None Include="Text.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>Text.feature.cs</LastGenOutput>
Expand Down
14 changes: 14 additions & 0 deletions src/Orchard.Specs/Settings.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Feature: Settings

In order to manage my site
As a privileged user
I want to be able to see and change site settings

Scenario: Adding a new site culture and selecting it as the default works

Given I have installed Orchard
When I go to "Admin/Settings/Index"
Then I should not see "hu-HU"
When I have "hu-HU" as the default culture
And I go to "Admin/Settings/Index"
Then I should see "<option selected="selected">hu-HU</option>"
93 changes: 93 additions & 0 deletions src/Orchard.Specs/Settings.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Orchard.Tests.Modules/Orchard.Tests.Modules.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="Iesi.Collections, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<HintPath>..\packages\Iesi.Collections.4.0.4\lib\net461\Iesi.Collections.dll</HintPath>
</Reference>
<Reference Include="IronRuby, Version=1.1.3.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
<HintPath>..\packages\IronRuby.1.1.3\lib\IronRuby.dll</HintPath>
</Reference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Orchard.Environment.Features;
using Orchard.Environment.State;
using Orchard.Events;
using Orchard.Locking;
using Orchard.Packaging.GalleryServer;
using Orchard.Packaging.Models;
using Orchard.Packaging.Services;
Expand Down Expand Up @@ -57,6 +58,7 @@ public override void Register(ContainerBuilder builder) {
builder.RegisterType<RecipeExecutionLogger>().AsSelf();
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
builder.RegisterType<FeatureManager>().As<IFeatureManager>();
builder.RegisterType<LockingProvider>().As<ILockingProvider>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
Expand All @@ -65,6 +67,7 @@ public override void Register(ContainerBuilder builder) {
builder.RegisterInstance(_packagesInRepository).As<IPackagingSourceManager>();
builder.RegisterInstance(_packageManager).As<IPackageManager>();
builder.RegisterType<ShellStateManager>().As<IShellStateManager>().SingleInstance();
builder.RegisterType<Signals>().As<ISignals>().SingleInstance();
builder.RegisterType<StubEventBus>().As<IEventBus>().SingleInstance();
builder.RegisterType<ModuleStep>();
builder.RegisterSource(new EventsRegistrationSource());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Orchard.Environment.State;
using Orchard.Events;
using Orchard.FileSystems.VirtualPath;
using Orchard.Locking;
using Orchard.Packaging.GalleryServer;
using Orchard.Packaging.Services;
using Orchard.Recipes.Models;
Expand Down Expand Up @@ -60,6 +61,7 @@ public override void Register(ContainerBuilder builder) {
builder.RegisterType<RecipeExecutionLogger>().AsSelf();
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
builder.RegisterType<FeatureManager>().As<IFeatureManager>();
builder.RegisterType<LockingProvider>().As<ILockingProvider>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
Expand All @@ -71,6 +73,7 @@ public override void Register(ContainerBuilder builder) {
builder.RegisterInstance(testVirtualPathProvider).As<IVirtualPathProvider>();
builder.RegisterType<StubEventBus>().As<IEventBus>().SingleInstance();
builder.RegisterType<ThemeService>().As<IThemeService>();
builder.RegisterType<Signals>().As<ISignals>().SingleInstance();
builder.RegisterType<StubOrchardServices>().As<IOrchardServices>();
builder.RegisterType<StubSiteThemeService>().As<ISiteThemeService>();
builder.RegisterType<ThemeStep>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Orchard.Events;
using Orchard.Caching;
using Orchard.Core.Settings.State.Records;
using Orchard.Locking;

namespace Orchard.Tests.Modules.Settings.Blueprint {
[TestFixture]
Expand All @@ -24,6 +25,8 @@ public override void Register(ContainerBuilder builder) {
builder.RegisterType<DefaultCacheManager>().As<ICacheManager>();
builder.RegisterType<DefaultCacheHolder>().As<ICacheHolder>().SingleInstance();
builder.RegisterType<DefaultCacheContextAccessor>().As<ICacheContextAccessor>();
builder.RegisterType<LockingProvider>().As<ILockingProvider>();
builder.RegisterType<Signals>().As<ISignals>().SingleInstance();
builder.RegisterType<ShellDescriptorManager>().As<IShellDescriptorManager>().SingleInstance();
builder.RegisterType<ShellStateManager>().As<IShellStateManager>().SingleInstance();
builder.RegisterType<StubEventBus>().As<IEventBus>().SingleInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public override void Register(ContainerBuilder builder) {
builder.RegisterType<UserPartHandler>().As<IContentHandler>();
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
builder.RegisterType<AccountValidationService>().As<IAccountValidationService>();
builder.RegisterType<PasswordService>().As<IPasswordService>();
builder.RegisterType<PasswordHistoryService>().As<IPasswordHistoryService>();

builder.RegisterInstance(new Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void Init() {
//builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterType<MembershipValidationService>().As<IMembershipValidationService>();
builder.RegisterType<MembershipService>().As<IMembershipService>();
builder.RegisterType<PasswordService>().As<IPasswordService>();
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>();
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
Expand All @@ -77,7 +78,6 @@ public void Init() {
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataProvider = "SqlCe" });
builder.RegisterType<UserPartHandler>().As<IContentHandler>();
//builder.RegisterType<StubWorkContextAccessor>().As<IWorkContextAccessor>();
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
builder.RegisterAutoMocking(MockBehavior.Loose);
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
Expand Down Expand Up @@ -135,11 +135,12 @@ public void DefaultPasswordFormatShouldBeHashedAndHaveSalt() {

[Test]
public void SaltAndPasswordShouldBeDifferentEvenWithSameSourcePassword() {
var user1 = _membershipService.CreateUser(new CreateUserParams("a", "b", "c", null, null, true, false));
var password = "Password1!";
var user1 = _membershipService.CreateUser(new CreateUserParams("user1", password, "[email protected]", null, null, true, false));
_session.Flush();
_session.Clear();

var user2 = _membershipService.CreateUser(new CreateUserParams("d", "b", "e", null, null, true, false));
var user2 = _membershipService.CreateUser(new CreateUserParams("user2", password, "[email protected]", null, null, true, false));
_session.Flush();
_session.Clear();

Expand All @@ -150,8 +151,8 @@ public void SaltAndPasswordShouldBeDifferentEvenWithSameSourcePassword() {
Assert.That(user1Record.Password, Is.Not.EqualTo(user2Record.Password));

List<LocalizedString> validationErrors;
Assert.That(_membershipService.ValidateUser("a", "b", out validationErrors), Is.Not.Null);
Assert.That(_membershipService.ValidateUser("d", "b", out validationErrors), Is.Not.Null);
Assert.That(_membershipService.ValidateUser("user1", password, out validationErrors), Is.Not.Null);
Assert.That(_membershipService.ValidateUser("user2", password, out validationErrors), Is.Not.Null);
}

[Test]
Expand Down
Loading

0 comments on commit 54ab14b

Please sign in to comment.