@@ -1637,7 +1637,7 @@ public void testNoCurrentURL() throws IOException, Error, XPathExpressionExcepti
16371637
16381638 /**
16391639 * Tests the isValid method of SamlResponse
1640- * Case: invalid version
1640+ * Case: invalid version (the response is not SAML 2.0)
16411641 *
16421642 * @throws IOException
16431643 * @throws Error
@@ -1655,7 +1655,53 @@ public void testValidateVersion() throws IOException, Error, XPathExpressionExce
16551655 String samlResponseEncoded = Util .getFileAsString ("data/responses/invalids/no_saml2.xml.base64" );
16561656 SamlResponse samlResponse = new SamlResponse (settings , newHttpRequest (samlResponseEncoded ));
16571657 assertFalse (samlResponse .isValid ());
1658- assertEquals ("Unsupported SAML Version." , samlResponse .getError ());
1658+ assertTrue (samlResponse .getError ().startsWith ("Unsupported SAML Version" ));
1659+ }
1660+
1661+ /**
1662+ * Tests the isValid method of SamlResponse
1663+ * Case: invalid response version (although the response may otherwise be valid SAML 2.0)
1664+ *
1665+ * @throws IOException
1666+ * @throws Error
1667+ * @throws ValidationError
1668+ * @throws SettingsException
1669+ * @throws SAXException
1670+ * @throws ParserConfigurationException
1671+ * @throws XPathExpressionException
1672+ *
1673+ * @see com.onelogin.saml2.authn.SamlResponse#isValid
1674+ */
1675+ @ Test
1676+ public void testValidateResponseVersion () throws IOException , Error , XPathExpressionException , ParserConfigurationException , SAXException , SettingsException , ValidationError {
1677+ Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.min.properties" ).build ();
1678+ String samlResponseEncoded = Util .getFileAsString ("data/responses/invalids/invalid_response_version.xml.base64" );
1679+ SamlResponse samlResponse = new SamlResponse (settings , newHttpRequest (samlResponseEncoded ));
1680+ assertFalse (samlResponse .isValid ());
1681+ assertEquals ("Unsupported SAML Version on Response." , samlResponse .getError ());
1682+ }
1683+
1684+ /**
1685+ * Tests the isValid method of SamlResponse
1686+ * Case: invalid assertion version (although the response may otherwise be valid SAML 2.0)
1687+ *
1688+ * @throws IOException
1689+ * @throws Error
1690+ * @throws ValidationError
1691+ * @throws SettingsException
1692+ * @throws SAXException
1693+ * @throws ParserConfigurationException
1694+ * @throws XPathExpressionException
1695+ *
1696+ * @see com.onelogin.saml2.authn.SamlResponse#isValid
1697+ */
1698+ @ Test
1699+ public void testValidateAssertionVersion () throws IOException , Error , XPathExpressionException , ParserConfigurationException , SAXException , SettingsException , ValidationError {
1700+ Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.min.properties" ).build ();
1701+ String samlResponseEncoded = Util .getFileAsString ("data/responses/invalids/invalid_assertion_version.xml.base64" );
1702+ SamlResponse samlResponse = new SamlResponse (settings , newHttpRequest (samlResponseEncoded ));
1703+ assertFalse (samlResponse .isValid ());
1704+ assertEquals ("Unsupported SAML Version on Assertion." , samlResponse .getError ());
16591705 }
16601706
16611707 /**
0 commit comments