a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington * The contents of this file are subject to the terms of the Common Development and
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington * Distribution License (the License). You may not use this file except in compliance with the
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington * specific language governing permission and limitations under the License.
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington * When distributing Covered Software, include this CDDL Header Notice in each file and include
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington * Header, with the fields enclosed by brackets [] replaced by your own identifying
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington * information: "Portions copyright [year] [name of copyright owner]".
412e1e94939e06eaec3523eafe3e1130349f9486Tom Rumsey * Copyright 2015-2016 ForgeRock AS.
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport static com.google.inject.multibindings.MapBinder.newMapBinder;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport static org.assertj.core.api.Assertions.assertThat;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport static org.forgerock.http.routing.RoutingMode.EQUALS;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport static org.forgerock.http.routing.RoutingMode.STARTS_WITH;
9edb7d0c3f707c96c3ee9a9bbe327ea9ffeafcefPeter Majorimport static org.forgerock.json.JsonValue.field;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport static org.forgerock.json.JsonValue.object;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport static org.forgerock.json.resource.Responses.newResourceResponse;
dfa51161ad226f5998270e3becb25817774aa168Tony Bamfordimport static org.forgerock.openam.audit.AuditConstants.EventName;
7483f02ef17d2c2051a288b7bcbe4f27f2af9fbbJaco Joosteimport static org.forgerock.openam.audit.AuditConstants.ACCESS_TOPIC;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport static org.forgerock.openam.audit.AuditConstants.Component.AUTHENTICATION;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport static org.forgerock.openam.audit.AuditConstants.Component.CONFIG;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport static org.forgerock.openam.audit.AuditConstants.Component.USERS;
7e863fbb4994becee1defd0839fdd67b33b19342Jaco Joosteimport static org.forgerock.openam.audit.AuditConstants.NO_REALM;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport static org.forgerock.openam.rest.Routers.ssoToken;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport static org.forgerock.util.promise.Promises.newResultPromise;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport static org.mockito.Mockito.verifyZeroInteractions;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport com.google.inject.multibindings.MapBinder;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport com.sun.identity.idm.IdRepoException;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.guice.core.GuiceModuleLoader;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.guice.core.GuiceModules;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.guice.core.GuiceTestCase;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.guice.core.InjectorConfiguration;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.guice.core.InjectorHolder;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.http.protocol.Response;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.http.routing.ResourceApiVersionBehaviourManager;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport org.forgerock.http.session.SessionContext;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.json.resource.CollectionResourceProvider;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.json.resource.ReadRequest;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport org.forgerock.json.resource.ResourceException;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport org.forgerock.json.resource.ResourceResponse;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.json.resource.SingletonResourceProvider;
9edb7d0c3f707c96c3ee9a9bbe327ea9ffeafcefPeter Majorimport org.forgerock.json.resource.http.HttpContext;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.openam.audit.AbstractHttpAccessAuditFilter;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.openam.audit.AuditConstants;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.openam.audit.AuditEventFactory;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.openam.audit.AuditEventPublisher;
890c120a8dac4ce3f54f804a6776769f5ba3980cJaco Joosteimport org.forgerock.openam.audit.AuditServiceProvider;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.openam.authentication.service.AuthUtilsWrapper;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.openam.core.CoreWrapper;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.openam.http.HttpGuiceModule;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.openam.http.annotations.Get;
ae38b3b0c7668321cd32405f4ad510601d6f1276James Phillpottsimport org.forgerock.openam.rest.resource.SSOTokenContext;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonimport org.forgerock.openam.rest.router.RestRealmValidator;
ae38b3b0c7668321cd32405f4ad510601d6f1276James Phillpottsimport org.forgerock.openam.session.SessionCache;
ae38b3b0c7668321cd32405f4ad510601d6f1276James Phillpottsimport org.forgerock.openam.session.SessionConstants;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport org.forgerock.services.context.AttributesContext;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport org.forgerock.services.context.RequestAuditContext;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport org.forgerock.services.context.RootContext;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport org.forgerock.services.context.SecurityContext;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Joosteimport org.forgerock.util.promise.NeverThrowsException;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington@GuiceModules({HttpGuiceModule.class, RestGuiceModule.class})
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunningtonpublic class RestRouterIT extends GuiceTestCase {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private SingletonResourceProvider configResource;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private CollectionResourceProvider usersResource;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste private CollectionResourceProvider internalResource;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private DashboardResource dashboardResource;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private AuthenticateResource authenticateResource;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private AbstractHttpAccessAuditFilter httpAccessAuditFilter;
7483f02ef17d2c2051a288b7bcbe4f27f2af9fbbJaco Jooste private AuditEventPublisher auditEventPublisher;
890c120a8dac4ce3f54f804a6776769f5ba3980cJaco Jooste private AuditServiceProvider auditServiceProvider;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private ResourceApiVersionBehaviourManager versionBehaviourManager;
5af486b23de789a6978e855f20235758122bd2abAndrew Forrest private PrivilegedAction<SSOToken> ssoTokenAction;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington configResource = mock(SingletonResourceProvider.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington usersResource = mock(CollectionResourceProvider.class);
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste internalResource = mock(CollectionResourceProvider.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington dashboardResource = spy(new DashboardResource());
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington authenticateResource = spy(new AuthenticateResource());
7483f02ef17d2c2051a288b7bcbe4f27f2af9fbbJaco Jooste httpAccessAuditFilter = spy(new AbstractHttpAccessAuditFilter(AUTHENTICATION, mock(AuditEventPublisher.class)
7483f02ef17d2c2051a288b7bcbe4f27f2af9fbbJaco Jooste auditEventPublisher = mock(AuditEventPublisher.class);
890c120a8dac4ce3f54f804a6776769f5ba3980cJaco Jooste auditServiceProvider = mock(AuditServiceProvider.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington versionBehaviourManager = mock(ResourceApiVersionBehaviourManager.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington ssoTokenManager = mock(SSOTokenManager.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington authUtilsWrapper = mock(AuthUtilsWrapper.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington SSOToken adminToken = mock(SSOToken.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington given(coreWrapper.getAdminToken()).willReturn(adminToken);
412e1e94939e06eaec3523eafe3e1130349f9486Tom Rumsey given(coreWrapper.isValidFQDN(anyString())).willReturn(true);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington realmValidator = mock(RestRealmValidator.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington @BeforeMethod(dependsOnMethods = "setupMocks")
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public void setupGuiceModules() throws Exception {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington InjectorConfiguration.setGuiceModuleLoader(new GuiceModuleLoader() {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public Set<Class<? extends Module>> getGuiceModules(Class<? extends Annotation> clazz) {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington return new HashSet<>();
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington MapBinder<AuditConstants.Component, AbstractHttpAccessAuditFilter> httpAccessAuditFilterMapBinder
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington = newMapBinder(binder, AuditConstants.Component.class, AbstractHttpAccessAuditFilter.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington httpAccessAuditFilterMapBinder.addBinding(AUTHENTICATION).toInstance(httpAccessAuditFilter);
7483f02ef17d2c2051a288b7bcbe4f27f2af9fbbJaco Jooste binder.bind(AuditEventPublisher.class).toInstance(auditEventPublisher);
890c120a8dac4ce3f54f804a6776769f5ba3980cJaco Jooste binder.bind(AuditServiceProvider.class).toInstance(auditServiceProvider);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington binder.bind(Key.get(SingletonResourceProvider.class, Names.named("ConfigResource"))).toInstance(configResource);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington binder.bind(Key.get(CollectionResourceProvider.class, Names.named("UsersResource"))).toInstance(usersResource);
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste binder.bind(Key.get(CollectionResourceProvider.class, Names.named("InternalResource"))).toInstance(internalResource);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington binder.bind(Key.get(Object.class, Names.named("DashboardResource"))).toInstance(dashboardResource);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington binder.bind(Key.get(Object.class, Names.named("AuthenticateResource"))).toInstance(authenticateResource);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington binder.bind(SSOTokenManager.class).toInstance(ssoTokenManager);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington binder.bind(AuthUtilsWrapper.class).toInstance(authUtilsWrapper);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington binder.bind(CoreWrapper.class).toInstance(coreWrapper);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington binder.bind(RestRealmValidator.class).toInstance(realmValidator);
5af486b23de789a6978e855f20235758122bd2abAndrew Forrest binder.bind(new TypeLiteral<PrivilegedAction<SSOToken>>() {}).toInstance(ssoTokenAction);
ae38b3b0c7668321cd32405f4ad510601d6f1276James Phillpotts binder.bind(SessionCache.class).toInstance(mock(SessionCache.class));
ae38b3b0c7668321cd32405f4ad510601d6f1276James Phillpotts binder.bind(Debug.class).annotatedWith(Names.named(SessionConstants.SESSION_DEBUG))
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public void configureOverrideBindings(Binder binder) {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington binder.bind(ResourceApiVersionBehaviourManager.class).toInstance(versionBehaviourManager);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington @BeforeMethod(dependsOnMethods = "setupGuiceModules")
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington handler = InjectorHolder.getInstance(HttpApplication.class).start();
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington doThrow(IdRepoException.class).when(coreWrapper).getOrganization(any(SSOToken.class), eq("users"));
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington doThrow(IdRepoException.class).when(coreWrapper).getOrganization(any(SSOToken.class), eq("authenticate"));
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste doThrow(IdRepoException.class).when(coreWrapper).getOrganization(any(SSOToken.class), eq("internal"));
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public void shouldReadCrestEndpointOnRootHandler() throws Exception {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington Request request = newRequest("GET", "/json/config");
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington verify(configResource).readInstance(any(Context.class), any(ReadRequest.class));
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public void shouldReadChfEndpointOnRootHandler() throws Exception {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington Request request = newRequest("GET", "/json/dashboard");
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public void shouldReadCrestEndpointOnRealmHandlerWithRootRealm() throws Exception {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington Request request = newRequest("GET", "/json/users/demo");
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington verify(usersResource).readInstance(contextCaptor.capture(), eq("demo"), any(ReadRequest.class));
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington assertThat(contextCaptor.getValue().asContext(RealmContext.class).getResolvedRealm()).isEqualTo("/");
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public void shouldReadCrestEndpointOnRealmHandlerWithSubRealm() throws Exception {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington Request request = newRequest("GET", "/json/subrealm/users/demo");
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington verify(usersResource).readInstance(contextCaptor.capture(), eq("demo"), any(ReadRequest.class));
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington assertThat(contextCaptor.getValue().asContext(RealmContext.class).getResolvedRealm()).isEqualTo("/subrealm");
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public void shouldReadChfEndpointOnRealmHandlerWithRootRealm() throws Exception {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington Request request = newRequest("GET", "/json/authenticate");
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public void shouldReadChfEndpointOnRealmHandlerWithSubRealm() throws Exception {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington Request request = newRequest("GET", "/json/subrealm/authenticate");
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste public void shouldNotBePossibleToReachInternalResourceViaChf() throws Exception {
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste Request request = newRequest("GET", "/json/internal");
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste Promise<Response, NeverThrowsException> promise = handler.handle(context, request);
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste assertThat(response.getStatus()).isEqualTo(Status.NOT_FOUND);
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste public void shouldBeAbleToReachInternalViaInternalRouter() throws Exception {
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste Promise<ResourceResponse, ResourceException> promise =
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste newResultPromise(newResourceResponse("1", "1", json(object())));
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste given(internalResource.readInstance(any(Context.class), eq("123"), any(ReadRequest.class))).willReturn(promise);
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste Router internalRouter = InjectorHolder.getInstance(Key.get(Router.class, Names.named("InternalCrestRouter")));
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste ReadRequest request = Requests.newReadRequest("internal/123");
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste verify(internalResource).readInstance(any(Context.class), eq("123"), any(ReadRequest.class));
9edb7d0c3f707c96c3ee9a9bbe327ea9ffeafcefPeter Major AttributesContext httpRequestContext = new AttributesContext(new SessionContext(parent, mock(Session.class)));
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington httpRequestContext.getAttributes().put(HttpServletRequest.class.getName(), httpServletRequest);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington return new RequestAuditContext(httpRequestContext);
9edb7d0c3f707c96c3ee9a9bbe327ea9ffeafcefPeter Major final HttpContext httpContext = new HttpContext(json(object(
9edb7d0c3f707c96c3ee9a9bbe327ea9ffeafcefPeter Major field(HttpContext.ATTR_HEADERS, Collections.singletonMap("Accept-Language", Arrays.asList("en"))),
9edb7d0c3f707c96c3ee9a9bbe327ea9ffeafcefPeter Major field(HttpContext.ATTR_PARAMETERS, Collections.emptyMap()))), null);
ae38b3b0c7668321cd32405f4ad510601d6f1276James Phillpotts SecurityContext securityContext = new SecurityContext(mockContext(httpContext), null, null);
ae38b3b0c7668321cd32405f4ad510601d6f1276James Phillpotts return new SSOTokenContext(mock(Debug.class), null, securityContext) {
ae38b3b0c7668321cd32405f4ad510601d6f1276James Phillpotts given(token.getProperty(Constants.AM_CTX_ID)).willReturn("TRACKING_ID");
ae38b3b0c7668321cd32405f4ad510601d6f1276James Phillpotts given(token.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("USER_ID");
ae38b3b0c7668321cd32405f4ad510601d6f1276James Phillpotts // won't happen - it's a mock
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private Request newRequest(String method, String uri) throws URISyntaxException {
dfa51161ad226f5998270e3becb25817774aa168Tony Bamford given(auditEventPublisher.isAuditing(eq(NO_REALM), eq(ACCESS_TOPIC), any(EventName.class))).willReturn(false);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private void mockDnsAlias(String alias, String realm) throws Exception {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private void mockRealm(String realm) throws Exception {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington given(coreWrapper.getOrganization(any(SSOToken.class), eq(realm))).willReturn(realm);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington given(coreWrapper.convertOrgNameToRealmName(realm)).willReturn(realm);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington given(realmValidator.isRealm(realm)).willReturn(true);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private void mockRealmAlias(String alias, String realm) throws Exception {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington given(coreWrapper.getOrganization(any(SSOToken.class), eq(alias))).willReturn(realm);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington given(coreWrapper.convertOrgNameToRealmName(realm)).willReturn(realm);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington given(realmValidator.isRealm(realm)).willReturn(true);
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public static final class RestRouteTestRestRouteProvider extends AbstractRestRouteProvider {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private SingletonResourceProvider configResource;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington private CollectionResourceProvider usersResource;
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste private CollectionResourceProvider internalResource;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public void addResourceRoutes(ResourceRouter rootRouter, ResourceRouter realmRouter) {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington public void addServiceRoutes(ServiceRouter rootRouter, ServiceRouter realmRouter) {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington .toService(STARTS_WITH, dashboardResource);
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste public void addInternalRoutes(ResourceRouter internalRouter) {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington void setConfigResource(@Named("ConfigResource") SingletonResourceProvider configResource) {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington void setUsersResource(@Named("UsersResource") CollectionResourceProvider usersResource) {
ea968a2519a7cf9282263e27b81ad7eb6706ef3aJaco Jooste void setInternalResource(@Named("InternalResource") CollectionResourceProvider internalResource) {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington void setDashboardResource(@Named("DashboardResource") Object dashboardResource) {
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington this.dashboardResource = dashboardResource;
a6fc9ae6bd096a653649fdf8e4189f102dd4cdf2Phill Cunnington void setAuthenticateResource(@Named("AuthenticateResource") Object authenticateResource) {