Merge pull request #3940 from pdrozd/KEYCLOAK-4304
KEYCLOAK-4304 Updated Kerberos tests to be able to run them on differ…
This commit is contained in:
commit
71a9d51c56
4 changed files with 25 additions and 6 deletions
|
@ -73,4 +73,8 @@ public class KerberosRule extends LDAPRule {
|
||||||
public boolean isCaseSensitiveLogin() {
|
public boolean isCaseSensitiveLogin() {
|
||||||
return ldapTestConfiguration.isCaseSensitiveLogin();
|
return ldapTestConfiguration.isCaseSensitiveLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isStartEmbeddedLdapServer() {
|
||||||
|
return ldapTestConfiguration.isStartEmbeddedLdapServer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
|
|
||||||
package org.keycloak.testsuite.federation.kerberos;
|
package org.keycloak.testsuite.federation.kerberos;
|
||||||
|
|
||||||
|
import static org.keycloak.testsuite.admin.AbstractAdminTest.loadJson;
|
||||||
|
import static org.keycloak.testsuite.admin.ApiUtil.findClientByClientId;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
@ -44,6 +47,7 @@ import org.jboss.resteasy.client.jaxrs.ResteasyClient;
|
||||||
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
|
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
|
||||||
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine;
|
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -75,8 +79,6 @@ import org.keycloak.testsuite.auth.page.AuthRealm;
|
||||||
import org.keycloak.testsuite.pages.AccountPasswordPage;
|
import org.keycloak.testsuite.pages.AccountPasswordPage;
|
||||||
import org.keycloak.testsuite.pages.LoginPage;
|
import org.keycloak.testsuite.pages.LoginPage;
|
||||||
import org.keycloak.testsuite.util.OAuthClient;
|
import org.keycloak.testsuite.util.OAuthClient;
|
||||||
import static org.keycloak.testsuite.admin.AbstractAdminTest.loadJson;
|
|
||||||
import static org.keycloak.testsuite.admin.ApiUtil.findClientByClientId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||||
|
@ -102,6 +104,8 @@ public abstract class AbstractKerberosTest extends AbstractAuthTest {
|
||||||
|
|
||||||
protected abstract void setKrb5ConfPath();
|
protected abstract void setKrb5ConfPath();
|
||||||
|
|
||||||
|
protected abstract boolean isStartEmbeddedLdapServer();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTestRealms(List<RealmRepresentation> testRealms) {
|
public void addTestRealms(List<RealmRepresentation> testRealms) {
|
||||||
RealmRepresentation realmRep = loadJson(getClass().getResourceAsStream("/kerberos/kerberosrealm.json"), RealmRepresentation.class);
|
RealmRepresentation realmRep = loadJson(getClass().getResourceAsStream("/kerberos/kerberosrealm.json"), RealmRepresentation.class);
|
||||||
|
@ -256,7 +260,8 @@ public abstract class AbstractKerberosTest extends AbstractAuthTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void credentialDelegationTest() throws Exception {
|
public void credentialDelegationTest() throws Exception {
|
||||||
// Add kerberos delegation credential mapper
|
Assume.assumeTrue("Ignoring test as the embedded server is not started", isStartEmbeddedLdapServer());
|
||||||
|
// Add kerberos delegation credential mapper
|
||||||
ProtocolMapperModel protocolMapper = UserSessionNoteMapper.createClaimMapper(KerberosConstants.GSS_DELEGATION_CREDENTIAL_DISPLAY_NAME,
|
ProtocolMapperModel protocolMapper = UserSessionNoteMapper.createClaimMapper(KerberosConstants.GSS_DELEGATION_CREDENTIAL_DISPLAY_NAME,
|
||||||
KerberosConstants.GSS_DELEGATION_CREDENTIAL,
|
KerberosConstants.GSS_DELEGATION_CREDENTIAL,
|
||||||
KerberosConstants.GSS_DELEGATION_CREDENTIAL, "String",
|
KerberosConstants.GSS_DELEGATION_CREDENTIAL, "String",
|
||||||
|
|
|
@ -75,6 +75,11 @@ public class KerberosLdapTest extends AbstractKerberosTest {
|
||||||
protected boolean isCaseSensitiveLogin() {
|
protected boolean isCaseSensitiveLogin() {
|
||||||
return kerberosRule.isCaseSensitiveLogin();
|
return kerberosRule.isCaseSensitiveLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isStartEmbeddedLdapServer() {
|
||||||
|
return kerberosRule.isStartEmbeddedLdapServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -78,6 +78,11 @@ public class KerberosStandaloneTest extends AbstractKerberosTest {
|
||||||
protected boolean isCaseSensitiveLogin() {
|
protected boolean isCaseSensitiveLogin() {
|
||||||
return kerberosRule.isCaseSensitiveLogin();
|
return kerberosRule.isCaseSensitiveLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isStartEmbeddedLdapServer() {
|
||||||
|
return kerberosRule.isStartEmbeddedLdapServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,7 +95,7 @@ public class KerberosStandaloneTest extends AbstractKerberosTest {
|
||||||
spnegoLoginTestImpl();
|
spnegoLoginTestImpl();
|
||||||
|
|
||||||
// Assert user was imported and hasn't any required action on him. Profile info is synced from LDAP
|
// Assert user was imported and hasn't any required action on him. Profile info is synced from LDAP
|
||||||
assertUser("hnelson", "hnelson@keycloak.org", null, null, false);
|
assertUser("hnelson", "hnelson@" + kerberosRule.getConfig().get(KerberosConstants.KERBEROS_REALM).toLowerCase(), null, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,11 +113,11 @@ public class KerberosStandaloneTest extends AbstractKerberosTest {
|
||||||
Assert.assertEquals(200, spnegoResponse.getStatus());
|
Assert.assertEquals(200, spnegoResponse.getStatus());
|
||||||
String responseText = spnegoResponse.readEntity(String.class);
|
String responseText = spnegoResponse.readEntity(String.class);
|
||||||
Assert.assertTrue(responseText.contains("You need to update your user profile to activate your account."));
|
Assert.assertTrue(responseText.contains("You need to update your user profile to activate your account."));
|
||||||
Assert.assertTrue(responseText.contains("hnelson@keycloak.org"));
|
Assert.assertTrue(responseText.contains("hnelson@" + kerberosRule.getConfig().get(KerberosConstants.KERBEROS_REALM).toLowerCase()));
|
||||||
spnegoResponse.close();
|
spnegoResponse.close();
|
||||||
|
|
||||||
// Assert user was imported and has required action on him
|
// Assert user was imported and has required action on him
|
||||||
assertUser("hnelson", "hnelson@keycloak.org", null, null, true);
|
assertUser("hnelson", "hnelson@" + kerberosRule.getConfig().get(KerberosConstants.KERBEROS_REALM).toLowerCase(), null, null, true);
|
||||||
|
|
||||||
// Switch updateProfileOnFirstLogin to off
|
// Switch updateProfileOnFirstLogin to off
|
||||||
kerberosProvider.getConfig().putSingle(KerberosConstants.UPDATE_PROFILE_FIRST_LOGIN, "false");
|
kerberosProvider.getConfig().putSingle(KerberosConstants.UPDATE_PROFILE_FIRST_LOGIN, "false");
|
||||||
|
|
Loading…
Reference in a new issue