public void Defaults() { List <string> errors = new List <string>(); string issuerAddress = "http://www.gotjwt.com"; AuthenticationProtocolMessage authenticationProtocolMessage = new DerivedAuthenticationProtocolMessage(); if (!IdentityComparer.AreStringsEqual(authenticationProtocolMessage.IssuerAddress, string.Empty, CompareContext.Default)) { errors.Add("authenticationProtocolMessage.IssuerAddress != string.Empty: " + authenticationProtocolMessage.IssuerAddress ?? "null"); } authenticationProtocolMessage = new DerivedAuthenticationProtocolMessage() { IssuerAddress = issuerAddress }; if (!IdentityComparer.AreStringsEqual(authenticationProtocolMessage.IssuerAddress, issuerAddress, CompareContext.Default)) { errors.Add("authenticationProtocolMessage.IssuerAddress != issuerAddress: " + authenticationProtocolMessage.IssuerAddress ?? "null" + " , " + issuerAddress); } if (authenticationProtocolMessage.Parameters == null) { errors.Add("uthenticationProtocolMessage.Parameters .IssuerAddress != issuerAddress: " + authenticationProtocolMessage.IssuerAddress ?? "null" + " , " + issuerAddress); } Assert.NotNull(authenticationProtocolMessage.Parameters); Assert.Equal(0, authenticationProtocolMessage.Parameters.Count); }
public void Defaults() { var context = new CompareContext(); string issuerAddress = "http://www.gotjwt.com"; var script = "<script language=\"javascript\">window.setTimeout(function() {document.forms[0].submit();}, 0);</script>"; AuthenticationProtocolMessage authenticationProtocolMessage = new DerivedAuthenticationProtocolMessage(); IdentityComparer.AreStringsEqual(authenticationProtocolMessage.IssuerAddress, string.Empty, context); authenticationProtocolMessage = new DerivedAuthenticationProtocolMessage() { IssuerAddress = issuerAddress }; IdentityComparer.AreStringsEqual(authenticationProtocolMessage.IssuerAddress, issuerAddress, context); if (!authenticationProtocolMessage.Script.Equals(script)) { context.Diffs.Add("The value of authenticationProtocolMessage.Script should be '" + script + "'."); } if (authenticationProtocolMessage.Parameters == null) { context.Diffs.Add("authenticationProtocolMessage.Parameters == null"); } if (authenticationProtocolMessage.Parameters.Count != 0) { context.Diffs.Add("authenticationProtocolMessage.Parameters.Count != 0"); } TestUtilities.AssertFailIfErrors(context); }
public void CanonicalString() { var context = new CompareContext($"{this}.CanonicalString"); var assertion = ReferenceSaml.SamlAssertion; var canonicalString = assertion.CanonicalString; var canonicalString2 = assertion.CanonicalString; IdentityComparer.AreStringsEqual(canonicalString, canonicalString2, context); TestUtilities.AssertFailIfErrors(context); }
public void CanonicalString() { var context = new CompareContext($"{this}.CanonicalString"); var assertion = new Saml2Assertion(new Saml2NameIdentifier("nameIdentifier")); var canonicalString = assertion.CanonicalString; var canonicalString2 = assertion.CanonicalString; IdentityComparer.AreStringsEqual(canonicalString, canonicalString2, context); TestUtilities.AssertFailIfErrors(context); }
public void CreateJwkClaim(SignedHttpRequestUtilityTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.CreateJwkClaim", theoryData); try { var jwkClaim = SignedHttpRequestUtilities.CreateJwkClaim(theoryData.JsonWebKey); if (!string.IsNullOrEmpty(theoryData.ExpectedJwkClaim)) { IdentityComparer.AreStringsEqual(jwkClaim, theoryData.ExpectedJwkClaim, context); } var jwkJwt = JObject.Parse(jwkClaim); var privateKeyPropertyNames = new List <string>() { JsonWebKeyParameterNames.D, JsonWebKeyParameterNames.DP, JsonWebKeyParameterNames.DQ, JsonWebKeyParameterNames.Oth, JsonWebKeyParameterNames.P, JsonWebKeyParameterNames.Q, JsonWebKeyParameterNames.QI, }; foreach (var privateKeyPropertyName in privateKeyPropertyNames) { if (jwkJwt.ContainsKey(privateKeyPropertyName)) { context.AddDiff($"The resulting jwk claim contains '{privateKeyPropertyName}' field, that represents a private key."); } } if (new JsonWebKey(jwkClaim).HasPrivateKey) { context.AddDiff($"The resulting jwk claim contains a private key."); } theoryData.ExpectedException.ProcessNoException(context); } catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } TestUtilities.AssertFailIfErrors(context); }
public async Task ToHttpRequestDataAsync(SignedHttpRequestUtilityTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.ToHttpRequestDataAsync", theoryData); try { var httpRequestData = await SignedHttpRequestUtilities.ToHttpRequestDataAsync(theoryData.HttpRequestMessage).ConfigureAwait(false); IdentityComparer.AreStringsEqual(httpRequestData.Method, theoryData.ExpectedHttpRequestData.Method, context); IdentityComparer.AreUrisEqual(httpRequestData.Uri, theoryData.ExpectedHttpRequestData.Uri, context); IdentityComparer.AreBytesEqual(httpRequestData.Body, theoryData.ExpectedHttpRequestData.Body, context); IdentityComparer.AreStingEnumDictionariesEqual(httpRequestData.Headers, theoryData.ExpectedHttpRequestData.Headers, context); theoryData.ExpectedException.ProcessNoException(context); } catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } TestUtilities.AssertFailIfErrors(context); }