KEYCLOAK-3482
This commit is contained in:
parent
eea6eb6263
commit
9ef1f1b73c
13 changed files with 1 additions and 143 deletions
|
@ -120,7 +120,6 @@ public class KeycloakApplication extends Application {
|
||||||
ResteasyProviderFactory.pushContext(KeycloakApplication.class, this); // for injection
|
ResteasyProviderFactory.pushContext(KeycloakApplication.class, this); // for injection
|
||||||
context.setAttribute(KeycloakSessionFactory.class.getName(), this.sessionFactory);
|
context.setAttribute(KeycloakSessionFactory.class.getName(), this.sessionFactory);
|
||||||
|
|
||||||
singletons.add(new ServerVersionResource());
|
|
||||||
singletons.add(new RobotsResource());
|
singletons.add(new RobotsResource());
|
||||||
singletons.add(new RealmsResource());
|
singletons.add(new RealmsResource());
|
||||||
singletons.add(new AdminRoot());
|
singletons.add(new AdminRoot());
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2016 Red Hat, Inc. and/or its affiliates
|
|
||||||
* and other contributors as indicated by the @author tags.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.keycloak.services.resources;
|
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
import org.jboss.resteasy.annotations.cache.NoCache;
|
|
||||||
import org.jboss.resteasy.spi.HttpRequest;
|
|
||||||
import org.jboss.resteasy.spi.HttpResponse;
|
|
||||||
import org.keycloak.representations.VersionRepresentation;
|
|
||||||
|
|
||||||
import javax.ws.rs.GET;
|
|
||||||
import javax.ws.rs.OPTIONS;
|
|
||||||
import javax.ws.rs.Path;
|
|
||||||
import javax.ws.rs.Produces;
|
|
||||||
import javax.ws.rs.core.Context;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
|
||||||
* @version $Revision: 1 $
|
|
||||||
*/
|
|
||||||
@Path("/version")
|
|
||||||
public class ServerVersionResource {
|
|
||||||
|
|
||||||
protected static final Logger logger = Logger.getLogger(ServerVersionResource.class);
|
|
||||||
|
|
||||||
@Context
|
|
||||||
protected HttpRequest request;
|
|
||||||
|
|
||||||
@Context
|
|
||||||
protected HttpResponse response;
|
|
||||||
|
|
||||||
@OPTIONS
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public Response getVersionPreflight() {
|
|
||||||
logger.debugv("cors request from: {0}", request.getHttpHeaders().getRequestHeaders().getFirst("Origin"));
|
|
||||||
return Cors.add(request, Response.ok()).allowedMethods("GET").auth().preflight().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@NoCache
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public VersionRepresentation getVersion() {
|
|
||||||
Cors.add(request).allowedOrigins("*").allowedMethods("GET").auth().build(response);
|
|
||||||
return VersionRepresentation.SINGLETON;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -183,11 +183,6 @@ public class AdapterTest {
|
||||||
testStrategy.testBadUser();
|
testStrategy.testBadUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testVersion() throws Exception {
|
|
||||||
testStrategy.testVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAuthenticated() throws Exception {
|
public void testAuthenticated() throws Exception {
|
||||||
testStrategy.testAuthenticated();
|
testStrategy.testAuthenticated();
|
||||||
|
|
|
@ -587,28 +587,7 @@ public class AdapterTestStrategy extends ExternalResource {
|
||||||
client.close();
|
client.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testVersion() throws Exception {
|
|
||||||
Client client = ClientBuilder.newClient();
|
|
||||||
WebTarget target = client.target(AUTH_SERVER_URL).path("version");
|
|
||||||
VersionRepresentation version = target.request().get(VersionRepresentation.class);
|
|
||||||
Assert.assertNotNull(version);
|
|
||||||
Assert.assertNotNull(version.getVersion());
|
|
||||||
Assert.assertNotNull(version.getBuildTime());
|
|
||||||
Assert.assertNotEquals(version.getVersion(), Version.UNKNOWN);
|
|
||||||
Assert.assertNotEquals(version.getBuildTime(), Version.UNKNOWN);
|
|
||||||
|
|
||||||
VersionRepresentation version2 = client.target(APP_SERVER_BASE_URL + "/secure-portal").path(AdapterConstants.K_VERSION).request().get(VersionRepresentation.class);
|
|
||||||
Assert.assertNotNull(version2);
|
|
||||||
Assert.assertNotNull(version2.getVersion());
|
|
||||||
Assert.assertNotNull(version2.getBuildTime());
|
|
||||||
Assert.assertEquals(version.getVersion(), version2.getVersion());
|
|
||||||
Assert.assertEquals(version.getBuildTime(), version2.getBuildTime());
|
|
||||||
client.close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void testAuthenticated() throws Exception {
|
public void testAuthenticated() throws Exception {
|
||||||
// test login to customer-portal which does a bearer request to customer-db
|
// test login to customer-portal which does a bearer request to customer-db
|
||||||
driver.navigate().to(APP_SERVER_BASE_URL + "/secure-portal");
|
driver.navigate().to(APP_SERVER_BASE_URL + "/secure-portal");
|
||||||
|
|
|
@ -153,11 +153,6 @@ public class FilterAdapterTest {
|
||||||
testStrategy.testBadUser();
|
testStrategy.testBadUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testVersion() throws Exception {
|
|
||||||
testStrategy.testVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Don't need to test this because HttpServletRequest.authenticate doesn't make sense with filter implementation
|
Don't need to test this because HttpServletRequest.authenticate doesn't make sense with filter implementation
|
||||||
|
|
||||||
|
|
|
@ -148,12 +148,6 @@ public class Jetty8Test {
|
||||||
testStrategy.testBadUser();
|
testStrategy.testBadUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testVersion() throws Exception {
|
|
||||||
testStrategy.testVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KEYCLOAK-732
|
* KEYCLOAK-732
|
||||||
*
|
*
|
||||||
|
|
|
@ -154,12 +154,6 @@ public class Jetty9Test {
|
||||||
testStrategy.testBadUser();
|
testStrategy.testBadUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testVersion() throws Exception {
|
|
||||||
testStrategy.testVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KEYCLOAK-732
|
* KEYCLOAK-732
|
||||||
*
|
*
|
||||||
|
|
|
@ -154,12 +154,6 @@ public class Jetty9Test {
|
||||||
testStrategy.testBadUser();
|
testStrategy.testBadUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testVersion() throws Exception {
|
|
||||||
testStrategy.testVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KEYCLOAK-732
|
* KEYCLOAK-732
|
||||||
*
|
*
|
||||||
|
|
|
@ -154,12 +154,6 @@ public class Jetty9Test {
|
||||||
testStrategy.testBadUser();
|
testStrategy.testBadUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testVersion() throws Exception {
|
|
||||||
testStrategy.testVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KEYCLOAK-732
|
* KEYCLOAK-732
|
||||||
*
|
*
|
||||||
|
|
|
@ -154,12 +154,6 @@ public class Jetty9Test {
|
||||||
testStrategy.testBadUser();
|
testStrategy.testBadUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testVersion() throws Exception {
|
|
||||||
testStrategy.testVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KEYCLOAK-732
|
* KEYCLOAK-732
|
||||||
*
|
*
|
||||||
|
|
|
@ -138,12 +138,6 @@ public class TomcatTest {
|
||||||
testStrategy.testBadUser();
|
testStrategy.testBadUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testVersion() throws Exception {
|
|
||||||
testStrategy.testVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KEYCLOAK-732
|
* KEYCLOAK-732
|
||||||
*
|
*
|
||||||
|
|
|
@ -144,12 +144,6 @@ public class Tomcat7Test {
|
||||||
testStrategy.testBadUser();
|
testStrategy.testBadUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testVersion() throws Exception {
|
|
||||||
testStrategy.testVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KEYCLOAK-732
|
* KEYCLOAK-732
|
||||||
*
|
*
|
||||||
|
|
|
@ -144,12 +144,6 @@ public class TomcatTest {
|
||||||
testStrategy.testBadUser();
|
testStrategy.testBadUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testVersion() throws Exception {
|
|
||||||
testStrategy.testVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KEYCLOAK-732
|
* KEYCLOAK-732
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue