dataloader icon indicating copy to clipboard operation
dataloader copied to clipboard

Add OAuth PKCE Selenium test automation with test seam pattern

Open amers185 opened this issue 4 months ago • 0 comments

This PR adds automated testing for OAuth PKCE flow using Selenium WebDriver, eliminating the need for manual browser interaction during testing.

🔧 Implementation

Test Seam Pattern

  • UrlOpener interface for abstraction
  • SeleniumUrlOpener for test browser control
  • URLUtil modified with test hook for Selenium integration

📁 Files Added/Modified

New Files:

  • src/main/java/com/salesforce/dataloader/ui/UrlOpener.java - Interface for test seam pattern
  • src/test/java/com/salesforce/dataloader/ui/SeleniumUrlOpener.java - Test implementation for Selenium
  • src/test/java/com/salesforce/dataloader/oauth/OAuthTestSeamSeleniumTest.java - Main automated test

Modified Files:

  • src/main/java/com/salesforce/dataloader/ui/URLUtil.java - Added test hook for Selenium integration

🔍 Technical Details

Uses the test seam pattern to inject Selenium control into the OAuth flow without modifying core business logic. When URLUtil.openURL() is called during tests, the test hook redirects to Selenium WebDriver instead of the system browser.

This approach solves the "Two Browser Problem" where DataLoader opens the system browser but tests need to control a Selenium browser.

🏗️ Architecture

The implementation keeps production logic embedded in URLUtil while providing a clean test hook:

  • Production: Uses existing URLUtil.openURL() with embedded browser opening logic
  • Testing: Test hook intercepts calls and redirects to SeleniumUrlOpener
  • Interface: UrlOpener provides abstraction for different implementations

amers185 avatar Aug 25 '25 21:08 amers185