MCPcopy
hub / github.com/kopia/kopia / TestLoadPEMPath

Function TestLoadPEMPath

cli/storage_s3_test.go:38–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func 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
58func TestLoadPEMBoth(t *testing.T) {
59 s3flags := storageS3Flags{rootCaPemBase64: "AA==", rootCaPemPath: "/tmp/blah"}

Callers

nothing calls this directly

Calls 6

preActionLoadPEMPathMethod · 0.95
TempDirectoryFunction · 0.92
EqualMethod · 0.80
WriteFileMethod · 0.65
ErrorMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected