3 Replies Latest reply on Dec 6, 2017 1:13 PM by gbuckholtz

    Drone with http header/proxy settings (e.g. BrowserMobProxy)?

    michaelb80

      Is there a way to pass a header/proxy configuration in Drone?

       

      We have the following use case for our integration tests:

      • There are several JSF/RF-based applications that are integrated in a Single-Sign-On (SSO) environment.
      • An application can only be executed in an authenticated context.
      • SSO-Integration is performed in a trusted environment by setting a specific http-header which identifies the user to be authenticated against the local data base of the JSF application.
      • We need to pass the http-Header to every request in our tests

       

      Can it be done? how?

       

      We found out that the selenium guys won't provide the possibility of setting http headers, although a lot of people on the net requested that functionality for similar use cases as ours.

      The workaround of choice is to use an integrated proxy (BrowserMobProxy) which can handle setting the request header.

       

      Using BrowserMobProxy the solution just requires a few lines of extra code in the tests:

       

      private static final int PROXY_PORT = 50000;
      
      private static BrowserMobProxy proxy;
      
      private static DesiredCapabilities webDriverCapabilities;
      
      @BeforeClass    
      public static void startProxy() {
           proxy = new BrowserMobProxyServer( PROXY_PORT );
           proxy.start();
      
           Proxy seleniumProxy = ClientUtil.createSeleniumProxy( proxy );
           webDriverCapabilities = new DesiredCapabilities();
           webDriverCapabilities.setCapability( CapabilityType.PROXY, seleniumProxy );
      }
      
      @Before
      public void loadPage() {
           proxy.addHeader( "xxx", "yyy" );
           // ...
      }
      
      @AfterClass
      public static void stopProxy() {
           proxy.abort();
           proxy = null;
      }
      
      

       

      That works if you create a WebDriver yourself:

       

      new FirefoxDriver( webDriverCapabilities )
      

       

      So how can a similar configuration be achieved using drone and a configuration in arquillian.xml?

      (Simply setting "proxyHost" and "proxyPort" in the "webdriver" extension the same way as in the "selenium-server" extension of course is not enough)

        • 1. Re: Drone with http header/proxy settings (e.g. BrowserMobProxy)?
          bmajsak

          Hi Michael,

           

          that's really neat functionality. I might also need that in my current projects (similar setup), so I started hacking an extension for Drone. Give me a bit more time I will come up with some foundation to move forward and maybe we can work on it together?

           

          Cheers,

          Bartosz

          • 2. Re: Drone with http header/proxy settings (e.g. BrowserMobProxy)?
            michaelb80

            Hi Bartosz,

             

            sounds really interesting!

             

            I don't know if I could be of much help (due to both limited time and knowledge of Arquillian/Drone/Graphene etc.), but if there's something I can help with, I'll be glad to do it.

             

            Also I'm currently trying to create a test environment for JSF/RF components/applications at our company, which gives us some advanced features for integration tests. One of them is the use of headers etc. as described.

             

            Another one would be an integration of Arquillian/Drone/Graphene with Serenity (Thucydides), since I really like the html reporting feature with screenshots etc. and I think customers would highly appreciate that as well.

            I've been looking around the blogs and found out, that there was some joint effort in 2012 for trying to integrate arquillian/thucydides, but it doesn't seem that this was pursued any further.

             

            It would be really great, to have the ability to use the existing page fragments that are used to drive RF component tests in arquillian/drone/graphene together with the reporting features of serinity/thucydides. That way one could easily implement acceptance tests for a RF-based application and report the results.

             

            Maybe that's also s.th. worth picking up - what do you think?

             

            Cheers,

            Michael

            • 3. Re: Drone with http header/proxy settings (e.g. BrowserMobProxy)?
              gbuckholtz

              Did you come up with a solution for injecting request headers?

               

              I am in the same SSO boat.  I use Header Request values that our SSO (shib) has provided for name, email, etc.  I am currently skipping the @Drone injectection and creating my own WebDriver.