Merge pull request #3526 from mhajas/KEYCLOAK-3017
KEYCLOAK-3017 Location header not present in responses from admin endpoints test
This commit is contained in:
commit
d7df86d6d0
4 changed files with 54 additions and 1 deletions
|
@ -19,7 +19,7 @@
|
|||
],
|
||||
"realmRoles": [ "user" ],
|
||||
"clientRoles": {
|
||||
"realm-management" : [ "view-realm" ],
|
||||
"realm-management" : [ "view-realm", "manage-users" ],
|
||||
"account": ["view-profile", "manage-account"]
|
||||
}
|
||||
},{
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
<button onclick="addToTimeSkew()">timeSkew offset</button>
|
||||
<button onclick="refreshTimeSkew()">refresh timeSkew</button>
|
||||
<button onclick="sendBearerToKeycloak()">Bearer to keycloak</button>
|
||||
<button onclick="createUser()">Create user</button>
|
||||
|
||||
|
||||
<select id="flowSelect">
|
||||
|
@ -240,6 +241,35 @@ TimeSkew: <div id="timeSkew"></div>
|
|||
req.send();
|
||||
}
|
||||
|
||||
function createUser() {
|
||||
var user = JSON.parse('{"emailVerified" : false, "enabled" : true, "username": "mhajas", "firstName" :"First", "lastName":"Last","email":"email@redhat.com", "attributes": {}}');
|
||||
|
||||
var url = "http://localhost:8180/auth/admin/realms/example/users";
|
||||
if (window.location.href.indexOf("8543") > -1) {
|
||||
url = url.replace("8180","8543");
|
||||
url = url.replace("http","https");
|
||||
}
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
req.open("POST", url, true);
|
||||
req.setRequestHeader('Accept', 'application/json');
|
||||
req.setRequestHeader('Authorization', 'Bearer ' + keycloak.token);
|
||||
req.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
|
||||
req.onreadystatechange = function () {
|
||||
if (req.readyState == 4) {
|
||||
if (req.status == 201) {
|
||||
output("Response headers: " + req.getAllResponseHeaders().toLowerCase());
|
||||
} else if (req.status == 403) {
|
||||
output('Forbidden');
|
||||
} else if (req.status == 401) {
|
||||
output('Unauthorized');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
req.send(JSON.stringify(user));
|
||||
}
|
||||
|
||||
var keycloak;
|
||||
|
||||
function keycloakInit() {
|
||||
|
|
|
@ -81,6 +81,8 @@ public class JSConsoleTestApp extends AbstractPageWithInjectedUrl {
|
|||
private WebElement certRequestButton;
|
||||
@FindBy(xpath = "//button[text() = 'refresh timeSkew']")
|
||||
private WebElement refreshTimeSkewButton;
|
||||
@FindBy(xpath = "//button[text() = 'Create user']")
|
||||
private WebElement createUserButton;
|
||||
|
||||
@FindBy(id = "timeSkew")
|
||||
private WebElement timeSkewValue;
|
||||
|
@ -181,6 +183,10 @@ public class JSConsoleTestApp extends AbstractPageWithInjectedUrl {
|
|||
refreshTimeSkewButton.click();
|
||||
}
|
||||
|
||||
public void createUserRequest() {
|
||||
createUserButton.click();
|
||||
}
|
||||
|
||||
public void sendCertRequest() {
|
||||
certRequestButton.click();
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ import org.jboss.arquillian.graphene.page.Page;
|
|||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.admin.client.resource.ClientResource;
|
||||
import org.keycloak.admin.client.resource.UsersResource;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.representations.idm.UserRepresentation;
|
||||
import org.keycloak.testsuite.adapter.AbstractExampleAdapterTest;
|
||||
import org.keycloak.testsuite.adapter.page.JSConsoleTestApp;
|
||||
import org.keycloak.testsuite.adapter.page.JSDatabaseTestApp;
|
||||
|
@ -412,6 +414,21 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
|||
assertTrue("TimeSkew was: " + timeSkew + ", but should be ~-40", timeSkew + 40 <= TIME_SKEW_TOLERANCE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocationHeaderInResponse() {
|
||||
logInAndInit("standard");
|
||||
waitUntilElement(jsConsoleTestAppPage.getOutputElement()).text().contains("Init Success (Authenticated)");
|
||||
|
||||
jsConsoleTestAppPage.createUserRequest();
|
||||
|
||||
UsersResource userResource = testRealmResource().users();
|
||||
|
||||
List<UserRepresentation> users = userResource.search("mhajas", 0, 1);
|
||||
assertEquals("There should be created user mhajas", 1, users.size());
|
||||
waitUntilElement(jsConsoleTestAppPage.getOutputElement()).text()
|
||||
.contains("location: " + authServerContextRootPage.toString() + "/auth/admin/realms/" + EXAMPLE + "/users/" + users.get(0).getId());
|
||||
}
|
||||
|
||||
private void setImplicitFlowForClient() {
|
||||
ClientResource clientResource = ApiUtil.findClientResourceByClientId(testRealmResource(), "js-console");
|
||||
ClientRepresentation client = clientResource.toRepresentation();
|
||||
|
|
Loading…
Reference in a new issue