KEYCLOAK-3365 Add test case

This commit is contained in:
Sven-Torben Janus 2020-10-13 22:29:30 +02:00 committed by Marek Posolda
parent 79f0703d62
commit 5918094840

View file

@ -46,6 +46,8 @@ import org.keycloak.testsuite.util.LDAPRule;
import org.keycloak.testsuite.util.LDAPTestUtils; import org.keycloak.testsuite.util.LDAPTestUtils;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import javax.ws.rs.ClientErrorException;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -125,6 +127,23 @@ public class LDAPReadOnlyTest extends AbstractLDAPTest {
user.removeCredential(totpCredentialId); user.removeCredential(totpCredentialId);
} }
// KEYCLOAK-3365
@Test
public void testReadOnlyUserDoesNotThrowIfUnchanged() {
UserResource user = ApiUtil.findUserByUsernameId(testRealm(), "johnkeycloak");
UserRepresentation userRepresentation = user.toRepresentation();
user.update(userRepresentation);
}
// KEYCLOAK-3365
@Test(expected = ClientErrorException.class)
public void testReadOnlyUserThrowsIfChanged() {
UserResource user = ApiUtil.findUserByUsernameId(testRealm(), "johnkeycloak");
UserRepresentation userRepresentation = user.toRepresentation();
userRepresentation.setFirstName("Jane");
user.update(userRepresentation);
}
private void setTotpRequirementExecutionForRealm(AuthenticationExecutionModel.Requirement requirement) { private void setTotpRequirementExecutionForRealm(AuthenticationExecutionModel.Requirement requirement) {
adminClient.realm("test").flows().getExecutions("browser"). adminClient.realm("test").flows().getExecutions("browser").
stream().filter(execution -> execution.getDisplayName().equals("Browser - Conditional OTP")) stream().filter(execution -> execution.getDisplayName().equals("Browser - Conditional OTP"))