public class SecurityTest extends Object
| Modifier and Type | Field and Description |
|---|---|
protected org.eclipse.jetty.server.Server |
applicationServer |
protected ApplicationServerOptions |
applicationServerOptions |
protected List<org.eclipse.jetty.servlet.FilterHolder> |
applicationServletFilters |
protected Map<String,org.eclipse.jetty.servlet.ServletHolder> |
applicationServletsByPath |
protected String |
clientId |
static String |
DEFAULT_APP_ID |
static String |
DEFAULT_CLIENT_ID |
static String |
DEFAULT_DOMAIN |
protected String |
jwksUrl |
protected RSAKeys |
keys |
protected static String |
LOCALHOST_PATTERN |
protected static org.slf4j.Logger |
LOGGER |
protected Service |
service |
protected boolean |
useApplicationServer |
protected com.github.tomakehurst.wiremock.WireMockServer |
wireMockServer |
| Constructor and Description |
|---|
SecurityTest(Service service) |
| Modifier and Type | Method and Description |
|---|---|
SecurityTest |
addApplicationServlet(Class<? extends javax.servlet.Servlet> servletClass,
String path)
Adds a servlet to the servlet server.
|
SecurityTest |
addApplicationServlet(org.eclipse.jetty.servlet.ServletHolder servletHolder,
String path)
Adds a servlet to the servlet server.
|
SecurityTest |
addApplicationServletFilter(Class<? extends javax.servlet.Filter> filterClass)
Adds a filter to the servlet server.
|
Token |
createToken()
Creates a very basic token on base of the preconfigured Jwt token generator.
|
String |
getApplicationServerUri()
Returns the URI of the embedded jetty server or null if not specified.
|
JwtGenerator |
getPreconfiguredJwtGenerator()
Note: the JwtGenerator is fully configured as part of
setup()
method. |
com.github.tomakehurst.wiremock.WireMockServer |
getWireMockServer()
Allows to stub further endpoints of the identity service.
|
SecurityTest |
setKeys(String publicKeyPath,
String privateKeyPath)
Overwrites the private/public key pair to be used.
|
SecurityTest |
setPort(int port)
Overwrites the port on which the identity service mock server runs
(WireMock).
|
void |
setup()
Starts the Jetty application web server and the WireMock OAuthServer if not
running.
|
void |
tearDown()
Shuts down Jetty application web server and WireMock stub.
|
SecurityTest |
useApplicationServer()
Specifies an embedded jetty as servlet server.
|
SecurityTest |
useApplicationServer(ApplicationServerOptions applicationServerOptions)
Specifies an embedded jetty as servlet server.
|
protected static final org.slf4j.Logger LOGGER
public static final String DEFAULT_APP_ID
public static final String DEFAULT_CLIENT_ID
public static final String DEFAULT_DOMAIN
protected static final String LOCALHOST_PATTERN
protected final Map<String,org.eclipse.jetty.servlet.ServletHolder> applicationServletsByPath
protected final List<org.eclipse.jetty.servlet.FilterHolder> applicationServletFilters
protected org.eclipse.jetty.server.Server applicationServer
protected ApplicationServerOptions applicationServerOptions
protected boolean useApplicationServer
protected com.github.tomakehurst.wiremock.WireMockServer wireMockServer
protected RSAKeys keys
protected Service service
protected String clientId
protected String jwksUrl
public SecurityTest(Service service)
public SecurityTest useApplicationServer()
setup() method. The application server will be started
with default options for the given Service, see
ApplicationServerOptions.forService(Service) for details. By default
the servlet server will listen on a free random port. Use
SecurityTestRule.useApplicationServer(ApplicationServerOptions) to
overwrite default settings. Use getApplicationServerUri() to obtain
the actual port used at runtime.public SecurityTest useApplicationServer(ApplicationServerOptions applicationServerOptions)
setup() method. Use
ApplicationServerOptions.forService(Service) to obtain a
configuration object that can be customized. See
ApplicationServerOptions for details.applicationServerOptions - custom options to configure the application server.public SecurityTest addApplicationServlet(Class<? extends javax.servlet.Servlet> servletClass, String path)
useApplicationServer.servletClass - the servlet class that should be served.path - the path on which the servlet should be served, e.g. "/*".public SecurityTest addApplicationServlet(org.eclipse.jetty.servlet.ServletHolder servletHolder, String path)
useApplicationServer.servletHolder - the servlet inside a ServletHolder that should be served.path - the path on which the servlet should be served, e.g. "/*".public SecurityTest addApplicationServletFilter(Class<? extends javax.servlet.Filter> filterClass)
useApplicationServer.filterClass - the filter class that should intercept with incoming requests.public SecurityTest setPort(int port)
setup() method. If
the port is not specified or is set to 0, a free random port is chosen.port - the port on which the wire mock service is started.public SecurityTest setKeys(String publicKeyPath, String privateKeyPath)
publicKeyPath - resource path to public key file.privateKeyPath - resource path to private key file.public JwtGenerator getPreconfiguredJwtGenerator()
setup()
method.public Token createToken()
getPreconfiguredJwtGenerator()public com.github.tomakehurst.wiremock.WireMockServer getWireMockServer()
setup() method. You can
find a detailed explanation on how to configure wire mock here:
http://wiremock.org/docs/getting-started/@Nullable public String getApplicationServerUri()
public void setup()
throws Exception
IOException - if the stub cannot be initializedExceptionpublic void tearDown()
Copyright © 2020. All rights reserved.