This handler receives auth URLs, and logs into control. It counts how many URLs it sees, and will fail the test if it sees multiple login URLs.
(t *testing.T, control *testcontrol.Server, counter *atomic.Int32)
| 305 | // It counts how many URLs it sees, and will fail the test if it |
| 306 | // sees multiple login URLs. |
| 307 | func completeLogin(t *testing.T, control *testcontrol.Server, counter *atomic.Int32) func(string) error { |
| 308 | return func(urlStr string) error { |
| 309 | t.Logf("saw auth URL %q", urlStr) |
| 310 | if control.CompleteAuth(urlStr) { |
| 311 | if counter.Add(1) > 1 { |
| 312 | err := errors.New("completed multiple auth URLs") |
| 313 | t.Error(err) |
| 314 | return err |
| 315 | } |
| 316 | t.Logf("completed login to %s", urlStr) |
| 317 | return nil |
| 318 | } else { |
| 319 | err := fmt.Errorf("failed to complete initial login to %q", urlStr) |
| 320 | t.Fatal(err) |
| 321 | return err |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | // This handler receives device approval URLs, and approves the device. |
| 327 | // |
no test coverage detected
searching dependent graphs…