Exemplo n.º 1
0
  @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());
  }
Exemplo n.º 2
0
  @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);
  }
Exemplo n.º 3
0
  @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());
  }