Fix showing federation links of users in admin console

This commit is contained in:
mposolda 2015-02-11 12:24:24 +01:00
parent 4b637036ac
commit 03d607b022
4 changed files with 22 additions and 23 deletions

View file

@ -133,7 +133,6 @@ module.controller('UserFederatedIdentityCtrl', function($scope, realm, user, fed
$scope.realm = realm;
$scope.user = user;
$scope.federatedIdentities = federatedIdentities;
console.log('showing federated identities of user');
});

View file

@ -54,16 +54,16 @@ public interface UserResource {
public List<UserSessionRepresentation> getUserSessions();
@GET
@Path("social-links")
public List<FederatedIdentityRepresentation> getSocialLinks();
@Path("federated-identity")
public List<FederatedIdentityRepresentation> getFederatedIdentity();
@POST
@Path("social-links/{provider}")
public Response addSocialLink(@PathParam("provider") String provider, FederatedIdentityRepresentation rep);
@Path("federated-identity/{provider}")
public Response addFederatedIdentity(@PathParam("provider") String provider, FederatedIdentityRepresentation rep);
@Path("social-links/{provider}")
@Path("federated-identity/{provider}")
@DELETE
public void removeSocialLink(final @PathParam("provider") String provider);
public void removeFederatedIdentity(final @PathParam("provider") String provider);
@Path("role-mappings")
public RoleMappingResource roles();

View file

@ -264,7 +264,7 @@ public class UsersResource {
for (FederatedIdentityModel identity : identities) {
for (IdentityProviderModel identityProviderModel : realm.getIdentityProviders()) {
if (identityProviderModel.getProviderId().equals(identity.getIdentityProvider())) {
if (identityProviderModel.getId().equals(identity.getIdentityProvider())) {
FederatedIdentityRepresentation rep = ModelToRepresentation.toRepresentation(identity);
rep.setIdentityProvider(identityProviderModel.getName());
@ -276,10 +276,10 @@ public class UsersResource {
return result;
}
@Path("{username}/social-links/{provider}")
@Path("{username}/federated-identity/{provider}")
@POST
@NoCache
public Response addSocialLink(final @PathParam("username") String username, final @PathParam("provider") String provider, FederatedIdentityRepresentation rep) {
public Response addFederatedIdentity(final @PathParam("username") String username, final @PathParam("provider") String provider, FederatedIdentityRepresentation rep) {
auth.requireManage();
UserModel user = session.users().getUserByUsername(username, realm);
if (user == null) {
@ -295,10 +295,10 @@ public class UsersResource {
return Response.noContent().build();
}
@Path("{username}/social-links/{provider}")
@Path("{username}/federated-identity/{provider}")
@DELETE
@NoCache
public void removeSocialLink(final @PathParam("username") String username, final @PathParam("provider") String provider) {
public void removeFederatedIdentity(final @PathParam("username") String username, final @PathParam("provider") String provider) {
auth.requireManage();
UserModel user = session.users().getUserByUsername(username, realm);
if (user == null) {

View file

@ -114,7 +114,7 @@ public class UserTest extends AbstractClientTest {
}
@Test
public void addSocialLink() {
public void addFederatedIdentity() {
createUser();
UserResource user = realm.users().get("user1");
@ -123,19 +123,19 @@ public class UserTest extends AbstractClientTest {
link.setUserId("social-user-id");
link.setUserName("social-username");
Response response = user.addSocialLink("social-provider-id", link);
Response response = user.addFederatedIdentity("social-provider-id", link);
assertEquals(204, response.getStatus());
}
@Test
@Ignore("Refactor based on KEYCLOAK-883")
public void getSocialLinks() {
addSocialLink();
public void getFederatedIdentities() {
addFederatedIdentity();
UserResource user = realm.users().get("user1");
assertEquals(1, user.getSocialLinks().size());
assertEquals(1, user.getFederatedIdentity().size());
FederatedIdentityRepresentation link = user.getSocialLinks().get(0);
FederatedIdentityRepresentation link = user.getFederatedIdentity().get(0);
assertEquals("social-provider-id", link.getIdentityProvider());
assertEquals("social-user-id", link.getUserId());
assertEquals("social-username", link.getUserName());
@ -143,15 +143,15 @@ public class UserTest extends AbstractClientTest {
@Test
@Ignore("Refactor based on KEYCLOAK-883")
public void removeSocialLink() {
addSocialLink();
public void removeFederatedIdentity() {
addFederatedIdentity();
UserResource user = realm.users().get("user1");
assertEquals(1, user.getSocialLinks().size());
assertEquals(1, user.getFederatedIdentity().size());
user.removeSocialLink("social-provider-id");
user.removeFederatedIdentity("social-provider-id");
assertEquals(0, user.getSocialLinks().size());
assertEquals(0, user.getFederatedIdentity().size());
}
@Test