| 93 | |
| 94 | |
| 95 | TEST_F(LoggingTest, Toggle) |
| 96 | { |
| 97 | process::PID<> pid; |
| 98 | pid.id = "logging"; |
| 99 | pid.address = process::address(); |
| 100 | |
| 101 | process::Future<Response> response = process::http::get(pid, "toggle"); |
| 102 | |
| 103 | AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response); |
| 104 | |
| 105 | response = process::http::get(pid, "toggle", "level=0"); |
| 106 | |
| 107 | AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response); |
| 108 | AWAIT_EXPECT_RESPONSE_BODY_EQ( |
| 109 | "Expecting 'duration=value' in query.\n", |
| 110 | response); |
| 111 | |
| 112 | response = process::http::get(pid, "toggle", "duration=10secs"); |
| 113 | |
| 114 | AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response); |
| 115 | AWAIT_EXPECT_RESPONSE_BODY_EQ( |
| 116 | "Expecting 'level=value' in query.\n", |
| 117 | response); |
| 118 | |
| 119 | response = process::http::get(pid, "toggle", "duration=10secs"); |
| 120 | |
| 121 | AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response); |
| 122 | AWAIT_EXPECT_RESPONSE_BODY_EQ( |
| 123 | "Expecting 'level=value' in query.\n", |
| 124 | response); |
| 125 | |
| 126 | response = process::http::get(pid, "toggle", "level=-1&duration=10secs"); |
| 127 | |
| 128 | AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response); |
| 129 | AWAIT_EXPECT_RESPONSE_BODY_EQ( |
| 130 | "Invalid level '-1'.\n", |
| 131 | response); |
| 132 | |
| 133 | response = process::http::get(pid, "toggle", "level=-1&duration=10secs"); |
| 134 | |
| 135 | AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response); |
| 136 | AWAIT_EXPECT_RESPONSE_BODY_EQ( |
| 137 | "Invalid level '-1'.\n", |
| 138 | response); |
| 139 | } |
| 140 | |
| 141 | |
| 142 | // Tests that the `/logging/toggle` endpoint rejects unauthenticated requests |
nothing calls this directly
no test coverage detected