MCPcopy Create free account
hub / github.com/containers/image / TestDockerCertDir

Function TestDockerCertDir

docker/docker_client_test.go:23–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21)
22
23func TestDockerCertDir(t *testing.T) {
24 const nondefaultFullPath = "/this/is/not/the/default/full/path"
25 const nondefaultPerHostDir = "/this/is/not/the/default/certs.d"
26 const variableReference = "$HOME"
27 const rootPrefix = "/root/prefix"
28 const registryHostPort = "thishostdefinitelydoesnotexist:5000"
29
30 systemPerHostResult := filepath.Join(perHostCertDirs[len(perHostCertDirs)-1].path, registryHostPort)
31 for _, c := range []struct {
32 sys *types.SystemContext
33 expected string
34 }{
35 // The common case
36 {nil, systemPerHostResult},
37 // There is a context, but it does not override the path.
38 {&types.SystemContext{}, systemPerHostResult},
39 // Full path overridden
40 {&types.SystemContext{DockerCertPath: nondefaultFullPath}, nondefaultFullPath},
41 // Per-host path overridden
42 {
43 &types.SystemContext{DockerPerHostCertDirPath: nondefaultPerHostDir},
44 filepath.Join(nondefaultPerHostDir, registryHostPort),
45 },
46 // Both overridden
47 {
48 &types.SystemContext{
49 DockerCertPath: nondefaultFullPath,
50 DockerPerHostCertDirPath: nondefaultPerHostDir,
51 },
52 nondefaultFullPath,
53 },
54 // Root overridden
55 {
56 &types.SystemContext{RootForImplicitAbsolutePaths: rootPrefix},
57 filepath.Join(rootPrefix, systemPerHostResult),
58 },
59 // Root and path overrides present simultaneously,
60 {
61 &types.SystemContext{
62 DockerCertPath: nondefaultFullPath,
63 RootForImplicitAbsolutePaths: rootPrefix,
64 },
65 nondefaultFullPath,
66 },
67 {
68 &types.SystemContext{
69 DockerPerHostCertDirPath: nondefaultPerHostDir,
70 RootForImplicitAbsolutePaths: rootPrefix,
71 },
72 filepath.Join(nondefaultPerHostDir, registryHostPort),
73 },
74 // … and everything at once
75 {
76 &types.SystemContext{
77 DockerCertPath: nondefaultFullPath,
78 DockerPerHostCertDirPath: nondefaultPerHostDir,
79 RootForImplicitAbsolutePaths: rootPrefix,
80 },

Callers

nothing calls this directly

Calls 1

dockerCertDirFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…