Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vramik
committed
Dec 4, 2015
1 parent
1dd3fc5
commit 1b936a1
Showing
9 changed files
with
202 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
...s/base/src/main/java/org/keycloak/testsuite/console/page/clients/ClientScopeMappings.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...sts/base/src/main/java/org/keycloak/testsuite/console/page/clients/scope/ClientScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
package org.keycloak.testsuite.console.page.clients.scope; | |||
|
|||
import org.jboss.arquillian.graphene.page.Page; | |||
import org.keycloak.testsuite.console.page.clients.Client; | |||
import org.keycloak.testsuite.console.page.roles.RoleCompositeRoles; | |||
|
|||
/** | |||
* | |||
* @author tkyjovsk | |||
*/ | |||
public class ClientScope extends Client { | |||
|
|||
@Override | |||
public String getUriFragment() { | |||
return super.getUriFragment() + "/scope-mappings"; | |||
} | |||
|
|||
@Page | |||
private ClientScopeForm clientScopeForm; | |||
|
|||
@Page | |||
private RoleCompositeRoles scopeRoleForm; | |||
|
|||
public ClientScopeForm scopeForm() { | |||
return clientScopeForm; | |||
} | |||
|
|||
public RoleCompositeRoles roleForm() { | |||
return scopeRoleForm; | |||
} | |||
} |
41 changes: 41 additions & 0 deletions
41
...base/src/main/java/org/keycloak/testsuite/console/page/clients/scope/ClientScopeForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,41 @@ | |||
/* | |||
* JBoss, Home of Professional Open Source. | |||
* Copyright 2012, Red Hat, Inc., and individual contributors | |||
* as indicated by the @author tags. See the copyright.txt file in the | |||
* distribution for a full listing of individual contributors. | |||
* | |||
* This is free software; you can redistribute it and/or modify it | |||
* under the terms of the GNU Lesser General Public License as | |||
* published by the Free Software Foundation; either version 2.1 of | |||
* the License, or (at your option) any later version. | |||
* | |||
* This software is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public | |||
* License along with this software; if not, write to the Free | |||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |||
*/ | |||
package org.keycloak.testsuite.console.page.clients.scope; | |||
|
|||
import org.keycloak.testsuite.console.page.fragment.OnOffSwitch; | |||
import org.keycloak.testsuite.page.Form; | |||
import org.openqa.selenium.support.FindBy; | |||
|
|||
/** | |||
* | |||
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a> | |||
*/ | |||
public class ClientScopeForm extends Form { | |||
|
|||
@FindBy(className = "onoffswitch") | |||
private OnOffSwitch fullScopeAllowedSwitch; | |||
|
|||
|
|||
public void setFullScopeAllowed(boolean value) { | |||
fullScopeAllowedSwitch.setOn(value); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...lian/tests/base/src/test/java/org/keycloak/testsuite/console/clients/ClientScopeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,102 @@ | |||
/* | |||
* JBoss, Home of Professional Open Source. | |||
* Copyright 2012, Red Hat, Inc., and individual contributors | |||
* as indicated by the @author tags. See the copyright.txt file in the | |||
* distribution for a full listing of individual contributors. | |||
* | |||
* This is free software; you can redistribute it and/or modify it | |||
* under the terms of the GNU Lesser General Public License as | |||
* published by the Free Software Foundation; either version 2.1 of | |||
* the License, or (at your option) any later version. | |||
* | |||
* This software is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public | |||
* License along with this software; if not, write to the Free | |||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |||
*/ | |||
package org.keycloak.testsuite.console.clients; | |||
|
|||
import java.util.List; | |||
import java.util.Map; | |||
import org.jboss.arquillian.graphene.page.Page; | |||
import static org.junit.Assert.*; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.keycloak.representations.idm.ClientMappingsRepresentation; | |||
import org.keycloak.representations.idm.ClientRepresentation; | |||
import org.keycloak.representations.idm.MappingsRepresentation; | |||
import org.keycloak.representations.idm.RoleRepresentation; | |||
import static org.keycloak.testsuite.console.clients.AbstractClientTest.createOidcClientRep; | |||
import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.CONFIDENTIAL; | |||
import org.keycloak.testsuite.console.page.clients.credentials.ClientCredentialsGeneratePrivateKeys; | |||
import org.keycloak.testsuite.console.page.clients.scope.ClientScope; | |||
|
|||
/** | |||
* | |||
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a> | |||
*/ | |||
public class ClientScopeTest extends AbstractClientTest { | |||
|
|||
private ClientRepresentation newClient; | |||
private ClientRepresentation found; | |||
|
|||
@Page | |||
private ClientScope clientScopePage; | |||
@Page | |||
private ClientCredentialsGeneratePrivateKeys generatePrivateKeysPage; | |||
|
|||
@Before | |||
public void before() { | |||
newClient = createOidcClientRep(CONFIDENTIAL, TEST_CLIENT_ID, TEST_REDIRECT_URIS); | |||
testRealmResource().clients().create(newClient).close(); | |||
|
|||
found = findClientByClientId(TEST_CLIENT_ID); | |||
assertNotNull("Client " + TEST_CLIENT_ID + " was not found.", found); | |||
clientScopePage.setId(found.getId()); | |||
clientScopePage.navigateTo(); | |||
} | |||
|
|||
@Test | |||
public void clientScopeTest() { | |||
assertTrue(found.isFullScopeAllowed()); | |||
clientScopePage.scopeForm().setFullScopeAllowed(false); | |||
assertFlashMessageSuccess(); | |||
|
|||
found = findClientByClientId(TEST_CLIENT_ID); | |||
assertFalse(found.isFullScopeAllowed()); | |||
assertNull(getAllMappingsRepresentation().getRealmMappings()); | |||
assertNull(getAllMappingsRepresentation().getClientMappings()); | |||
|
|||
clientScopePage.roleForm().addRealmRole("offline_access"); | |||
assertFlashMessageSuccess(); | |||
|
|||
clientScopePage.roleForm().selectClientRole("account"); | |||
clientScopePage.roleForm().addClientRole("view-profile"); | |||
assertFlashMessageSuccess(); | |||
|
|||
found = findClientByClientId(TEST_CLIENT_ID); | |||
List<RoleRepresentation> realmMappings = getAllMappingsRepresentation().getRealmMappings(); | |||
assertEquals(1, realmMappings.size()); | |||
assertEquals("offline_access", realmMappings.get(0).getName()); | |||
Map<String, ClientMappingsRepresentation> clientMappings = getAllMappingsRepresentation().getClientMappings(); | |||
assertEquals(1, clientMappings.size()); | |||
assertEquals("view-profile", clientMappings.get("account").getMappings().get(0).getName()); | |||
|
|||
clientScopePage.roleForm().removeAssignedRole("offline_access"); | |||
assertFlashMessageSuccess(); | |||
clientScopePage.roleForm().removeAssignedClientRole("view-profile"); | |||
assertFlashMessageSuccess(); | |||
|
|||
assertNull(getAllMappingsRepresentation().getRealmMappings()); | |||
assertNull(getAllMappingsRepresentation().getClientMappings()); | |||
} | |||
|
|||
private MappingsRepresentation getAllMappingsRepresentation() { | |||
return testRealmResource().clients().get(found.getId()).getScopeMappings().getAll(); | |||
} | |||
} |