Commit 48af9bd
committed
test(security): add positive-path test for insecure TLS double-gate
Code review on PR #157 caught that the existing tests only assert the
SAFE/DEFAULT path and the env-var helper's UNSET behaviour. They never
exercise the positive path where BOTH gates are present and the insecure
TrustManager actually activates — the one combination that ships a
trust-all SSLContext and permissive HostnameVerifier.
This commit adds four tests to close the gap:
- envVarHelperShouldBeTrueWhenSetToTrue / ...WhenSetToOne
Confirm isInsecureTlsEnvVarEnabled() honours both accepted values.
- shouldActivateInsecurePathWhenBothGatesArePresent
The positive-path regression. Builds an OkHttpClient with
insecureSkipVerify(true) AND AXONFLOW_INSECURE_TLS=true, then asserts:
1. hostnameVerifier class name does NOT contain "OkHostnameVerifier"
(i.e. the synthetic permissive lambda is installed),
2. that verifier returns true for an arbitrary hostname,
3. sslSocketFactory() is NOT the same instance as the one a
default-path client produces (trust-all SSLContext is wired in).
- shouldKeepDefaultPathWhenOnlyEnvVarIsSet
Complementary negative path — env var alone, without the builder
flag, must keep OkHttp's default OkHostnameVerifier. Together with
the existing "neither flag set" test, this proves the gate is
symmetric: both must be present to flip behaviour.
Env-var injection is done with junit-pioneer 2.2.0's
@SetEnvironmentVariable, which scopes the variable to a single test
method via reflective access into java.base/java.util. The required
JDK 17+ --add-opens flags are added to the surefire argLine alongside
the existing -Dnet.bytebuddy.experimental=true.
Full suite: 1228/1228 green.1 parent b65ef0e commit 48af9bd
2 files changed
Lines changed: 88 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
131 | 139 | | |
132 | 140 | | |
133 | 141 | | |
| |||
183 | 191 | | |
184 | 192 | | |
185 | 193 | | |
186 | | - | |
| 194 | + | |
| 195 | + | |
187 | 196 | | |
188 | 197 | | |
189 | 198 | | |
| |||
Lines changed: 78 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
103 | 181 | | |
0 commit comments