Add proxy to download report via Smart Reporting API in Java

When utilizing the ReportiumExportUtils.java file, for example as described for downloading PDF reports in PDF download after test execution and Download Summary PDF Report for a Job in Java, you may need to define a proxy to connect to the Perfecto Smart Reporting API.

To add a proxy to download a report:

  1. In the ReportiumExportUtils.java file, search for the following line:

    Copy
    private static final String PERFECTO_SECURITY_TOKEN = "MY_CONTINUOUS_QUALITY_LAB_SECURITY_TOKEN";
  2. Immediate following the line you found in step 1, add the following lines:

    Copy
    //replace with the actual proxy host and port
    private static final String PROXY_H = "<proxy_host>";
    private static final String PROXY_P = "<proxy_port>";
        
    private static final String PROXY_HOST = System.getProperty("https.proxyHost", PROXY_H);
    private static final String PROXY_PORT = System.getProperty("https.proxyPort", PROXY_P);
  3. Search for the following line:

    Copy
    private static HttpClient httpClient = HttpClientBuilder.create()
  4. Right before the line you find in step 3, add the following lines:

    Copy
    //need to import org.apache.http.HttpHost;
    private static HttpHost proxyHost = new HttpHost(PROXY_HOST, Integer.parseInt(PROXY_PORT));
  5. Search for the following line:

    Copy
    private static HttpClient httpClient = HttpClientBuilder.create()
  6. To the line that you find in step 5, add the following method:

    Copy
    .setProxy(proxyHost)