MCPcopy
hub / github.com/containerd/containerd / TestUIDNoGID

Function TestUIDNoGID

integration/client/container_linux_test.go:1266–1299  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1264}
1265
1266func TestUIDNoGID(t *testing.T) {
1267 t.Parallel()
1268
1269 ctx, cancel := testContext(t)
1270 defer cancel()
1271 id := t.Name()
1272
1273 client, err := newClient(t, address)
1274 if err != nil {
1275 t.Fatal(err)
1276 }
1277 defer client.Close()
1278 image, err := client.GetImage(ctx, testImage)
1279 if err != nil {
1280 t.Fatal(err)
1281 }
1282
1283 container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithUserID(1000)))
1284 if err != nil {
1285 t.Fatal(err)
1286 }
1287 defer container.Delete(ctx)
1288
1289 spec, err := container.Spec(ctx)
1290 if err != nil {
1291 t.Fatal(err)
1292 }
1293 if uid := spec.Process.User.UID; uid != 1000 {
1294 t.Fatalf("expected uid 1000 but received %d", uid)
1295 }
1296 if gid := spec.Process.User.GID; gid != 0 {
1297 t.Fatalf("expected gid 0 but received %d", gid)
1298 }
1299}
1300
1301func TestBindLowPortNonRoot(t *testing.T) {
1302 t.Parallel()

Callers

nothing calls this directly

Calls 12

DeleteMethod · 0.95
SpecMethod · 0.95
WithUserIDFunction · 0.92
testContextFunction · 0.85
newClientFunction · 0.85
WithNewSpecFunction · 0.85
FatalMethod · 0.80
NameMethod · 0.65
CloseMethod · 0.65
GetImageMethod · 0.65
NewContainerMethod · 0.65
WithNewSnapshotFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…