@Test public void authorizationRequestNoState() throws IOException { AuthorizationCodeResponse response = oauth.doLogin("test-user@localhost", "password"); Assert.assertTrue(response.isRedirected()); Assert.assertNotNull(response.getCode()); Assert.assertNull(response.getState()); Assert.assertNull(response.getError()); oauth.verifyCode(response.getCode()); }
@Test public void authorizationRequestInstalledApp() throws IOException { oauth.redirectUri(Constants.INSTALLED_APP_URN); oauth.doLogin("test-user@localhost", "password"); String title = driver.getTitle(); Assert.assertTrue(title.startsWith("Success code=")); String code = driver.findElement(By.id(OAuth2Constants.CODE)).getText(); oauth.verifyCode(code); }
@Test public void authorizationValidRedirectUri() throws IOException { keycloakRule.configure( new KeycloakRule.KeycloakSetup() { @Override public void config( RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) { appRealm.getApplicationByName("test-app").addRedirectUri(oauth.getRedirectUri()); } }); oauth.state("mystate"); AuthorizationCodeResponse response = oauth.doLogin("test-user@localhost", "password"); Assert.assertTrue(response.isRedirected()); Assert.assertNotNull(response.getCode()); oauth.verifyCode(response.getCode()); }