Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-1366

Warp: support server-side testing of web pages that require authentication

XMLWordPrintable

      When web pages are protected by a security-constraint (web.xml) that requires authentication, Warp JSF runs into a SynchronizationPoint$ServerResponseTimeoutException while executing server-side tests using inspect(), like the second one below. Standard FORM authentication (via j_security_check) and Web Driver's htmlunit browser are used in this case.

      More observations:

      • Client-side tests work just fine (first test below)
      • Disabling the security-constraint (no authentication) allows the server-side test to finish successfully
          @Test
          @RunAsClient
          public void testOnClient() {
              browser.get(deploymentUrl + "index.xhtml");
              doLoginIfNeeded(browser);
              // this works just fine!
              Assert.assertEquals("INDEX", browser.getTitle());
          }
      
          @Test
          @RunAsClient
          public void testOnServer() {
              Warp.initiate(new Activity() {
                  @Override
                  public void perform() {
                      browser.get(deploymentUrl + "index.xhtml");
                      doLoginIfNeeded(browser);
                      // this works just fine!
                      Assert.assertEquals("INDEX", browser.getTitle());
                  }
              })
              .group()
                  .observe(request().uri().contains("index.xhtml"))
                  .inspect(new Inspection() {
                      private static final long serialVersionUID = 1L;
      
                      @ArquillianResource
                      private FacesContext facesContext;
      
                      @AfterPhase(RENDER_RESPONSE)
                      @SuppressWarnings("unused")
                      public void testNavigation() {
                          // timeout exception before we reach this
                          Assert.assertTrue(facesContext.getViewRoot().getViewId().contains("index.xhtml"));
                      }
                  })
              .execute();
          }
      

      Note: doLoginIfNeeded() is just a helper method that enters user name and password and hits the login button if the login form popped-up (in case there's no active session) following the initial browser.get() request in the test.

      Exception:

      org.jboss.arquillian.warp.impl.client.execution.SynchronizationPoint$ServerResponseTimeoutException
                at org.jboss.arquillian.warp.impl.client.execution.SynchronizationPoint.awaitResponses(SynchronizationPoint.java:155)
                at org.jboss.arquillian.warp.impl.client.execution.DefaultExecutionSynchronizer.waitForResponse(DefaultExecutionSynchronizer.java:60)
                at org.jboss.arquillian.warp.impl.client.execution.WarpExecutionObserver.awaitResponse(WarpExecutionObserver.java:64)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
                at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
                at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
                at org.jboss.arquillian.warp.impl.client.execution.DefaultWarpExecutor.awaitServerExecution(DefaultWarpExecutor.java:95)
                at org.jboss.arquillian.warp.impl.client.execution.DefaultWarpExecutor.execute(DefaultWarpExecutor.java:65)
                at org.jboss.arquillian.warp.impl.client.execution.WarpExecutionObserver.executeWarp(WarpExecutionObserver.java:45)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
      

              brevilo_jira Oliver Bock (Inactive)
              brevilo_jira Oliver Bock (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: