@@ -149,13 +149,12 @@ public void testConstructorWithFilenameAndKeyStore() throws IOException, Setting
149149
150150 Auth auth = new Auth ("config/config.min.properties" , ks , alias , password );
151151 assertTrue (auth .getSettings () != null );
152-
153152 assertTrue (auth .getSettings ().getSPcert () != null );
154153 assertTrue (auth .getSettings ().getSPkey () != null );
155154
156- Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.min.properties" ).build ();
157- assertEquals (settings .getIdpEntityId (), auth .getSettings ().getIdpEntityId ());
158- assertEquals (settings .getSpEntityId (), auth .getSettings ().getSpEntityId ());
155+ Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.min.properties" , ks , alias , password ).build ();
156+ assertEquals (settings .getSPcert (), auth .getSettings ().getSPcert ());
157+ assertEquals (settings .getSPkey (), auth .getSettings ().getSPkey ());
159158 }
160159
161160 /**
@@ -183,7 +182,43 @@ public void testConstructorWithReqRes() throws IOException, SettingsException, U
183182 assertEquals (settings .getIdpEntityId (), auth .getSettings ().getIdpEntityId ());
184183 assertEquals (settings .getSpEntityId (), auth .getSettings ().getSpEntityId ());
185184 }
186-
185+
186+ /**
187+ * Tests the constructor of Auth
188+ * Case: KeyStore and HttpServletRequest and HttpServletResponse provided
189+ *
190+ * @throws SettingsException
191+ * @throws IOException
192+ * @throws URISyntaxException
193+ * @throws Error
194+ * @throws KeyStoreException
195+ * @throws CertificateException
196+ * @throws NoSuchAlgorithmException
197+ *
198+ * @see com.onelogin.saml2.Auth
199+ */
200+ @ Test
201+ public void testConstructorWithReqResAndKeyStore () throws IOException , SettingsException , URISyntaxException , Error , KeyStoreException , NoSuchAlgorithmException , CertificateException {
202+ HttpServletRequest request = mock (HttpServletRequest .class );
203+ HttpServletResponse response = mock (HttpServletResponse .class );
204+
205+ String password = "changeit" ;
206+ String keyStoreFile = "src/test/resources/keystore/oneloginTestKeystore.jks" ;
207+ String alias = "onelogintest" ;
208+
209+ KeyStore ks = KeyStore .getInstance ("JKS" );
210+ ks .load (new FileInputStream (keyStoreFile ), password .toCharArray ());
211+
212+ Auth auth = new Auth (ks , alias , password , request , response );
213+ assertTrue (auth .getSettings () != null );
214+ assertTrue (auth .getSettings ().getSPcert () != null );
215+ assertTrue (auth .getSettings ().getSPkey () != null );
216+
217+ Saml2Settings settings = new SettingsBuilder ().fromFile ("onelogin.saml.properties" , ks , alias , password ).build ();
218+ assertEquals (settings .getSPkey (), auth .getSettings ().getSPkey ());
219+ assertEquals (settings .getSPcert (), auth .getSettings ().getSPcert ());
220+ }
221+
187222 /**
188223 * Tests the constructor of Auth
189224 * Case: filename, HttpServletRequest and HttpServletResponse provided
0 commit comments