fix regression and add unit test for login redirect to non-default page
This commit is contained in:
parent
e969ee00cf
commit
787c8923bd
@ -30,6 +30,7 @@ namespace Mocha.Core
|
||||
public static Guid Order { get; } = new Guid("{49423f66-8837-430d-8cac-7892ebdcb1fe}");
|
||||
|
||||
public static Guid TargetURL { get; } = new Guid("{970F79A0-9EFE-4E7D-9286-9908C6F06A67}");
|
||||
public static Guid ReferralURL { get; } = new Guid("{6daaa721-db70-43ad-b373-6a8038e69d2e}");
|
||||
|
||||
public static Guid UserName { get; } = new Guid("{960FAF02-5C59-40F7-91A7-20012A99D9ED}");
|
||||
public static Guid PasswordHash { get; } = new Guid("{F377FC29-4DF1-4AFB-9643-4191F37A00A9}");
|
||||
|
||||
@ -2058,13 +2058,14 @@ public abstract class Oms
|
||||
if (h != InstanceHandle.Empty)
|
||||
{
|
||||
targetURL = ctx.GetWorkData<string>(h);
|
||||
if (targetURL == null)
|
||||
{
|
||||
targetURL = targetURLAttr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetURL == null)
|
||||
{
|
||||
targetURL = targetURLAttr;
|
||||
}
|
||||
|
||||
if (targetURL != null)
|
||||
{
|
||||
return new RedirectResponse(targetURL);
|
||||
|
||||
@ -46,6 +46,33 @@ public class UITests : OmsTestsBase
|
||||
Assert.That(json["destinationUrl"].GetValue<string>(), Is.EqualTo("~/d/home.htmld"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoginPageElementSubmitRedirectToAnotherPage()
|
||||
{
|
||||
Oms.CreateUser("testing", "testing");
|
||||
|
||||
InstanceHandle loginPage = Oms.GetInstance(KnownInstanceGuids.Pages.LoginPage);
|
||||
|
||||
InstanceHandle loginPageSubedit = Oms.GetInstance(new Guid("{2b7d4481-b7c2-4e26-a917-e3ff7c367a8a}"));
|
||||
OmsContext context = Oms.CreateContext();
|
||||
|
||||
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||
dict["{c67f305e-bd4d-4628-816b-55fb85ea1b67}"] = "testing";
|
||||
dict["{51b51be3-44fd-48f1-971f-682aee0a6132}"] = "testing";
|
||||
|
||||
context.SetGlobal(Oms.GetInstance(KnownAttributeGuids.Text.ReferralURL), "https://example.com/referer");
|
||||
|
||||
Response pageOutput = Oms.ProcessElement(context, loginPageSubedit, dict);
|
||||
JsonObject json = pageOutput.GetResponse(Oms, context);
|
||||
|
||||
string s_Token = context.GetGlobal<string>(Oms.GetInstance(KnownAttributeGuids.Text.Token));
|
||||
Assert.That(s_Token, Is.Not.Empty);
|
||||
|
||||
Assert.That(json["result"].GetValue<string>(), Is.EqualTo("success"));
|
||||
Assert.That(json["type"].GetValue<string>(), Is.EqualTo("redirect"));
|
||||
Assert.That(json["destinationUrl"].GetValue<string>(), Is.EqualTo("https://example.com/referer"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoginPageElementSubmitBadPassword()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user