added UI tests for client scope
This commit is contained in:
parent
1dd3fc537b
commit
1b936a1230
9 changed files with 202 additions and 34 deletions
|
@ -76,9 +76,9 @@
|
|||
</div>
|
||||
<div class="row" data-ng-show="targetClient">
|
||||
<div class="col-md-3">
|
||||
<label class="control-label" for="client-available">{{:: 'available-roles' | translate}}</label>
|
||||
<label class="control-label" for="available-client">{{:: 'available-roles' | translate}}</label>
|
||||
<kc-tooltip>{{:: 'assign.available-roles.tooltip' | translate}}</kc-tooltip>
|
||||
<select id="client-available" class="form-control" multiple size="5"
|
||||
<select id="available-client" class="form-control" multiple size="5"
|
||||
ng-multiple="true"
|
||||
ng-model="selectedClientRoles"
|
||||
ng-options="r.name for r in clientRoles">
|
||||
|
@ -88,9 +88,9 @@
|
|||
</button>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="control-label" for="client-assigned">{{:: 'assigned-roles' | translate}}</label>
|
||||
<label class="control-label" for="assigned-client">{{:: 'assigned-roles' | translate}}</label>
|
||||
<kc-tooltip>{{:: 'client.assigned-roles.tooltip' | translate}}</kc-tooltip>
|
||||
<select id="client-assigned" class="form-control" multiple size=5
|
||||
<select id="assigned-client" class="form-control" multiple size=5
|
||||
ng-multiple="true"
|
||||
ng-model="selectedClientMappings"
|
||||
ng-options="r.name for r in clientMappings">
|
||||
|
|
|
@ -65,9 +65,9 @@
|
|||
</div>
|
||||
<div class="row" data-ng-show="targetClient">
|
||||
<div class="col-md-3">
|
||||
<label class="control-label" for="client-available">{{:: 'available-roles' | translate}}</label>
|
||||
<label class="control-label" for="available-client">{{:: 'available-roles' | translate}}</label>
|
||||
<kc-tooltip>{{:: 'assign.available-roles.tooltip' | translate}}</kc-tooltip>
|
||||
<select id="client-available" class="form-control" multiple size="5"
|
||||
<select id="available-client" class="form-control" multiple size="5"
|
||||
ng-multiple="true"
|
||||
ng-model="selectedClientRoles"
|
||||
ng-options="r.name for r in clientRoles">
|
||||
|
@ -77,9 +77,9 @@
|
|||
</button>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="control-label" for="client-assigned">{{:: 'assigned-roles' | translate}}</label>
|
||||
<label class="control-label" for="assigned-client">{{:: 'assigned-roles' | translate}}</label>
|
||||
<kc-tooltip>{{:: 'client.assigned-roles.tooltip' | translate}}</kc-tooltip>
|
||||
<select id="client-assigned" class="form-control" multiple size=5
|
||||
<select id="assigned-client" class="form-control" multiple size=5
|
||||
ng-multiple="true"
|
||||
ng-model="selectedClientMappings"
|
||||
ng-options="r.name for r in clientMappings">
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package org.keycloak.testsuite.console.page.clients;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tkyjovsk
|
||||
*/
|
||||
public class ClientScopeMappings extends Client {
|
||||
|
||||
@Override
|
||||
public String getUriFragment() {
|
||||
return super.getUriFragment() + "/scope-mappings";
|
||||
}
|
||||
|
||||
}
|
|
@ -9,8 +9,6 @@ import org.openqa.selenium.support.ui.Select;
|
|||
|
||||
/**
|
||||
* @author Vaclav Muzikar <vmuzikar@redhat.com>
|
||||
*
|
||||
* TODO: SAML
|
||||
*/
|
||||
public class CreateClientMappersForm extends Form {
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package org.keycloak.testsuite.console.page.roles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -88,6 +90,14 @@ public class RoleCompositeRoles extends Form {
|
|||
button.click();
|
||||
}
|
||||
|
||||
public void addRealmRole(String role) {
|
||||
addMissingRoles(availableRealmRolesSelect, addSelectedRealmRolesButton, Arrays.asList(role));
|
||||
}
|
||||
|
||||
public void addClientRole(String role) {
|
||||
addMissingRoles(availableClientRolesSelect, addSelectedClientRolesButton, Arrays.asList(role));
|
||||
}
|
||||
|
||||
protected void addMissingRoles(Select select, WebElement button, Collection<String> roles) {
|
||||
select.deselectAll();
|
||||
if (roles != null) { // if roles not provided, don't add any
|
||||
|
|
|
@ -41,39 +41,39 @@ public class ClientCredentialsTest extends AbstractClientTest {
|
|||
private ClientRepresentation newClient;
|
||||
|
||||
@Page
|
||||
private ClientCredentials clientCredentials;
|
||||
private ClientCredentials clientCredentialsPage;
|
||||
@Page
|
||||
private ClientCredentialsGeneratePrivateKeys generatePrivateKeysPage;
|
||||
|
||||
@Before
|
||||
public void beforeClientsTest() {
|
||||
public void before() {
|
||||
newClient = createOidcClientRep(CONFIDENTIAL, TEST_CLIENT_ID, TEST_REDIRECT_URIS);
|
||||
testRealmResource().clients().create(newClient).close();
|
||||
|
||||
ClientRepresentation found = findClientByClientId(TEST_CLIENT_ID);
|
||||
assertNotNull("Client " + TEST_CLIENT_ID + " was not found.", found);
|
||||
clientCredentials.setId(found.getId());
|
||||
clientCredentials.navigateTo();
|
||||
clientCredentialsPage.setId(found.getId());
|
||||
clientCredentialsPage.navigateTo();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regenerateSecret() {
|
||||
clientCredentials.form().selectClientIdAndSecret();
|
||||
clientCredentials.form().regenerateSecret();
|
||||
clientCredentialsPage.form().selectClientIdAndSecret();
|
||||
clientCredentialsPage.form().regenerateSecret();
|
||||
assertFlashMessageSuccess();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regenerateRegistrationAccessToken() {
|
||||
clientCredentials.form().regenerateRegistrationAccessToken();
|
||||
clientCredentialsPage.form().regenerateRegistrationAccessToken();
|
||||
assertFlashMessageSuccess();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateNewKeysAndCert() {
|
||||
generatePrivateKeysPage.setId(clientCredentials.getId());
|
||||
clientCredentials.form().selectSignedJwt();
|
||||
clientCredentials.form().generateNewKeysAndCert();
|
||||
generatePrivateKeysPage.setId(clientCredentialsPage.getId());
|
||||
clientCredentialsPage.form().selectSignedJwt();
|
||||
clientCredentialsPage.form().generateNewKeysAndCert();
|
||||
assertCurrentUrlEquals(generatePrivateKeysPage);
|
||||
|
||||
generatePrivateKeysPage.generateForm().setKeyPassword("pass");
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue