Skip to content

Conversation

@amers185
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant