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

Function TEST_F

src/tests/metrics_tests.cpp:94–114  ·  view source on GitHub ↗

Tests that the `/metrics/snapshot` endpoint will reject unauthenticated requests when HTTP authentication is enabled on the master.

Source from the content-addressed store, hash-verified

92// Tests that the `/metrics/snapshot` endpoint will reject unauthenticated
93// requests when HTTP authentication is enabled on the master.
94TEST_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

Callers

nothing calls this directly

Calls 10

UnauthorizedClass · 0.85
NoneClass · 0.85
createBasicAuthHeadersFunction · 0.85
ForbiddenClass · 0.85
CopyFromMethod · 0.80
createDetectorMethod · 0.80
principalMethod · 0.80
addressFunction · 0.50
getFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected