Hello,
I trying to test an AccountController that uses DotNetOpenAuth but I am running into a problem. I want to test the Logon Actionresult to see that it is returning the correct views. The test fails because realm(I think) has a contract that requires the HttpContext.Current not to be null. I think I have to mock the request somehow but I am not sure how I should do this.
This is the ActionResult code. It's taken directly from a DotNetOpenAuth example.
[AcceptVerbs(HttpVerbs.Post), ValidateAntiForgeryToken]
public ActionResult LogOn(string openid_identifier,
bool rememberMe,
string returnUrl)
{
Identifier userSuppliedIdentifier;
if (Identifier.TryParse(openid_identifier, out userSuppliedIdentifier))
{
try
{
var request = this.RelyingParty
.CreateRequest(openid_identifier,
Realm.AutoDetect,
Url.ActionFull("LogOnReturnTo"));
if (!string.IsNullOrEmpty(returnUrl))
{
request.SetUntrustedCallbackArgument("returnUrl", returnUrl);
}
return request.RedirectingResponse.AsActionResult();
}
catch (ProtocolException ex)
{
ModelState.AddModelError("OpenID", ex.Message);
}
}
else
{
ModelState.AddModelError("openid_identifier",
"This doesn't look like a valid OpenID.");
}
return RedirectToAction("LogOn", "Account");
}
Thanks in advance,
Pickels