Commit d2b5b14
test(git): de-flake GitUtilsTest.isRepoPrivate by mocking the HTTP call (#41975)
## Problem
`GitUtilsTest.isRepoPrivate` intermittently fails in CI with `expected:
false`. The test asserted against **real** URLs — including
`github.com/appsmithorg/appsmith` — and `GitUtils.isRepoPrivate`
performs a **live HTTP GET** against the repo URL (2xx ⇒ public,
otherwise/error ⇒ private) with a **2-second timeout**:
```java
return WebClientUtils.create(remoteHttpsUrl).get()
.httpRequest(r -> r.getNativeRequest().responseTimeout(Duration.ofSeconds(2)))
.exchange()
.flatMap(resp -> Mono.just(!resp.statusCode().is2xxSuccessful()))
.onErrorResume(t -> Mono.just(Boolean.TRUE)); // error ⇒ assume private
```
So whenever the CI runner can't reach GitHub within 2s (shared-runner
rate-limits, DNS blips), the error path returns `TRUE` (private) and the
`expected: false` (public) assertion fails — non-deterministically,
independent of the change under test. This is almost certainly the flake
behind the intermittently-red scheduled release builds too.
## Fix
Make the test hermetic: mock `WebClientUtils.create` so the request hits
a local `MockWebServer` instead of the internet, and assert the real
branching logic deterministically — **200 ⇒ public**, **404 ⇒ private**.
`WebClientUtils.create` is mocked (rather than pointing `isRepoPrivate`
straight at the loopback server) because it wraps every `WebClient` in
an SSRF host filter that would block a loopback address. URL-conversion
coverage is untouched — `convertSshUrlToBrowserSupportedUrl` has its own
dedicated test.
No new dependencies (`mockwebserver` + `mockito-inline` are already test
deps). Verified locally on JDK 25: `Tests run: 18, Failures: 0`.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Tests**
* Updated repository privacy checks to use fully mocked HTTP responses
instead of real network calls.
* Added coverage for both accessible and inaccessible repository
responses, improving test reliability and stability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 0d3895d commit d2b5b14
1 file changed
Lines changed: 34 additions & 16 deletions
Lines changed: 34 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| |||
87 | 93 | | |
88 | 94 | | |
89 | 95 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
106 | 124 | | |
107 | 125 | | |
108 | 126 | | |
| |||
0 commit comments