public void JwtSecurityTokenRequirement_Constructor() { // This class is a bit thin, most of the tests are in JwtConfigTests, just added a couple of missed cases that are easy to code directly. // *** null param JwtSecurityTokenRequirement JwtSecurityTokenRequirement; ExpectedException expectedException = new ExpectedException(typeExpected: typeof(ArgumentNullException), substringExpected: "element"); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(null); expectedException.ProcessNoException(); } catch(Exception exception) { expectedException.ProcessException(exception); } // *** wrong namespace XmlDocument xmlDocument = new XmlDocument(); expectedException = ExpectedException.ConfigurationErrorsException(substringExpected: "Jwt10601"); XmlElement xmlElement = new CustomXmlElement("prefix", "localName", "http://www.gotJwt.com", xmlDocument); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(xmlElement); expectedException.ProcessNoException(); } catch (Exception exception) { expectedException.ProcessException(exception); } // *** unknown X509RevocationMode expectedException = ExpectedException.ConfigurationErrorsException(substringExpected: "Jwt10606"); xmlElement = new CustomXmlElement("prefix", "jwtSecurityTokenRequirement", "http://www.gotJwt.com", xmlDocument); xmlElement.Attributes.Append(new CustomXmlAttribute("prefix", "issuerCertificateRevocationMode", "http://www.gotJwt.com", xmlDocument) { Value = "UnKnown:issuerCertificateRevocationMode", }); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(xmlElement); expectedException.ProcessNoException(); } catch (Exception exception) { expectedException.ProcessException(exception); } // *** unknown ValidationMode expectedException = ExpectedException.ConfigurationErrorsException(substringExpected: "Jwt10606"); xmlElement = new CustomXmlElement("prefix", "jwtSecurityTokenRequirement", "http://www.gotJwt.com", xmlDocument); xmlElement.Attributes.Append(new CustomXmlAttribute("prefix", "issuerCertificateValidationMode", "http://www.gotJwt.com", xmlDocument) { Value = "UnKnown:issuerCertificateValidationMode", }); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(xmlElement); expectedException.ProcessNoException(); } catch (Exception exception) { expectedException.ProcessException(exception); } // *** unknown TrustedStoreLocation expectedException = ExpectedException.ConfigurationErrorsException(substringExpected: "Jwt10606"); xmlElement = new CustomXmlElement("prefix", "jwtSecurityTokenRequirement", "http://www.gotJwt.com", xmlDocument); xmlElement.Attributes.Append(new CustomXmlAttribute("prefix", "issuerCertificateTrustedStoreLocation", "http://www.gotJwt.com", xmlDocument) { Value = "UnKnown:issuerCertificateTrustedStoreLocation", }); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(xmlElement); expectedException.ProcessNoException(); } catch (Exception exception) { expectedException.ProcessException(exception); } // *** unbale to create type expectedException = ExpectedException.ConfigurationErrorsException(substringExpected: "Jwt10613", inner: typeof(TypeLoadException)); xmlElement = new CustomXmlElement("prefix", "jwtSecurityTokenRequirement", "http://www.gotJwt.com", xmlDocument); xmlElement.Attributes.Append(new CustomXmlAttribute("prefix", "issuerCertificateValidator", "http://www.gotJwt.com", xmlDocument) { Value = "UnKnown:issuerCertificateValidatorType", }); xmlElement.Attributes.Append(new CustomXmlAttribute("prefix", "issuerCertificateValidationMode", "http://www.gotJwt.com", xmlDocument) { Value = "Custom", }); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(xmlElement); expectedException.ProcessNoException(); } catch (Exception exception) { expectedException.ProcessException(exception); } }
public void JwtSecurityTokenRequirement_Constructor() { // This class is a bit thin, most of the tests are in JwtConfigTests, just added a couple of missed cases that are easy to code directly. // *** null param JwtSecurityTokenRequirement JwtSecurityTokenRequirement; ExpectedException expectedException = new ExpectedException(typeExpected: typeof(ArgumentNullException), substringExpected: "element"); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(null); expectedException.ProcessNoException(); } catch (Exception exception) { expectedException.ProcessException(exception); } // *** wrong namespace XmlDocument xmlDocument = new XmlDocument(); expectedException = ExpectedException.ConfigurationErrorsException(substringExpected: "Jwt10601"); XmlElement xmlElement = new CustomXmlElement("prefix", "localName", "http://www.gotJwt.com", xmlDocument); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(xmlElement); expectedException.ProcessNoException(); } catch (Exception exception) { expectedException.ProcessException(exception); } // *** unknown X509RevocationMode expectedException = ExpectedException.ConfigurationErrorsException(substringExpected: "Jwt10606"); xmlElement = new CustomXmlElement("prefix", "jwtSecurityTokenRequirement", "http://www.gotJwt.com", xmlDocument); xmlElement.Attributes.Append(new CustomXmlAttribute("prefix", "issuerCertificateRevocationMode", "http://www.gotJwt.com", xmlDocument) { Value = "UnKnown:issuerCertificateRevocationMode", }); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(xmlElement); expectedException.ProcessNoException(); } catch (Exception exception) { expectedException.ProcessException(exception); } // *** unknown ValidationMode expectedException = ExpectedException.ConfigurationErrorsException(substringExpected: "Jwt10606"); xmlElement = new CustomXmlElement("prefix", "jwtSecurityTokenRequirement", "http://www.gotJwt.com", xmlDocument); xmlElement.Attributes.Append(new CustomXmlAttribute("prefix", "issuerCertificateValidationMode", "http://www.gotJwt.com", xmlDocument) { Value = "UnKnown:issuerCertificateValidationMode", }); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(xmlElement); expectedException.ProcessNoException(); } catch (Exception exception) { expectedException.ProcessException(exception); } // *** unknown TrustedStoreLocation expectedException = ExpectedException.ConfigurationErrorsException(substringExpected: "Jwt10606"); xmlElement = new CustomXmlElement("prefix", "jwtSecurityTokenRequirement", "http://www.gotJwt.com", xmlDocument); xmlElement.Attributes.Append(new CustomXmlAttribute("prefix", "issuerCertificateTrustedStoreLocation", "http://www.gotJwt.com", xmlDocument) { Value = "UnKnown:issuerCertificateTrustedStoreLocation", }); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(xmlElement); expectedException.ProcessNoException(); } catch (Exception exception) { expectedException.ProcessException(exception); } // *** unbale to create type expectedException = ExpectedException.ConfigurationErrorsException(substringExpected: "Jwt10613", inner: typeof(TypeLoadException)); xmlElement = new CustomXmlElement("prefix", "jwtSecurityTokenRequirement", "http://www.gotJwt.com", xmlDocument); xmlElement.Attributes.Append(new CustomXmlAttribute("prefix", "issuerCertificateValidator", "http://www.gotJwt.com", xmlDocument) { Value = "UnKnown:issuerCertificateValidatorType", }); xmlElement.Attributes.Append(new CustomXmlAttribute("prefix", "issuerCertificateValidationMode", "http://www.gotJwt.com", xmlDocument) { Value = "Custom", }); try { JwtSecurityTokenRequirement = new JwtSecurityTokenRequirement(xmlElement); expectedException.ProcessNoException(); } catch (Exception exception) { expectedException.ProcessException(exception); } }