Skip to content

Commit

Permalink
OAuthGrantTest migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Oliveira committed May 9, 2016
1 parent 0ec23fd commit bb6a7e3
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 121 deletions.
Expand Up @@ -122,10 +122,15 @@ public AuthorizationCodeResponse doLogin(String username, String password) {


public void doLoginGrant(String username, String password) { public void doLoginGrant(String username, String password) {
openLoginForm(); openLoginForm();

String src = driver.getPageSource();
driver.findElement(By.id("username")).sendKeys(username); try {
driver.findElement(By.id("password")).sendKeys(password); driver.findElement(By.id("username")).sendKeys(username);
driver.findElement(By.name("login")).click(); driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.name("login")).click();
} catch (Throwable t) {
System.err.println(src);
throw t;
}
} }


public AccessTokenResponse doAccessTokenRequest(String code, String password) { public AccessTokenResponse doAccessTokenRequest(String code, String password) {
Expand Down
Expand Up @@ -23,6 +23,7 @@
import org.keycloak.admin.client.resource.UserResource; import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.ClientRepresentation;
import org.keycloak.representations.idm.CredentialRepresentation; import org.keycloak.representations.idm.CredentialRepresentation;
import org.keycloak.representations.idm.ProtocolMapperRepresentation;
import org.keycloak.representations.idm.RoleRepresentation; import org.keycloak.representations.idm.RoleRepresentation;
import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.representations.idm.UserRepresentation;


Expand Down Expand Up @@ -90,6 +91,15 @@ public static RoleResource findClientRoleByName(ClientResource client, String ro
return client.roles().get(role); return client.roles().get(role);
} }


public static ProtocolMapperRepresentation findProtocolMapperByName(ClientResource client, String name) {
for (ProtocolMapperRepresentation p : client.getProtocolMappers().getMappers()) {
if (p.getName().equals(name)) {
return p;
}
}
return null;
}

public static RoleResource findRealmRoleByName(RealmResource realm, String role) { public static RoleResource findRealmRoleByName(RealmResource realm, String role) {
return realm.roles().get(role); return realm.roles().get(role);
} }
Expand Down

0 comments on commit bb6a7e3

Please sign in to comment.