我正在尝试测试受证书保护的应用程序,因此我有一个过滤器将证书放在我的 servlet 前面的 HTTP 会话中。
这是一个 GWT 应用程序,所以我使用gwt-syncproxy和 Arquillian。
@RunWith(Arquillian.class)
public class TestLiveLoginService {
@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap
.create(WebArchive.class, "launcher.war")
.addPackages(true, "com.mycompany.launcher")
.addAsResource("resources/logback.xml")
.addAsWebInfResource("resources/web.xml")
.merge(ShrinkWrap
.create(ExplodedImporter.class, "resources.war")
.importDirectory("war/launcher")
.as(WebArchive.class));
}
private static LoginService rpcService;
@Before
@RunAsClient
public void initClient() {
rpcService = (LoginService) SyncProxy.newProxyInstance(
LoginService.class, "http://localhost/launcher/", "login");
}
@Test
@RunAsClient
public void testLogin1() throws ServerException {
User result = rpcService.login(new User.Builder(
"user", "password").build());
assertTrue((result != null));
}
}
我的测试testLogin1()
失败了,因为服务器代码正在寻找将在正常登录流程中的会话中的证书。
是否可以在 Arquillian 测试中更新 HTTP 会话?在这种情况下,我可以轻松地在我的initClient()
方法中在会话中添加模拟证书。