KEYCLOAK-3653 Tests for cert endpoint
This commit is contained in:
parent
cf17687b8b
commit
8fc5b00d91
3 changed files with 51 additions and 0 deletions
|
@ -43,6 +43,7 @@
|
||||||
<button onclick="output(keycloak.createRegisterUrl())">Show Register URL</button>
|
<button onclick="output(keycloak.createRegisterUrl())">Show Register URL</button>
|
||||||
<button onclick="createBearerRequest()">Create Bearer Request</button>
|
<button onclick="createBearerRequest()">Create Bearer Request</button>
|
||||||
<button onclick="output(showTime())">Show current time</button>
|
<button onclick="output(showTime())">Show current time</button>
|
||||||
|
<button onclick="cert()">Cert request</button>
|
||||||
<input id="timeSkewInput"/>
|
<input id="timeSkewInput"/>
|
||||||
<button onclick="addToTimeSkew()">timeSkew offset</button>
|
<button onclick="addToTimeSkew()">timeSkew offset</button>
|
||||||
<button onclick="refreshTimeSkew()">refresh timeSkew</button>
|
<button onclick="refreshTimeSkew()">refresh timeSkew</button>
|
||||||
|
@ -215,6 +216,30 @@ TimeSkew: <div id="timeSkew"></div>
|
||||||
req.send();
|
req.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cert() {
|
||||||
|
var url = 'http://localhost:8180/auth/realms/example/protocol/openid-connect/certs';
|
||||||
|
if (window.location.href.indexOf("8543") > -1) {
|
||||||
|
url = url.replace("8180","8543");
|
||||||
|
url = url.replace("http","https");
|
||||||
|
}
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
req.open('GET', url, true);
|
||||||
|
req.setRequestHeader('Accept', 'application/json');
|
||||||
|
req.setRequestHeader('Authorization', 'Bearer ' + keycloak.token);
|
||||||
|
req.onreadystatechange = function () {
|
||||||
|
if (req.readyState == 4) {
|
||||||
|
if (req.status == 200) {
|
||||||
|
output('Success');
|
||||||
|
} else if (req.status == 403) {
|
||||||
|
output('Forbidden');
|
||||||
|
} else if (req.status == 401) {
|
||||||
|
output('Unauthorized');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
req.send();
|
||||||
|
}
|
||||||
|
|
||||||
var keycloak;
|
var keycloak;
|
||||||
|
|
||||||
function keycloakInit() {
|
function keycloakInit() {
|
||||||
|
|
|
@ -77,6 +77,8 @@ public class JSConsoleTestApp extends AbstractPageWithInjectedUrl {
|
||||||
private WebElement createBearerRequest;
|
private WebElement createBearerRequest;
|
||||||
@FindBy(xpath = "//button[text() = 'Bearer to keycloak']")
|
@FindBy(xpath = "//button[text() = 'Bearer to keycloak']")
|
||||||
private WebElement createBearerRequestToKeycloakButton;
|
private WebElement createBearerRequestToKeycloakButton;
|
||||||
|
@FindBy(xpath = "//button[text() = 'Cert request']")
|
||||||
|
private WebElement certRequestButton;
|
||||||
@FindBy(xpath = "//button[text() = 'refresh timeSkew']")
|
@FindBy(xpath = "//button[text() = 'refresh timeSkew']")
|
||||||
private WebElement refreshTimeSkewButton;
|
private WebElement refreshTimeSkewButton;
|
||||||
|
|
||||||
|
@ -178,4 +180,8 @@ public class JSConsoleTestApp extends AbstractPageWithInjectedUrl {
|
||||||
public void refreshTimeSkew() {
|
public void refreshTimeSkew() {
|
||||||
refreshTimeSkewButton.click();
|
refreshTimeSkewButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendCertRequest() {
|
||||||
|
certRequestButton.click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,15 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
waitUntilElement(jsConsoleTestAppPage.getOutputElement()).text().contains("\"username\": \"user\"");
|
waitUntilElement(jsConsoleTestAppPage.getOutputElement()).text().contains("\"username\": \"user\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCertEndpoint() {
|
||||||
|
logInAndInit("standard");
|
||||||
|
waitUntilElement(jsConsoleTestAppPage.getOutputElement()).text().contains("Init Success (Authenticated)");
|
||||||
|
|
||||||
|
jsConsoleTestAppPage.sendCertRequest();
|
||||||
|
waitUntilElement(jsConsoleTestAppPage.getOutputElement()).text().contains("Success");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void grantBrowserBasedApp() {
|
public void grantBrowserBasedApp() {
|
||||||
testRealmPage.setAuthRealm(EXAMPLE);
|
testRealmPage.setAuthRealm(EXAMPLE);
|
||||||
|
@ -322,6 +331,16 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
waitUntilElement(jsConsoleTestAppPage.getEventsElement()).text().contains("Access token expired");
|
waitUntilElement(jsConsoleTestAppPage.getEventsElement()).text().contains("Access token expired");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void implicitFlowCertEndpoint() {
|
||||||
|
setImplicitFlowForClient();
|
||||||
|
logInAndInit("implicit");
|
||||||
|
waitUntilElement(jsConsoleTestAppPage.getOutputElement()).text().contains("Init Success (Authenticated)");
|
||||||
|
|
||||||
|
jsConsoleTestAppPage.sendCertRequest();
|
||||||
|
waitUntilElement(jsConsoleTestAppPage.getOutputElement()).text().contains("Success");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBearerRequest() {
|
public void testBearerRequest() {
|
||||||
jsConsoleTestAppPage.navigateTo();
|
jsConsoleTestAppPage.navigateTo();
|
||||||
|
@ -406,6 +425,7 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
jsConsoleTestAppPage.setFlow(flow);
|
jsConsoleTestAppPage.setFlow(flow);
|
||||||
jsConsoleTestAppPage.init();
|
jsConsoleTestAppPage.init();
|
||||||
jsConsoleTestAppPage.logIn();
|
jsConsoleTestAppPage.logIn();
|
||||||
|
waitUntilElement(By.xpath("//body")).is().present();
|
||||||
testRealmLoginPage.form().login(user, "password");
|
testRealmLoginPage.form().login(user, "password");
|
||||||
jsConsoleTestAppPage.setFlow(flow);
|
jsConsoleTestAppPage.setFlow(flow);
|
||||||
jsConsoleTestAppPage.init();
|
jsConsoleTestAppPage.init();
|
||||||
|
|
Loading…
Reference in a new issue