TestGetRequestMetadataBadSubjectTokenRead verifies the scenario where the attempt to read the subjectToken fails.
(t *testing.T)
| 412 | // TestGetRequestMetadataBadSubjectTokenRead verifies the scenario where the |
| 413 | // attempt to read the subjectToken fails. |
| 414 | func (s) TestGetRequestMetadataBadSubjectTokenRead(t *testing.T) { |
| 415 | defer overrideSubjectTokenError()() |
| 416 | fc, cancel := overrideHTTPClientGood() |
| 417 | defer cancel() |
| 418 | |
| 419 | creds, err := NewCredentials(goodOptions) |
| 420 | if err != nil { |
| 421 | t.Fatalf("NewCredentials(%v) = %v", goodOptions, err) |
| 422 | } |
| 423 | |
| 424 | errCh := make(chan error, 1) |
| 425 | go func() { |
| 426 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestShortTimeout) |
| 427 | defer cancel() |
| 428 | if _, err := fc.ReqChan.Receive(ctx); err != context.DeadlineExceeded { |
| 429 | errCh <- err |
| 430 | return |
| 431 | } |
| 432 | errCh <- nil |
| 433 | }() |
| 434 | |
| 435 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 436 | defer cancel() |
| 437 | if _, err := creds.GetRequestMetadata(createTestContext(ctx, credentials.PrivacyAndIntegrity), ""); err == nil { |
| 438 | t.Fatal("creds.GetRequestMetadata() succeeded when expected to fail") |
| 439 | } |
| 440 | if err := <-errCh; err != nil { |
| 441 | t.Fatal(err) |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | func (s) TestNewCredentials(t *testing.T) { |
| 446 | tests := []struct { |
nothing calls this directly
no test coverage detected