diff options
| author | Keith Wall <kwall@apache.org> | 2012-09-06 15:22:04 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2012-09-06 15:22:04 +0000 |
| commit | b081663c3b7c2f6394d2a432188541c078576556 (patch) | |
| tree | a4e2ac89e64e11151aa4e116bf42f7b60eb75f16 /qpid/java/broker-plugins/management-http/src/test | |
| parent | 09feae6b99eb09648ed6849e62705438931296e6 (diff) | |
| download | qpid-python-b081663c3b7c2f6394d2a432188541c078576556.tar.gz | |
QPID-4255: Add "log out" functionality to web UI
* Added logout link to the Web Management UI (displayed once a user is logged in).
* Added operation logging (open/close event) to report the fact that the user
has logged in, logged out (or gone away i.e. web session timeout).
* Allow Jetty web session timeout to be overridden from the config.xml
Work of Robbie Gemmell <robbie@apache.org> and myself.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1381637 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/management-http/src/test')
| -rw-r--r-- | qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporterTest.java | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporterTest.java b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporterTest.java new file mode 100644 index 0000000000..1d43c44587 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporterTest.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.qpid.server.management.plugin.session; + +import static org.mockito.Mockito.verify; +import static org.mockito.Matchers.argThat; + +import javax.security.auth.Subject; + +import org.apache.qpid.server.logging.LogActor; +import org.apache.qpid.server.logging.LogMessage; +import org.apache.qpid.server.security.auth.AuthenticatedPrincipal; +import org.mockito.ArgumentMatcher; +import org.mockito.Mockito; + +import junit.framework.TestCase; + +public class LoginLogoutReporterTest extends TestCase +{ + private LoginLogoutReporter _loginLogoutReport; + private Subject _subject = new Subject(); + private LogActor _logActor = Mockito.mock(LogActor.class); + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + _subject.getPrincipals().add(new AuthenticatedPrincipal("mockusername")); + _loginLogoutReport = new LoginLogoutReporter(_logActor, _subject); + } + + public void testLoginLogged() + { + _loginLogoutReport.valueBound(null); + verify(_logActor).message(isLogMessageWithMessage("MNG-1007 : Open : User mockusername")); + } + + public void testLogoutLogged() + { + _loginLogoutReport.valueUnbound(null); + verify(_logActor).message(isLogMessageWithMessage("MNG-1008 : Close : User mockusername")); + } + + private LogMessage isLogMessageWithMessage(final String expectedMessage) + { + return argThat( new ArgumentMatcher<LogMessage>() + { + @Override + public boolean matches(Object argument) + { + LogMessage actual = (LogMessage) argument; + return actual.toString().equals(expectedMessage); + } + }); + } +} |
