Commit 4484d3d
authored
Add a Test Connection button to TestingBot credentials (#36)
* Add a Test Connection button to TestingBot credentials
Adds a "Test Connection" validate button to the credentials form that calls the
TestingBot REST API (getUserInfo) with the entered key/secret and reports whether
they authenticate — e.g. "Connection successful — signed in as <email> (<plan>
plan)" or a clear error. This is the credential verification Sauce/BrowserStack
offer and we lacked.
The doVerifyCredentials descriptor method is @post (CSRF-safe), gated to admins or
users who can configure the surrounding item, and resolves the secret via
Secret.fromString so it works whether the form submits plaintext or the encrypted
value. The REST client is closed via try-with-resources.
* Catch the REST client's typed exceptions, not broad Exception (review on #36)
doVerifyCredentials caught Exception, masking unexpected bugs. The testingbotrest
client signals failures via two specific (unchecked) types — TestingbotUnauthorized
Exception (bad key/secret) and TestingbotApiException (which wraps network/parse
IOException) — so catch exactly those and let any other runtime exception propagate.
Note: getUserInfo()/close() declare no checked exceptions, so narrowing to checked
types (as literally worded) isn't possible; these typed unchecked exceptions are the
client's declared failure signals.1 parent b0cfb0e commit 4484d3d
2 files changed
Lines changed: 40 additions & 0 deletions
File tree
- src/main
- java/testingbot
- resources/testingbot/TestingBotCredentials
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| |||
305 | 309 | | |
306 | 310 | | |
307 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
308 | 345 | | |
309 | 346 | | |
310 | 347 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
0 commit comments