This test sends a malformed body that cannot be deserialized into a valid protobuf resulting in a BadRequest.
| 212 | // This test sends a malformed body that cannot be deserialized |
| 213 | // into a valid protobuf resulting in a BadRequest. |
| 214 | TEST_P(ExecutorHttpApiTest, MalformedContent) |
| 215 | { |
| 216 | Try<Owned<cluster::Master>> master = StartMaster(); |
| 217 | ASSERT_SOME(master); |
| 218 | |
| 219 | Future<Nothing> __recover = FUTURE_DISPATCH(_, &Slave::__recover); |
| 220 | |
| 221 | Owned<MasterDetector> detector = master.get()->createDetector(); |
| 222 | |
| 223 | slave::Flags flags = CreateSlaveFlags(); |
| 224 | |
| 225 | Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), flags); |
| 226 | ASSERT_SOME(slave); |
| 227 | |
| 228 | AWAIT_READY(__recover); |
| 229 | |
| 230 | // Wait for recovery to be complete. |
| 231 | Clock::pause(); |
| 232 | Clock::settle(); |
| 233 | |
| 234 | const string body = "MALFORMED_CONTENT"; |
| 235 | |
| 236 | const ContentType contentType = GetParam(); |
| 237 | process::http::Headers headers; |
| 238 | headers["Accept"] = stringify(contentType); |
| 239 | |
| 240 | Future<Response> response = process::http::post( |
| 241 | slave.get()->pid, |
| 242 | "api/v1/executor", |
| 243 | headers, |
| 244 | body, |
| 245 | stringify(contentType)); |
| 246 | |
| 247 | AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response); |
| 248 | } |
| 249 | |
| 250 | |
| 251 | // This test sets an unsupported media type as Content-Type. This |
nothing calls this directly
no test coverage detected