MCPcopy Create free account
hub / github.com/apache/mesos / TEST_F

Function TEST_F

src/tests/dynamic_weights_tests.cpp:147–192  ·  view source on GitHub ↗

Update weights requests with invalid JSON structure should return '400 Bad Request'.

Source from the content-addressed store, hash-verified

145// Update weights requests with invalid JSON structure
146// should return '400 Bad Request'.
147TEST_F(DynamicWeightsTest, PutInvalidRequest)
148{
149 Try<Owned<cluster::Master>> master = StartMaster();
150 ASSERT_SOME(master);
151
152 // Tests whether an update weights request with invalid JSON fails.
153 string badRequest =
154 "[{"
155 " \"weight\":3.2,"
156 " \"role\""
157 "}]";
158
159 Future<Response> response = process::http::request(
160 process::http::createRequest(
161 master.get()->pid,
162 "PUT",
163 false,
164 "weights",
165 createBasicAuthHeaders(DEFAULT_CREDENTIAL),
166 badRequest));
167
168 AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response);
169
170 checkWithGetRequest(master.get()->pid, DEFAULT_CREDENTIAL);
171
172 // Tests whether an update weights request with an invalid field fails.
173 // In this case, the correct field name should be 'role'.
174 badRequest =
175 "[{"
176 " \"weight\":3.2,"
177 " \"invalidField\":\"role1\""
178 "}]";
179
180 response = process::http::request(
181 process::http::createRequest(
182 master.get()->pid,
183 "PUT",
184 false,
185 "weights",
186 createBasicAuthHeaders(DEFAULT_CREDENTIAL),
187 badRequest));
188
189 AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response);
190
191 checkWithGetRequest(master.get()->pid, DEFAULT_CREDENTIAL);
192}
193
194
195// An update weights request with zero value

Callers

nothing calls this directly

Calls 15

requestFunction · 0.85
createRequestFunction · 0.85
createBasicAuthHeadersFunction · 0.85
BadRequestClass · 0.85
createWeightInfosFunction · 0.85
formatFunction · 0.85
protobufFunction · 0.85
OKClass · 0.85
UnauthorizedClass · 0.85
NoneClass · 0.85
ForbiddenClass · 0.85
principalMethod · 0.80

Tested by

no test coverage detected