Skip to content

Commit

Permalink
Added a setter for the AuthenticationProtocolMessage.Script property (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mafurman authored Oct 18, 2019
1 parent 501095c commit 38d5cb1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
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));

_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

0 comments on commit 38d5cb1

Please sign in to comment.