public class SecurityTestRule
extends org.junit.rules.ExternalResource
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_APP_ID |
static String |
DEFAULT_CLIENT_ID |
static String |
DEFAULT_DOMAIN |
| Modifier and Type | Method and Description |
|---|---|
SecurityTestRule |
addApplicationServlet(Class<? extends javax.servlet.Servlet> servletClass,
String path)
Adds a servlet to the servlet server.
|
SecurityTestRule |
addApplicationServlet(org.eclipse.jetty.servlet.ServletHolder servletHolder,
String path)
Adds a servlet to the servlet server.
|
SecurityTestRule |
addApplicationServletFilter(Class<? extends javax.servlet.Filter> filterClass)
Adds a filter to the servlet server.
|
protected void |
after() |
protected void |
before() |
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.
|
static SecurityTestRule |
getInstance(Service service)
Creates an instance of the test rule for the given service.
|
JwtGenerator |
getPreconfiguredJwtGenerator()
Note: the JwtGenerator is fully configured as part of
before()
method. |
com.github.tomakehurst.wiremock.junit.WireMockRule |
getWireMockRule()
Allows to stub further endpoints of the identity service.
|
SecurityTestRule |
setKeys(String publicKeyPath,
String privateKeyPath)
Overwrites the private/public key pair to be used.
|
SecurityTestRule |
setPort(int port)
Overwrites the port on which the identity service mock server runs
(WireMock).
|
SecurityTestRule |
useApplicationServer()
Specifies an embedded jetty as servlet server.
|
SecurityTestRule |
useApplicationServer(ApplicationServerOptions applicationServerOptions)
Specifies an embedded jetty as servlet server.
|
public static final String DEFAULT_APP_ID
public static final String DEFAULT_CLIENT_ID
public static final String DEFAULT_DOMAIN
public static SecurityTestRule getInstance(Service service)
service - the service for which the test rule should be created.public SecurityTestRule useApplicationServer()
before() 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
useApplicationServer(ApplicationServerOptions) to
overwrite default settings. Use getApplicationServerUri() to obtain
the actual port used at runtime.public SecurityTestRule useApplicationServer(ApplicationServerOptions applicationServerOptions)
before() 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 SecurityTestRule 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 SecurityTestRule 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 SecurityTestRule addApplicationServletFilter(Class<? extends javax.servlet.Filter> filterClass)
useApplicationServer.filterClass - the filter class that should intercept with incoming requests.public SecurityTestRule setPort(int port)
before() 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 SecurityTestRule setKeys(String publicKeyPath, String privateKeyPath)
publicKeyPath - resource path to public key file.privateKeyPath - resource path to private key file.protected void before()
throws Exception
before in class org.junit.rules.ExternalResourceExceptionpublic JwtGenerator getPreconfiguredJwtGenerator()
before()
method.public Token createToken()
getPreconfiguredJwtGenerator()@Nullable public com.github.tomakehurst.wiremock.junit.WireMockRule getWireMockRule()
before() method. You can find
a detailed explanation on how to configure wire mock here:
http://wiremock.org/docs/getting-started/@Nullable public String getApplicationServerUri()
protected void after()
after in class org.junit.rules.ExternalResourceCopyright © 2020. All rights reserved.