-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KEYCLOAK-14352] JavaScript injection vulnerability of Realm registra…
…tion REST API
- Loading branch information
1 parent
ab347df
commit 43e075a
Showing
2 changed files
with
51 additions
and
1 deletion.
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
42 changes: 42 additions & 0 deletions
42
...ration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/model/BadRealmTest.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.keycloak.testsuite.model; | ||
|
||
import org.junit.Test; | ||
import org.keycloak.models.KeycloakSession; | ||
import org.keycloak.representations.idm.RealmRepresentation; | ||
import org.keycloak.services.managers.RealmManager; | ||
import org.keycloak.testsuite.AbstractKeycloakTest; | ||
import org.keycloak.testsuite.arquillian.annotation.ModelTest; | ||
import org.keycloak.utils.ReservedCharValidator; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
public class BadRealmTest extends AbstractKeycloakTest { | ||
private String name = "MyRealm"; | ||
private String id = "MyId"; | ||
private String script = "<script>alert(4)</script>"; | ||
|
||
public void addTestRealms(List<RealmRepresentation> testRealms) { | ||
} | ||
|
||
@Test | ||
@ModelTest | ||
public void testBadRealmName(KeycloakSession session) { | ||
RealmManager manager = new RealmManager(session); | ||
try { | ||
manager.createRealm(id, name + script); | ||
fail(); | ||
} catch (ReservedCharValidator.ReservedCharException ex) {} | ||
} | ||
|
||
@Test | ||
@ModelTest | ||
public void testBadRealmId(KeycloakSession session) { | ||
RealmManager manager = new RealmManager(session); | ||
try { | ||
manager.createRealm(id + script, name); | ||
fail(); | ||
} catch (ReservedCharValidator.ReservedCharException ex) {} | ||
} | ||
} |