Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a setter for the AuthenticationProtocolMessage.Script property #1280

Merged
merged 1 commit into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace Microsoft.IdentityModel.Protocols
public abstract class AuthenticationProtocolMessage
{
private string _postTitle = "Working...";
private string _script = "<script language=\"javascript\">window.setTimeout('document.forms[0].submit()', 0);</script>";
private string _scriptButtonText = "Submit";
private string _scriptDisabledText = "Script is disabled. Click Submit to continue.";

Expand Down Expand Up @@ -148,7 +149,7 @@ public string IssuerAddress
set
{
if (value == null)
throw LogHelper.LogArgumentNullException("value");
throw LogHelper.LogArgumentNullException(nameof(IssuerAddress));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice.
We should follow this pattern.


_issuerAddress = value;
}
Expand Down Expand Up @@ -179,7 +180,7 @@ public string PostTitle
set
{
if (value == null)
throw LogHelper.LogArgumentNullException("value");
throw LogHelper.LogArgumentNullException(nameof(PostTitle));

_postTitle = value;
}
Expand Down Expand Up @@ -239,7 +240,22 @@ public virtual void SetParameters(NameValueCollection nameValueCollection)
/// <summary>
/// Gets the script used when constructing the post string.
/// </summary>
public string Script { get; } = "<script language=\"javascript\">window.setTimeout('document.forms[0].submit()', 0);</script>";
/// <exception cref="ArgumentNullException">If the 'value' is null.</exception>
public string Script
{
get
{
return _script;
}

set
{
if (value == null)
throw LogHelper.LogArgumentNullException(nameof(Script));

_script = value;
}
}

/// <summary>
/// Gets or sets the script button text used when constructing the post string.
Expand All @@ -255,7 +271,7 @@ public string ScriptButtonText
set
{
if (value == null)
throw LogHelper.LogArgumentNullException("value");
throw LogHelper.LogArgumentNullException(nameof(ScriptButtonText));

_scriptButtonText = value;
}
Expand All @@ -275,7 +291,7 @@ public string ScriptDisabledText
set
{
if (value == null)
throw LogHelper.LogArgumentNullException("value");
throw LogHelper.LogArgumentNullException(nameof(ScriptDisabledText));

_scriptDisabledText = value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ public void GetSets()
{
"IssuerAddress",
"PostTitle",
"Script",
"ScriptButtonText",
"ScriptDisabledText",
};

var context = new GetSetContext();
foreach(string property in properties)
{
TestUtilities.SetGet(authenticationProtocolMessage, property, null, ExpectedException.ArgumentNullException(substringExpected: "value"), context);
TestUtilities.SetGet(authenticationProtocolMessage, property, null, ExpectedException.ArgumentNullException(substringExpected: property), context);
TestUtilities.SetGet(authenticationProtocolMessage, property, "", ExpectedException.NoExceptionExpected, context);
TestUtilities.SetGet(authenticationProtocolMessage, property, property, ExpectedException.NoExceptionExpected, context);
TestUtilities.SetGet(authenticationProtocolMessage, property, " ", ExpectedException.NoExceptionExpected, context);
TestUtilities.SetGet(authenticationProtocolMessage, property, "\t\n\r", ExpectedException.NoExceptionExpected, context);
Expand Down