KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > atlassian > seraph > config > _TestSecurityConfig


1 package com.atlassian.seraph.config;
2
3 import junit.framework.TestCase;
4 import com.atlassian.seraph.auth.DefaultAuthenticator;
5 import com.atlassian.seraph.auth.GroupRoleMapper;
6 import com.atlassian.seraph.service.PathService;
7 import com.atlassian.seraph.controller.NullSecurityController;
8 import com.atlassian.seraph.interceptor.LoginInterceptor;
9 import com.atlassian.seraph.interceptor.LogoutInterceptor;
10 import mock.MockLoginInterceptor;
11
12 // DISABLED temporarily, since this test fails depending on which order the
13
// test is run in:
14

15 // [junit] Will fork only once
16
// [junit] Running mutiple tests
17
// [junit] Running com.atlassian.seraph.logout.TestLogoutServlet
18
// [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 1.009 sec
19
// [junit] Running com.atlassian.seraph.util.TestRedirectUtils
20
// [junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.037 sec
21
// [junit] Running com.atlassian.seraph.util.TestCookieUtils
22
// [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.108 sec
23
// [junit] Running com.atlassian.seraph.auth.TestDefaultAuthenticator
24
// [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.324 sec
25
// [junit] Running com.atlassian.seraph.controller.TestNullSecurityController
26
// [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.013 sec
27
// [junit] Running com.atlassian.seraph.config.TestSecurityConfig
28
// [junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.079 sec
29
// [junit] TEST com.atlassian.seraph.config.TestSecurityConfig FAILED
30

31 public class _TestSecurityConfig extends TestCase
32 {
33     public void testSecurityConfig() throws ConfigurationException
34     {
35         SecurityConfig config = SecurityConfigFactory.getInstance("test-seraph-config.xml");
36         assertTrue(config.getAuthenticator() instanceof DefaultAuthenticator);
37         assertTrue(config.getRoleMapper() instanceof GroupRoleMapper);
38         assertTrue(config.getController() instanceof NullSecurityController);
39         assertEquals(1, config.getServices().size());
40         assertTrue(config.getServices().get(0) instanceof PathService);
41
42         assertEquals("xYz", config.getCookieEncoding());
43         assertEquals("/login.action", config.getLoginURL());
44         assertEquals("test_security_originalurl", config.getOriginalURLKey());
45         assertEquals(0, config.getInterceptors(LogoutInterceptor.class).size());
46         assertEquals(1, config.getInterceptors(LoginInterceptor.class).size());
47         assertTrue(config.getInterceptors(LoginInterceptor.class).get(0) instanceof MockLoginInterceptor);
48     }
49 }
50
Popular Tags