ServletRegistrationComponent implements RestServicesMBean { public void setAuthenticationRealm( String authenticationRealm ) { this.logger.fine( "New authentication realm: " + authenticationRealm ); this.authenticationMngr = new AuthenticationManager( authenticationRealm ); if( this.authenticationFilter != null ) this.authenticationFilter.setAuthenticationManager( this.authenticationMngr ); if( this.app != null ) this.app.setAuthenticationManager( this.authenticationMngr ); } ServletRegistrationComponent( BundleContext bundleContext ); void starting(); void stopping(); void schedulerAppears(); void schedulerDisappears(); void mavenResolverAppears(); void mavenResolverDisappears(); void setHttpService( HttpService httpService ); void setManager( Manager manager ); void setEnableCors( boolean enableCors ); void setEnableAuthentication( boolean enableAuthentication ); void setAuthenticationRealm( String authenticationRealm ); void setSessionPeriod( long sessionPeriod ); void setScheduler( IScheduler scheduler ); void setMavenResolver( MavenResolver mavenResolver ); @Override int getCurrentWebSocketClientsCount(); @Override long getWebSocketConnectionErrorsCount(); @Override long getRestRequestsWithAuthFailureCount(); @Override long getRestRequestsCount(); @Override boolean isAuthenticationRequired(); @Override boolean isCorsEnabled(); @Override void reset(); static final String REST_CONTEXT; static final String WEBSOCKET_CONTEXT; final AtomicLong restRequestsCount; final AtomicLong restRequestsWithAuthFailureCount; static final AtomicLong WS_CONNECTION_ERRORS_COUNT; }
@Test public void testSetAuthenticationRealm() throws Exception { Assert.assertNull( this.register.authenticationMngr ); this.register.setAuthenticationRealm( "realm" ); Assert.assertNotNull( this.register.authenticationMngr ); this.register.authenticationFilter = Mockito.mock( AuthenticationFilter.class ); this.register.setAuthenticationRealm( "realm2" ); Mockito.verify( this.register.authenticationFilter, Mockito.only()).setAuthenticationManager( Mockito.any( AuthenticationManager.class )); this.register.stopping(); this.register.setAuthenticationRealm( "realm" ); }