(t *testing.T)
| 663 | } |
| 664 | |
| 665 | func TestMissingBearerAuthFile(t *testing.T) { |
| 666 | cfg := HTTPClientConfig{ |
| 667 | BearerTokenFile: MissingBearerTokenFile, |
| 668 | TLSConfig: TLSConfig{ |
| 669 | CAFile: TLSCAChainPath, |
| 670 | CertFile: ClientCertificatePath, |
| 671 | KeyFile: ClientKeyNoPassPath, |
| 672 | ServerName: "", |
| 673 | InsecureSkipVerify: false, |
| 674 | }, |
| 675 | } |
| 676 | handler := func(w http.ResponseWriter, r *http.Request) { |
| 677 | bearer := r.Header.Get("Authorization") |
| 678 | if bearer != ExpectedBearer { |
| 679 | fmt.Fprintf(w, "The expected Bearer Authorization (%s) differs from the obtained Bearer Authorization (%s)", |
| 680 | ExpectedBearer, bearer) |
| 681 | } else { |
| 682 | fmt.Fprint(w, ExpectedMessage) |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | testServer, err := newTestServer(handler) |
| 687 | require.NoError(t, err) |
| 688 | defer testServer.Close() |
| 689 | |
| 690 | client, err := NewClientFromConfig(cfg, "test") |
| 691 | require.NoError(t, err) |
| 692 | |
| 693 | _, err = client.Get(testServer.URL) |
| 694 | require.Errorf(t, err, "No error is returned here") |
| 695 | |
| 696 | require.ErrorContainsf(t, err, "unable to read authorization credentials: unable to read file missing/bearer.token: open missing/bearer.token: no such file or directory", "wrong error message being returned") |
| 697 | } |
| 698 | |
| 699 | func TestBearerAuthRoundTripper(t *testing.T) { |
| 700 | const ( |
nothing calls this directly
no test coverage detected
searching dependent graphs…