Tests that the `/metrics/snapshot` endpoint will reject unauthenticated requests when HTTP authentication is enabled on the master.
| 92 | // Tests that the `/metrics/snapshot` endpoint will reject unauthenticated |
| 93 | // requests when HTTP authentication is enabled on the master. |
| 94 | TEST_F(MetricsTest, MasterAuthenticationEnabled) |
| 95 | { |
| 96 | Credentials credentials; |
| 97 | credentials.add_credentials()->CopyFrom(DEFAULT_CREDENTIAL); |
| 98 | |
| 99 | // Create a basic HTTP authenticator with the specified credentials and set it |
| 100 | // as the authenticator for `READONLY_HTTP_AUTHENTICATION_REALM`. |
| 101 | setBasicHttpAuthenticator(READONLY_HTTP_AUTHENTICATION_REALM, credentials); |
| 102 | |
| 103 | Try<Owned<cluster::Master>> master = StartMaster(); |
| 104 | ASSERT_SOME(master); |
| 105 | |
| 106 | // Get the snapshot. |
| 107 | process::UPID upid("metrics", process::address()); |
| 108 | |
| 109 | process::Future<process::http::Response> response = |
| 110 | process::http::get(upid, "snapshot"); |
| 111 | |
| 112 | AWAIT_EXPECT_RESPONSE_STATUS_EQ( |
| 113 | process::http::Unauthorized({}).status, response); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | // Tests that the `/metrics/snapshot` endpoint will reject unauthenticated |
nothing calls this directly
no test coverage detected