(t *testing.T)
| 36 | } |
| 37 | |
| 38 | func TestLoadPEMPath(t *testing.T) { |
| 39 | var s3flags storageS3Flags |
| 40 | |
| 41 | tempdir := testutil.TempDirectory(t) |
| 42 | certpath := filepath.Join(tempdir, "certificate-filename") |
| 43 | |
| 44 | require.NoError(t, os.WriteFile(certpath, fakeCertContent, 0o644)) |
| 45 | |
| 46 | // Test regular file |
| 47 | s3flags = storageS3Flags{rootCaPemPath: certpath} |
| 48 | require.NoError(t, s3flags.preActionLoadPEMPath(nil)) |
| 49 | require.Equal(t, fakeCertContent, s3flags.s3options.RootCA, "content of RootCA should be %v", fakeCertContent) |
| 50 | |
| 51 | // Test inexistent file |
| 52 | s3flags = storageS3Flags{rootCaPemPath: "/does-not-exists"} |
| 53 | err := s3flags.preActionLoadPEMPath(nil) |
| 54 | require.Error(t, err) |
| 55 | require.Contains(t, err.Error(), "error opening root-ca-pem-path") |
| 56 | } |
| 57 | |
| 58 | func TestLoadPEMBoth(t *testing.T) { |
| 59 | s3flags := storageS3Flags{rootCaPemBase64: "AA==", rootCaPemPath: "/tmp/blah"} |
nothing calls this directly
no test coverage detected