Skip to content

Fix failing CI tests: GitClient allowlist stubs, integration test timeout properties, stable Selenium selectors - #663

Merged
conorheffron merged 19 commits into
mainfrom
copilot/fix-github-actions-failures
May 17, 2026
Merged

Fix failing CI tests: GitClient allowlist stubs, integration test timeout properties, stable Selenium selectors#663
conorheffron merged 19 commits into
mainfrom
copilot/fix-github-actions-failures

Conversation

Copilot AI commented May 16, 2026

Copy link
Copy Markdown
Contributor

The GitClient RestTemplate refactoring introduced URL allowlist validation that broke unit tests, caused Spring context failures in integration tests, and the Selenium browser test was using a fragile linkText locator.

GitClientTest — missing allowlist stubs

getValidatedApiUri() calls propertyConfig.getGitApiEndpointIssues() and urlUtils.isValidURL(allowlistUrl) before invoking restTemplate.exchange(). Neither was stubbed, so the method returned early — causing exchange() to never be called in the success test and flagged as UnnecessaryStubbingException in the blank-body test.

when(urlUtilsMock.isValidURL("https://unittest.github.com")).thenReturn(true);
when(propertyConfigMock.getGitApiEndpointIssues()).thenReturn("https://unittest.github.com");

Added to both test_callGitHubApi_success_with_token and test_callGitHubApi_blank_response_body_fail.

BaseControllerIntegrationTest — missing timeout properties

The new GitClient constructor calls propertyConfig.getGitTimeoutConnect() / getGitTimeoutRead() (backed by environment.getRequiredProperty()). The test @TestPropertySource didn't include these, throwing IllegalStateException during bean creation for CoffeeControllerIntegrationTest and GitProjectsControllerIntegrationTest.

"net.ironoc.portfolio.github.timeout.connect=5000",
"net.ironoc.portfolio.github.timeout.read=5000"

RemoteBrowserBasedIntTest — fragile Selenium locator

@FindBy(linkText = "iRonoc") fails on the live site. Replaced in HomePage, AboutPage, and PortfolioPage with a structural CSS selector that doesn't depend on exact link text:

@FindBy(css = ".navbar-nav .nav-item:first-child .dropdown-toggle")

GitClient.java — minor code quality

  • dtos initialized as new ArrayList<>() instead of immutable Collections.emptyList() (was immediately reassigned on the success path)
  • Corrected misleading log message: "Failed to create connection""Received blank response body from GitHub API"

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ads.mozilla.org
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofilenVfPTx (dns block)
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofilelwFdps HooksPath (dns block)
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofileScJ9mV (dns block)
  • detectportal.firefox.com
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofilenVfPTx (dns block)
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofilelwFdps HooksPath (dns block)
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofileScJ9mV (dns block)
  • firefox.settings.services.mozilla.com
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofilenVfPTx (dns block)
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofilelwFdps HooksPath (dns block)
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofileScJ9mV (dns block)
  • incoming.telemetry.mozilla.org
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofileCczFyZ (dns block)
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofile6UATr9 (dns block)
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofileSbEwkx (dns block)
  • support.mozilla.org
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofilenVfPTx (dns block)
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofileScJ9mV (dns block)
    • Triggering command: /usr/lib/firefox/firefox /usr/lib/firefox/firefox --marionette --headless --disable-gpu --window-size=1920,1080 -no-remote -profile /tmp/rust_mozprofile6UATr9 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Apply fixes directly to PR #657 in repository conorheffron/ironoc by updating the PR branch copilot/refactor-migrate-to-spring-boot-rest-template.

Context:

Observed failures from job logs:

  1. GitClientTest.test_callGitHubApi_success_with_token fails because restTemplateMock.exchange(...) was expected but never called.
  2. GitClientTest.test_callGitHubApi_blank_response_body_fail errors with UnnecessaryStubbingException.
  3. CoffeeControllerIntegrationTest fails to load ApplicationContext because bean creation for gitClient throws during startup.
  4. GitProjectsControllerIntegrationTest fails to load ApplicationContext because bean creation for gitClient throws during startup.
  5. RemoteBrowserBasedIntTest.test_quick_tour fails with Selenium NoSuchElementException: Unable to locate element: iRonoc while hitting the live site https://ironoc.net/.

Relevant files already identified:

  • src/main/java/net/ironoc/portfolio/client/GitClient.java
  • src/test/java/net/ironoc/portfolio/client/GitClientTest.java
  • src/test/java/net/ironoc/portfolio/controller/CoffeeControllerIntegrationTest.java
  • src/test/java/net/ironoc/portfolio/controller/GitProjectsControllerIntegrationTest.java
  • src/test/java/net/ironoc/portfolio/RemoteBrowserBasedIntTest.java
  • src/test/java/net/ironoc/portfolio/config/TestIronocConfiguration.java

Important implementation guidance:

  • Preserve the intent of the new GitClient URL validation / allowlist hardening.
  • Fix unit tests so they provide whatever configuration is now required by GitClient.
  • Fix Spring integration tests so the GitClient bean can be created in the test ApplicationContext without weakening production behavior.
  • Inspect any test configuration, property binding, or mock setup needed to satisfy PropertyConfigI.getGitApiEndpointIssues() and related URL validation.
  • Fix GitClientTest to remove or avoid unnecessary Mockito stubbing and align expectations with the current code path.
  • Investigate page objects or Selenium locators used by RemoteBrowserBasedIntTest; update the test or locators to use stable selectors. Prefer a minimal targeted fix that makes the browser test reliable in CI.
  • Keep changes scoped to solving the failures in this PR.
  • Run or reason through targeted tests impacted by the changes and include a concise summary in the PR changes.

Please modify the existing PR branch rather than creating a separate unrelated branch, and open/update the pull request with the fixes.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failures come from a recent hardening change in GitClient that now rejects requests unless gitApiEndpointIssues is configured and matches the target host. That broke both unit tests and Spring integration tests.

Fix the root cause in tests

GitClient now requires propertyConfig.getGitApiEndpointIssues() to return a valid base URL. Your tests don’t stub that, so bean creation fails and callGitHubApi() exits before the mocked exchange is reached.

Relevant code:

Recommended code changes

1. Update GitClientTest setup

Add the missing property stub so the validated URL passes:

@BeforeEach
void setUp() {
    when(restTemplateBuilderMock.connectTimeout(any())).thenReturn(restTemplateBuilderMock);
    when(restTemplateBuilderMock.readTimeout(any())).thenReturn(restTemplateBuilderMock);
    when(restTemplateBuilderMock.build()).thenReturn(restTemplateMock);
    when(propertyConfigMock.getGitTimeoutConnect()).thenReturn(5000);
    when(propertyConfigMock.getGitTimeoutRead()).thenReturn(5000);
    when(propertyConfigMock.getGitApiEndpointIssues()).thenReturn("https://unittest.github.com");

    gitClient = new GitClient(restTemplateBuilderMock, propertyConfigMock,
            secretManagerMock, urlUtilsMock, new ObjectMapper());
}

2. Fix the unnecessary stubbing in test_callGitHubApi_blank_response_body_fail

Because the method c...

This pull request was created from Copilot chat.

Copilot AI and others added 14 commits May 16, 2026 03:46
Agent-Logs-Url: https://github.com/conorheffron/ironoc/sessions/d12ea468-41d4-412d-b2d3-0de30faf76b1

Co-authored-by: conorheffron <8218626+conorheffron@users.noreply.github.com>
…forgery'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: conorheffron <8218626+conorheffron@users.noreply.github.com>
Co-authored-by: conorheffron <8218626+conorheffron@users.noreply.github.com>
Copilot AI and others added 5 commits May 16, 2026 18:58
Agent-Logs-Url: https://github.com/conorheffron/ironoc/sessions/e2b11e10-6ecc-4eaa-acc1-152b5e8534f2

Co-authored-by: conorheffron <8218626+conorheffron@users.noreply.github.com>
…meout props, stable Selenium selectors

Co-authored-by: conorheffron <8218626+conorheffron@users.noreply.github.com>
…S selectors for iRonoc nav

Agent-Logs-Url: https://github.com/conorheffron/ironoc/sessions/e2b11e10-6ecc-4eaa-acc1-152b5e8534f2

Co-authored-by: conorheffron <8218626+conorheffron@users.noreply.github.com>
Co-authored-by: conorheffron <8218626+conorheffron@users.noreply.github.com>
…lank-body error message

Agent-Logs-Url: https://github.com/conorheffron/ironoc/sessions/e2b11e10-6ecc-4eaa-acc1-152b5e8534f2

Co-authored-by: conorheffron <8218626+conorheffron@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix GitHub Actions failures in PR #657 Fix failing CI tests: GitClient allowlist stubs, integration test timeout properties, stable Selenium selectors May 16, 2026
@conorheffron
conorheffron marked this pull request as ready for review May 17, 2026 10:47
@conorheffron conorheffron moved this from In progress to In review in @conorheffron's ironoc (portfolio site) May 17, 2026
@conorheffron
conorheffron merged commit 339c68b into main May 17, 2026
9 of 14 checks passed
@conorheffron
conorheffron deleted the copilot/fix-github-actions-failures branch May 17, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests unit | integration tests

Projects

Development

Successfully merging this pull request may close these issues.

2 participants