Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Bill Burke 2015-10-01 14:28:04 -04:00
commit c5efd34a46
7 changed files with 57 additions and 16 deletions

View file

@ -12,7 +12,7 @@ public interface JpaUpdaterProvider extends Provider {
public String FIRST_VERSION = "1.0.0.Final";
public String LAST_VERSION = "1.5.0";
public String LAST_VERSION = "1.6.0";
public String getCurrentVersionSql(String defaultSchema);

View file

@ -56,8 +56,7 @@
<jboss.version>7.5.0.Final-redhat-15</jboss.version>
<servlet.api.30.version>1.0.2.Final</servlet.api.30.version>
<google.zxing.version>2.2</google.zxing.version>
<google.client.version>1.14.1-beta</google.client.version>
<google.zxing.version>3.2.1</google.zxing.version>
<github.relaxng.version>2011.1</github.relaxng.version>
<winzipaes.version>1.0.1</winzipaes.version>
<freemarker.version>2.3.23</freemarker.version>

View file

@ -17,7 +17,7 @@ public class FacebookIdentityProvider extends AbstractOAuth2IdentityProvider imp
public static final String AUTH_URL = "https://graph.facebook.com/oauth/authorize";
public static final String TOKEN_URL = "https://graph.facebook.com/oauth/access_token";
public static final String PROFILE_URL = "https://graph.facebook.com/me";
public static final String PROFILE_URL = "https://graph.facebook.com/me?fields=id,name,email,first_name,last_name";
public static final String DEFAULT_SCOPE = "email";
public FacebookIdentityProvider(OAuth2IdentityProviderConfig config) {

View file

@ -25,8 +25,8 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.jboss.logging.Logger;
import org.keycloak.admin.client.resource.ClientResource;
import org.keycloak.admin.client.resource.RoleScopeResource;
import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.representations.idm.CredentialRepresentation;
import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD;
@ -37,6 +37,8 @@ import org.keycloak.representations.idm.UserRepresentation;
* Created by st on 28.05.15.
*/
public class ApiUtil {
private static final Logger log = Logger.getLogger(ApiUtil.class);
public static String getCreatedId(Response response) {
URI location = response.getLocation();
@ -96,16 +98,32 @@ public class ApiUtil {
userResource.resetPassword(newCredential);
}
public static void assignClientRoles(UserResource userResource, String clientId, String... roles) {
RoleScopeResource rsr = userResource.roles().clientLevel(clientId);
List<String> rolesList = Arrays.asList(roles);
List<RoleRepresentation> realmMgmtRoles = new ArrayList<>();
for (RoleRepresentation rr : rsr.listAvailable()) {
if (rolesList.contains(rr.getName())) {
realmMgmtRoles.add(rr);
public static void assignClientRoles(RealmResource realm, String userId, String clientName, String... roles) {
String realmName = realm.toRepresentation().getRealm();
String clientId = "";
for (ClientRepresentation clientRepresentation : realm.clients().findAll()) {
if (clientRepresentation.getClientId().equals(clientName)) {
clientId = clientRepresentation.getId();
}
}
rsr.add(realmMgmtRoles);
if (!clientId.isEmpty()) {
ClientResource clientResource = realm.clients().get(clientId);
List<RoleRepresentation> roleRepresentations = new ArrayList<>();
for (String roleName : roles) {
RoleRepresentation role = clientResource.roles().get(roleName).toRepresentation();
roleRepresentations.add(role);
}
UserResource userResource = realm.users().get(userId);
log.debug("assigning roles: " + Arrays.toString(roles) + " to user: \"" +
userResource.toRepresentation().getUsername() + "\" of client: \"" +
clientName + "\" in realm: \"" + realmName + "\"");
userResource.roles().clientLevel(clientId).add(roleRepresentations);
} else {
log.warn("client with name " + clientName + "doesn't exist in realm " + realmName);
}
}
}

View file

@ -2,6 +2,7 @@ package org.keycloak.testsuite.console.page.events;
import org.keycloak.testsuite.console.page.fragment.OnOffSwitch;
import org.keycloak.testsuite.page.Form;
import static org.keycloak.testsuite.util.WaitUtils.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
@ -101,5 +102,9 @@ public class Config extends Events {
public void clearAdminEvents() {
clearAdminEventsButton.click();
}
public void waitForClearEventsButtonPresent() {
waitAjaxForElement(clearLoginEventsButton);
}
}
}

View file

@ -1,3 +1,20 @@
/*
* JBoss, Home of Professional Open Source
*
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.testsuite;
import java.text.MessageFormat;
@ -10,7 +27,7 @@ import org.keycloak.admin.client.resource.RealmResource;
import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.UserRepresentation;
import static org.keycloak.testsuite.admin.ApiUtil.createUserAndResetPasswordWithAdminClient;
import static org.keycloak.testsuite.admin.ApiUtil.*;
import static org.keycloak.testsuite.admin.Users.setPasswordFor;
import org.keycloak.testsuite.auth.page.AuthRealm;
import static org.keycloak.testsuite.auth.page.AuthRealm.TEST;
@ -56,6 +73,8 @@ public abstract class AbstractAuthTest extends AbstractKeycloakTest {
log.debug("creating test user");
String id = createUserAndResetPasswordWithAdminClient(testRealmResource(), testUser, PASSWORD);
testUser.setId(id);
assignClientRoles(testRealmResource(), id, "realm-management", "view-realm");
}
public static UserRepresentation createUserRepresentation(String username, String email, String firstName, String lastName, boolean enabled) {

View file

@ -21,14 +21,14 @@ import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD
public class LoginEventsTest extends AbstractConsoleTest {
@Page
private LoginEvents loginEventsPage;
@Page
private Config configPage;
@Before
public void beforeLoginEventsTest() {
configPage.navigateTo();
configPage.form().setSaveEvents(true);
configPage.form().waitForClearEventsButtonPresent();
configPage.form().addSaveType("LOGIN");
configPage.form().addSaveType("LOGIN_ERROR");
configPage.form().addSaveType("LOGOUT");