[KEYCLOAK-6376] Directly create group

This commit is contained in:
Martin Reinhardt 2019-10-19 04:50:32 +02:00 committed by Stian Thorgersen
parent 21a62a2670
commit 5ad05c9317

View File

@ -372,19 +372,15 @@ public class CustomAuthFlowOTPTest extends AbstractCustomAccountManagementTest {
}
private GroupRepresentation getOrCreateOTPRoleInGroup() {
try {
return testRealmResource().groups().groups("otp_group",0,1).get(0);
} catch (NotFoundException | IndexOutOfBoundsException ex ) {
GroupRepresentation group = new GroupRepresentation();
group.setName("otp_group");
RoleRepresentation role = getOrCreateOTPRole();
testRealmResource().groups().add(group);
//obtain id
GroupRepresentation groupRep = testRealmResource().groups().groups("otp_group",0,1).get(0);
testRealmResource().groups().group(groupRep.getId()).roles().realmLevel().add(Arrays.asList(role));
//reread
return testRealmResource().groups().groups("otp_group",0,1).get(0);
}
GroupRepresentation group = new GroupRepresentation();
group.setName("otp_group");
RoleRepresentation role = getOrCreateOTPRole();
testRealmResource().groups().add(group);
// obtain id
GroupRepresentation groupRep = testRealmResource().groups().groups("otp_group",0,1).get(0);
testRealmResource().groups().group(groupRep.getId()).roles().realmLevel().add(Arrays.asList(role));
// reread
return testRealmResource().groups().groups("otp_group",0,1).get(0);
}
@Test