MCPcopy Index your code
hub / github.com/moby/moby / TestCreateWithCustomMaskedPaths

Function TestCreateWithCustomMaskedPaths

integration/container/create_test.go:244–315  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

242}
243
244func TestCreateWithCustomMaskedPaths(t *testing.T) {
245 skip.If(t, testEnv.DaemonInfo.OSType != "linux")
246
247 ctx := setupTest(t)
248 apiClient := testEnv.APIClient()
249
250 testCases := []struct {
251 doc string
252 privileged bool
253 maskedPaths []string
254 expected []string
255 }{
256 {
257 doc: "default masked paths",
258 maskedPaths: nil,
259 expected: oci.DefaultSpec().Linux.MaskedPaths,
260 },
261 {
262 doc: "no masked paths",
263 maskedPaths: []string{},
264 expected: []string{},
265 },
266 {
267 doc: "custom masked paths",
268 maskedPaths: []string{"/proc/kcore", "/proc/keys"},
269 expected: []string{"/proc/kcore", "/proc/keys"},
270 },
271 {
272 // privileged containers should have no masked paths by default
273 doc: "privileged",
274 privileged: true,
275 maskedPaths: nil,
276 expected: nil,
277 },
278 }
279
280 for i, tc := range testCases {
281 t.Run(tc.doc, func(t *testing.T) {
282 t.Parallel()
283
284 // Create the container.
285 ctr, err := apiClient.ContainerCreate(ctx, client.ContainerCreateOptions{
286 Config: &container.Config{
287 Image: "busybox",
288 Cmd: []string{"true"},
289 },
290 HostConfig: &container.HostConfig{
291 Privileged: tc.privileged,
292 MaskedPaths: tc.maskedPaths,
293 },
294 Name: fmt.Sprintf("create-masked-paths-%d", i),
295 })
296 assert.NilError(t, err)
297
298 inspect, err := apiClient.ContainerInspect(ctx, ctr.ID, client.ContainerInspectOptions{})
299 assert.NilError(t, err)
300 assert.DeepEqual(t, inspect.Container.HostConfig.MaskedPaths, tc.expected)
301

Callers

nothing calls this directly

Calls 8

DefaultSpecFunction · 0.92
APIClientMethod · 0.80
setupTestFunction · 0.70
RunMethod · 0.65
ContainerCreateMethod · 0.65
ContainerInspectMethod · 0.65
ContainerStartMethod · 0.65
ContainerStopMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…