MCPcopy Create free account
hub / github.com/Mirantis/cri-dockerd / TestValidateExecAttachRequest

Function TestValidateExecAttachRequest

streaming/server_test.go:110–183  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

108}
109
110func TestValidateExecAttachRequest(t *testing.T) {
111 type config struct {
112 tty bool
113 stdin bool
114 stdout bool
115 stderr bool
116 }
117 for _, tc := range []struct {
118 desc string
119 configs []config
120 expectErr bool
121 }{
122 {
123 desc: "at least one stream must be true",
124 expectErr: true,
125 configs: []config{
126 {false, false, false, false},
127 {true, false, false, false}},
128 },
129 {
130 desc: "tty and stderr cannot both be true",
131 expectErr: true,
132 configs: []config{
133 {true, false, false, true},
134 {true, false, true, true},
135 {true, true, false, true},
136 {true, true, true, true},
137 },
138 },
139 {
140 desc: "a valid config should pass",
141 expectErr: false,
142 configs: []config{
143 {false, false, false, true},
144 {false, false, true, false},
145 {false, false, true, true},
146 {false, true, false, false},
147 {false, true, false, true},
148 {false, true, true, false},
149 {false, true, true, true},
150 {true, false, true, false},
151 {true, true, false, false},
152 {true, true, true, false},
153 },
154 },
155 } {
156 t.Run(tc.desc, func(t *testing.T) {
157 for _, c := range tc.configs {
158 // validate the exec request.
159 execReq := &runtimeapi.ExecRequest{
160 ContainerId: testContainerID,
161 Cmd: []string{"date"},
162 Tty: c.tty,
163 Stdin: c.stdin,
164 Stdout: c.stdout,
165 Stderr: c.stderr,
166 }
167 err := validateExecRequest(execReq)

Callers

nothing calls this directly

Calls 3

validateExecRequestFunction · 0.85
validateAttachRequestFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…