KEYCLOAK-8138 Fixed tests for product profile
This commit is contained in:
parent
36837ae4b6
commit
d37eb5d10b
3 changed files with 24 additions and 17 deletions
|
@ -23,6 +23,7 @@ import org.junit.Test;
|
|||
import org.keycloak.admin.client.Keycloak;
|
||||
import org.keycloak.authorization.model.Resource;
|
||||
import org.keycloak.client.admin.cli.util.ConfigUtil;
|
||||
import org.keycloak.common.Profile;
|
||||
import org.keycloak.models.*;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
import org.keycloak.representations.idm.authorization.ClientPolicyRepresentation;
|
||||
|
@ -41,6 +42,7 @@ import org.keycloak.representations.idm.RoleRepresentation;
|
|||
import org.keycloak.representations.idm.UserRepresentation;
|
||||
import org.keycloak.representations.idm.authorization.DecisionStrategy;
|
||||
import org.keycloak.testsuite.AbstractKeycloakTest;
|
||||
import org.keycloak.testsuite.ProfileAssume;
|
||||
import org.keycloak.testsuite.arquillian.AuthServerTestEnricher;
|
||||
import org.keycloak.testsuite.auth.page.AuthRealm;
|
||||
import org.keycloak.testsuite.runonserver.RunOnServerDeployment;
|
||||
|
@ -856,6 +858,7 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
|
|||
*/
|
||||
@Test
|
||||
public void testWithTokenExchange() throws Exception {
|
||||
ProfileAssume.assumeFeatureEnabled(Profile.Feature.TOKEN_EXCHANGE);
|
||||
testingClient.server().run(session -> {
|
||||
RealmModel realm = session.realms().getRealmByName("master");
|
||||
ClientModel client = session.realms().getClientByClientId("kcinit", realm);
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.keycloak.authentication.authenticators.console.ConsoleUsernamePasswor
|
|||
import org.keycloak.authentication.requiredactions.TermsAndConditions;
|
||||
import org.keycloak.authorization.model.Policy;
|
||||
import org.keycloak.authorization.model.ResourceServer;
|
||||
import org.keycloak.common.Profile;
|
||||
import org.keycloak.credential.CredentialModel;
|
||||
import org.keycloak.models.*;
|
||||
import org.keycloak.models.utils.DefaultAuthenticationFlows;
|
||||
|
@ -404,25 +405,27 @@ public class KcinitTest extends AbstractTestRealmKeycloakTest {
|
|||
Assert.assertEquals(0, exe.exitCode());
|
||||
Assert.assertEquals(0, exe.stdoutLines().size());
|
||||
|
||||
exe = KcinitExec.execute("token");
|
||||
Assert.assertEquals(0, exe.exitCode());
|
||||
Assert.assertEquals(1, exe.stdoutLines().size());
|
||||
String token = exe.stdoutLines().get(0).trim();
|
||||
//System.out.println("token: " + token);
|
||||
if (Profile.isFeatureEnabled(Profile.Feature.TOKEN_EXCHANGE)) {
|
||||
exe = KcinitExec.execute("token");
|
||||
Assert.assertEquals(0, exe.exitCode());
|
||||
Assert.assertEquals(1, exe.stdoutLines().size());
|
||||
String token = exe.stdoutLines().get(0).trim();
|
||||
//System.out.println("token: " + token);
|
||||
|
||||
exe = KcinitExec.execute("token app");
|
||||
Assert.assertEquals(0, exe.exitCode());
|
||||
Assert.assertEquals(1, exe.stdoutLines().size());
|
||||
String appToken = exe.stdoutLines().get(0).trim();
|
||||
Assert.assertFalse(appToken.equals(token));
|
||||
//System.out.println("token: " + token);
|
||||
exe = KcinitExec.execute("token app");
|
||||
Assert.assertEquals(0, exe.exitCode());
|
||||
Assert.assertEquals(1, exe.stdoutLines().size());
|
||||
String appToken = exe.stdoutLines().get(0).trim();
|
||||
Assert.assertFalse(appToken.equals(token));
|
||||
//System.out.println("token: " + token);
|
||||
|
||||
|
||||
exe = KcinitExec.execute("token badapp");
|
||||
Assert.assertEquals(1, exe.exitCode());
|
||||
Assert.assertEquals(0, exe.stdoutLines().size());
|
||||
Assert.assertEquals(1, exe.stderrLines().size());
|
||||
Assert.assertTrue(exe.stderrLines().get(0), exe.stderrLines().get(0).contains("failed to exchange token: invalid_client Audience not found"));
|
||||
exe = KcinitExec.execute("token badapp");
|
||||
Assert.assertEquals(1, exe.exitCode());
|
||||
Assert.assertEquals(0, exe.stdoutLines().size());
|
||||
Assert.assertEquals(1, exe.stderrLines().size());
|
||||
Assert.assertTrue(exe.stderrLines().get(0), exe.stderrLines().get(0).contains("failed to exchange token: invalid_client Audience not found"));
|
||||
}
|
||||
|
||||
exe = KcinitExec.execute("logout");
|
||||
Assert.assertEquals(0, exe.exitCode());
|
||||
|
|
|
@ -39,7 +39,8 @@ public class ThemeSelectorTest extends AbstractTestRealmKeycloakTest {
|
|||
}
|
||||
|
||||
private String detectTheme() {
|
||||
if(driver.getPageSource().contains("/login/keycloak/css/login.css")) {
|
||||
// for the purpose of the test does not matter which profile is used (product or community)
|
||||
if(driver.getPageSource().contains("/login/keycloak/css/login.css") || driver.getPageSource().contains("/login/rh-sso/css/login.css")) {
|
||||
return "keycloak";
|
||||
} else {
|
||||
return "base";
|
||||
|
|
Loading…
Reference in a new issue