Skip to content

Commit b57dc9f

Browse files
committed
cri/server: Add userns tests in PodSandboxStatus
The cherry-pick has been amended to duplicate the tests in cri/sbserver and cri/server. Signed-off-by: Rodrigo Campos <[email protected]> (cherry picked from commit 06ed897)
1 parent 6e809ef commit b57dc9f

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

pkg/cri/sbserver/sandbox_status_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ func TestPodSandboxStatus(t *testing.T) {
3131
id = "test-id"
3232
ip = "10.10.10.10"
3333
)
34+
idmap := []*runtime.IDMapping{
35+
{
36+
ContainerId: 0,
37+
HostId: 100,
38+
Length: 1,
39+
},
40+
}
41+
3442
additionalIPs := []string{"8.8.8.8", "2001:db8:85a3::8a2e:370:7334"}
3543
createdAt := time.Now()
3644
config := &runtime.PodSandboxConfig{
@@ -46,6 +54,11 @@ func TestPodSandboxStatus(t *testing.T) {
4654
Network: runtime.NamespaceMode_NODE,
4755
Pid: runtime.NamespaceMode_CONTAINER,
4856
Ipc: runtime.NamespaceMode_POD,
57+
UsernsOptions: &runtime.UserNamespace{
58+
Uids: idmap,
59+
Gids: idmap,
60+
Mode: runtime.NamespaceMode_POD,
61+
},
4962
},
5063
},
5164
},
@@ -80,6 +93,11 @@ func TestPodSandboxStatus(t *testing.T) {
8093
Network: runtime.NamespaceMode_NODE,
8194
Pid: runtime.NamespaceMode_CONTAINER,
8295
Ipc: runtime.NamespaceMode_POD,
96+
UsernsOptions: &runtime.UserNamespace{
97+
Uids: idmap,
98+
Gids: idmap,
99+
Mode: runtime.NamespaceMode_POD,
100+
},
83101
},
84102
},
85103
},

pkg/cri/server/sandbox_status_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ func TestPodSandboxStatus(t *testing.T) {
3131
id = "test-id"
3232
ip = "10.10.10.10"
3333
)
34+
idmap := []*runtime.IDMapping{
35+
{
36+
ContainerId: 0,
37+
HostId: 100,
38+
Length: 1,
39+
},
40+
}
3441
additionalIPs := []string{"8.8.8.8", "2001:db8:85a3::8a2e:370:7334"}
3542
createdAt := time.Now()
3643
config := &runtime.PodSandboxConfig{
@@ -46,6 +53,11 @@ func TestPodSandboxStatus(t *testing.T) {
4653
Network: runtime.NamespaceMode_NODE,
4754
Pid: runtime.NamespaceMode_CONTAINER,
4855
Ipc: runtime.NamespaceMode_POD,
56+
UsernsOptions: &runtime.UserNamespace{
57+
Uids: idmap,
58+
Gids: idmap,
59+
Mode: runtime.NamespaceMode_POD,
60+
},
4961
},
5062
},
5163
},
@@ -80,6 +92,11 @@ func TestPodSandboxStatus(t *testing.T) {
8092
Network: runtime.NamespaceMode_NODE,
8193
Pid: runtime.NamespaceMode_CONTAINER,
8294
Ipc: runtime.NamespaceMode_POD,
95+
UsernsOptions: &runtime.UserNamespace{
96+
Uids: idmap,
97+
Gids: idmap,
98+
Mode: runtime.NamespaceMode_POD,
99+
},
83100
},
84101
},
85102
},

0 commit comments

Comments
 (0)