Skip to content

Commit

Permalink
Merge pull request #3 from Lombiq/issue/LMBQ-253
Browse files Browse the repository at this point in the history
LMBQ-253: Reimplement Orchard-Login-as-Anybody submodule
  • Loading branch information
DemeSzabolcs authored Dec 21, 2023
2 parents 9061eb4 + 8d324c3 commit c82355a
Show file tree
Hide file tree
Showing 33 changed files with 444 additions and 463 deletions.
9 changes: 8 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
* -crlf
* text=auto

# Enforce Windows newlines for C# files to avoid false positives with IDE0055 warning.
# See https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions/issues/106 for more information.
*.cs text eol=crlf

# Keep LF line endings in pnpm-lock.yaml files to prevent Git from reporting this file as changed after pnpm touches it.
pnpm-lock.yaml text eol=lf
48 changes: 24 additions & 24 deletions .github/workflows/create-jira-issues-for-community-activities.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name: Create Jira issues for community activities

on:
discussion:
types: [created]
issues:
types: [opened]
pull_request_target:
types: [opened]

jobs:
create-jira-issues-for-community-activities:
name: Create Jira issues for community activities
uses: Lombiq/GitHub-Actions/.github/workflows/create-jira-issues-for-community-activities.yml@dev
secrets:
JIRA_BASE_URL: ${{ secrets.DEFAULT_JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.DEFAULT_JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.DEFAULT_JIRA_API_TOKEN }}
JIRA_PROJECT_KEY: ${{ secrets.DEFAULT_JIRA_PROJECT_KEY }}
DISCUSSION_JIRA_ISSUE_DESCRIPTION: ${{ secrets.DEFAULT_DISCUSSION_JIRA_ISSUE_DESCRIPTION }}
ISSUE_JIRA_ISSUE_DESCRIPTION: ${{ secrets.DEFAULT_ISSUE_JIRA_ISSUE_DESCRIPTION }}
PULL_REQUEST_JIRA_ISSUE_DESCRIPTION: ${{ secrets.DEFAULT_PULL_REQUEST_JIRA_ISSUE_DESCRIPTION }}
with:
issue-component: Lombiq.LoginAsAnybody
name: Create Jira issues for community activities

on:
discussion:
types: [created]
issues:
types: [opened]
pull_request_target:
types: [opened]

jobs:
create-jira-issues-for-community-activities:
name: Create Jira issues for community activities
uses: Lombiq/GitHub-Actions/.github/workflows/create-jira-issues-for-community-activities.yml@dev
secrets:
JIRA_BASE_URL: ${{ secrets.DEFAULT_JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.DEFAULT_JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.DEFAULT_JIRA_API_TOKEN }}
JIRA_PROJECT_KEY: ${{ secrets.DEFAULT_JIRA_PROJECT_KEY }}
DISCUSSION_JIRA_ISSUE_DESCRIPTION: ${{ secrets.DEFAULT_DISCUSSION_JIRA_ISSUE_DESCRIPTION }}
ISSUE_JIRA_ISSUE_DESCRIPTION: ${{ secrets.DEFAULT_ISSUE_JIRA_ISSUE_DESCRIPTION }}
PULL_REQUEST_JIRA_ISSUE_DESCRIPTION: ${{ secrets.DEFAULT_PULL_REQUEST_JIRA_ISSUE_DESCRIPTION }}
with:
issue-component: Lombiq.LoginAsAnybody
26 changes: 13 additions & 13 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Publish to NuGet

on:
push:
tags:
- v*

jobs:
publish-nuget:
name: Publish to NuGet
uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev
secrets:
API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }}
name: Publish to NuGet

on:
push:
tags:
- v*

jobs:
publish-nuget:
name: Publish to NuGet
uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev
secrets:
API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }}
18 changes: 9 additions & 9 deletions .github/workflows/validate-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Validate Pull Request

on:
pull_request:

jobs:
validate-pull-request:
name: Validate Pull Request
uses: Lombiq/GitHub-Actions/.github/workflows/validate-submodule-pull-request.yml@dev
name: Validate Pull Request

on:
pull_request:

jobs:
validate-pull-request:
name: Validate Pull Request
uses: Lombiq/GitHub-Actions/.github/workflows/validate-submodule-pull-request.yml@dev
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
.vs/
.idea/
.vscode/
obj/
bin/
artifacts/
wwwroot/
node_modules/
*.user
.pnpm-debug.log

# Mac
.DS_Store
4 changes: 0 additions & 4 deletions .hgignore

This file was deleted.

25 changes: 0 additions & 25 deletions AdminMenu.cs

This file was deleted.

59 changes: 0 additions & 59 deletions Controllers/AdminController.cs

This file was deleted.

28 changes: 13 additions & 15 deletions Licence.md → License.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
Copyright © 2015, [Lombiq Technologies Ltd.](https://lombiq.com)

All rights reserved.

For more information and requests about licensing please [contact us through our website](https://lombiq.com/contact-us).

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.
Copyright © 2015, [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.
17 changes: 17 additions & 0 deletions Lombiq.LoginAsAnybody.Tests.UI/Extensions/Configurations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Lombiq.Tests.UI.Services;
using System;
using System.Linq;

namespace Lombiq.LoginAsAnybody.Tests.UI.Extensions;

public static class Configurations
{
// We are checking a page with Unauthorized status code, so we need to make an exception here.
public static readonly Action<OrchardCoreUITestExecutorConfiguration> IgnoreUnauthorizedBrowserLogEntries =
configuration =>
configuration.AssertBrowserLog =
logEntries =>
OrchardCoreUITestExecutorConfiguration.AssertBrowserLogIsEmpty(
logEntries.Where(logEntry =>
!logEntry.Message.ContainsOrdinalIgnoreCase("the server responded with a status of 401")));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Lombiq.Tests.UI.Extensions;
using Lombiq.Tests.UI.Models;
using Lombiq.Tests.UI.Services;
using OpenQA.Selenium;
using Shouldly;
using System.Threading.Tasks;

namespace Lombiq.LoginAsAnybody.Tests.UI.Extensions;

public static class TestCaseUITestContextExtensions
{
public static async Task TestLoginAsAnybodyAsync(this UITestContext context)
{
await context.SignInDirectlyAndGoToDashboardAsync();

var userParameters = UserRegistrationParameters.CreateDefault();
await context.CreateUserAsync(userParameters.UserName, userParameters.Password, userParameters.Email);

await context.GoToUsersAsync();
await context.ClickReliablyOnAsync(By.XPath("//a[contains(.,'Log in as user')]"));

(await context.GetCurrentUserNameAsync()).ShouldBe(userParameters.UserName);
}

public static async Task TestLoginAsAnybodyAuthorizationAsync(this UITestContext context)
{
var userParameters = UserRegistrationParameters.CreateDefault();
await context.CreateUserAsync(userParameters.UserName, userParameters.Password, userParameters.Email);

// The role needs this permission to visit the users page.
await context.AddPermissionToRoleAsync("ManageUsers", "Moderator");
await context.AddUserToRoleAsync(userParameters.UserName, "Moderator");

await context.SignInDirectlyAndGoToDashboardAsync(userParameters.UserName);
await context.GoToUsersAsync();

context.Missing(By.XPath("//a[contains(.,'Log in as user')]"));
await context.GoToAdminRelativeUrlAsync("/Users/SwitchUser/userId");
context.Exists(By.XPath("//h1[contains(text(),'You are not authorized to view this content.')]"));
}
}
13 changes: 13 additions & 0 deletions Lombiq.LoginAsAnybody.Tests.UI/License.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright © 2023, [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,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<Title>Lombiq Login as Anybody for Orchard Core - UI Test Extensions</Title>
<Authors>Lombiq Technologies</Authors>
<Copyright>Copyright © 2023, Lombiq Technologies Ltd.</Copyright>
<Description>Lombiq Login as Anybody for Orchard Core - UI Test Extensions: Extensions to aid in UI testing Lombiq Login as Anybody for Orchard Core.</Description>
<PackageIcon>NuGetIcon.png</PackageIcon>
<PackageTags>OrchardCore;Lombiq;AspNetCore</PackageTags>
<RepositoryUrl>https://github.com/Lombiq/Orchard-Login-as-Anybody</RepositoryUrl>
<PackageProjectUrl>https://github.com/Lombiq/Orchard-Login-as-Anybody/tree/dev/Lombiq.LoginAsAnybody.Tests.UI</PackageProjectUrl>
<PackageLicenseFile>License.md</PackageLicenseFile>
</PropertyGroup>

<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="8.1.0-alpha.1.osoe-638" />
</ItemGroup>

<ItemGroup>
<None Include="License.md" Pack="true" PackagePath="" />
<None Include="NuGetIcon.png" Pack="true" PackagePath="" />
<None Include="Readme.md" />
</ItemGroup>

</Project>
Binary file added Lombiq.LoginAsAnybody.Tests.UI/NuGetIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions Lombiq.LoginAsAnybody.Tests.UI/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Lombiq Login as Anybody for Orchard Core - UI Test Extensions

## About

Extension methods that test various features in Lombiq Login as Anybody for Orchard Core, with the help of [Lombiq UI Testing Toolbox for Orchard Core](https://github.com/Lombiq/UI-Testing-Toolbox).

Call these from a UI test project to verify the module's basic features; as seen in [Open-Source Orchard Core Extensions](https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions).
Loading

0 comments on commit c82355a

Please sign in to comment.