Commit b8923cb
authored
Fix TestingBot credential resolution and Test Connection (#40)
* Fix TestingBot credential resolution and Test Connection
Two correctness fixes surfaced by an end-to-end run against a real account.
1. Credentials never resolved at build time.
TestingBotCredentials extended BaseCredentials (implements StandardCredentials).
CredentialsProvider.lookupCredentialsInItem(TestingBotCredentials.class, ...) —
used by the build wrapper's getCredentials(), availableCredentials() and every
credential dropdown — returned an empty list for it, even though the stored
objects are instances of the class (a StandardCredentials.class lookup found
them; a UsernamePasswordCredentialsImpl, which extends BaseStandardCredentials,
is found by concrete class). As a result the freestyle wrapper silently
resolved null credentials, so TB_KEY/TB_SECRET/TESTINGBOT_BUILD were never
injected and the dropdowns were empty.
Make TestingBotCredentials extend BaseStandardCredentials, which owns id and
description (and the id-based equals/hashCode), so concrete-type lookups work.
Old-format credentials.xml (scope/id/description/key/secret) still deserializes
unchanged — field names are identical.
2. Test Connection failed for accounts without an email.
doVerifyCredentials required a non-null user email; a valid account can return
200 with a null email (e.g. sub-accounts), which produced a false 'Could not
verify these credentials' for working key/secret. Treat any authenticated user
as success, preferring the email and falling back to the account first name.
* Add regression tests for Test Connection result branches
Extract the user-facing result building of doVerifyCredentials into a pure,
package-private verificationResult(TestingbotUser) helper (behavior unchanged) so
it can be unit-tested without the network call or the Jenkins permission check
(a JenkinsRule test is not viable here — see the harness/Jetty conflict).
Cover: null user -> error; user with email -> success naming the email; user
without email but with a first name -> success naming the first name; user
missing email, first name and plan -> still success, with no identity or plan
fragment in the message.1 parent 6c594a9 commit b8923cb
2 files changed
Lines changed: 82 additions & 37 deletions
File tree
- src
- main/java/testingbot
- test/java/testingbot
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
| |||
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
59 | | - | |
| 57 | + | |
60 | 58 | | |
61 | 59 | | |
62 | | - | |
63 | | - | |
64 | 60 | | |
65 | 61 | | |
66 | 62 | | |
67 | 63 | | |
68 | 64 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 65 | + | |
72 | 66 | | |
73 | 67 | | |
74 | 68 | | |
| |||
86 | 80 | | |
87 | 81 | | |
88 | 82 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | 83 | | |
112 | 84 | | |
113 | 85 | | |
| |||
329 | 301 | | |
330 | 302 | | |
331 | 303 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
| 304 | + | |
339 | 305 | | |
340 | 306 | | |
341 | 307 | | |
342 | 308 | | |
343 | 309 | | |
344 | 310 | | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
345 | 331 | | |
346 | 332 | | |
347 | 333 | | |
| |||
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
0 commit comments