You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by as...@apache.org on 2020/02/26 17:52:17 UTC
[mesos] 01/06: Cleaned up `HTTPTest.WWWAuthenticateHeader`.
This is an automated email from the ASF dual-hosted git repository.
asekretenko pushed a commit to branch 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 580056b307b6bfdb8ddabc9dfe4302196f38df54
Author: Benjamin Bannier <bb...@apache.org>
AuthorDate: Mon Sep 23 10:23:27 2019 +0200
Cleaned up `HTTPTest.WWWAuthenticateHeader`.
This patch removes a number of error-prone temporaries previously reused
in the test.
Review: https://reviews.apache.org/r/71533
---
3rdparty/libprocess/src/tests/http_tests.cpp | 87 ++++++++++++++--------------
1 file changed, 44 insertions(+), 43 deletions(-)
diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp
index 89d3bb2..9451fed 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -1566,11 +1566,9 @@ TEST_P(HTTPTest, CaseInsensitiveHeaders)
TEST_P(HTTPTest, WWWAuthenticateHeader)
{
- http::Headers headers;
- headers["Www-Authenticate"] = "Basic realm=\"basic-realm\"";
-
Result<http::header::WWWAuthenticate> header =
- headers.get<http::header::WWWAuthenticate>();
+ http::Headers({{"Www-Authenticate", "Basic realm=\"basic-realm\""}})
+ .get<http::header::WWWAuthenticate>();
ASSERT_SOME(header);
@@ -1578,17 +1576,14 @@ TEST_P(HTTPTest, WWWAuthenticateHeader)
EXPECT_EQ(1u, header->authParam().size());
EXPECT_EQ("basic-realm", header->authParam()["realm"]);
- headers.clear();
- header = headers.get<http::header::WWWAuthenticate>();
-
- EXPECT_NONE(header);
+ EXPECT_NONE(http::Headers().get<http::header::WWWAuthenticate>());
- headers["Www-Authenticate"] =
- "Bearer realm=\"https://auth.docker.io/token\","
- "service=\"registry.docker.io\","
- "scope=\"repository:gilbertsong/inky:pull\"";
-
- header = headers.get<http::header::WWWAuthenticate>();
+ header = http::Headers(
+ {{"Www-Authenticate",
+ "Bearer realm=\"https://auth.docker.io/token\","
+ "service=\"registry.docker.io\","
+ "scope=\"repository:gilbertsong/inky:pull\""}})
+ .get<http::header::WWWAuthenticate>();
ASSERT_SOME(header);
@@ -1598,35 +1593,41 @@ TEST_P(HTTPTest, WWWAuthenticateHeader)
EXPECT_EQ("registry.docker.io", header->authParam()["service"]);
EXPECT_EQ("repository:gilbertsong/inky:pull", header->authParam()["scope"]);
- headers["Www-Authenticate"] = "";
- header = headers.get<http::header::WWWAuthenticate>();
-
- EXPECT_ERROR(header);
-
- headers["Www-Authenticate"] = " ";
- header = headers.get<http::header::WWWAuthenticate>();
-
- EXPECT_ERROR(header);
-
- headers["Www-Authenticate"] = "Digest";
- header = headers.get<http::header::WWWAuthenticate>();
-
- EXPECT_ERROR(header);
-
- headers["Www-Authenticate"] = "Digest =";
- header = headers.get<http::header::WWWAuthenticate>();
-
- EXPECT_ERROR(header);
-
- headers["Www-Authenticate"] = "Digest ,,";
- header = headers.get<http::header::WWWAuthenticate>();
-
- EXPECT_ERROR(header);
-
- headers["Www-Authenticate"] = "Digest uri=\"/dir/index.html\",qop=auth";
- header = headers.get<http::header::WWWAuthenticate>();
-
- EXPECT_ERROR(header);
+ EXPECT_ERROR(
+ http::Headers(
+ {{"Www-Authenticate",
+ ""}})
+ .get<http::header::WWWAuthenticate>());
+
+ EXPECT_ERROR(
+ http::Headers(
+ {{"Www-Authenticate",
+ " "}})
+ .get<http::header::WWWAuthenticate>());
+
+ EXPECT_ERROR(
+ http::Headers(
+ {{"Www-Authenticate",
+ "Digest"}})
+ .get<http::header::WWWAuthenticate>());
+
+ EXPECT_ERROR(
+ http::Headers(
+ {{"Www-Authenticate",
+ "Digest ="}})
+ .get<http::header::WWWAuthenticate>());
+
+ EXPECT_ERROR(
+ http::Headers(
+ {{"Www-Authenticate",
+ "Digest ,,"}})
+ .get<http::header::WWWAuthenticate>());
+
+ EXPECT_ERROR(
+ http::Headers(
+ {{"Www-Authenticate",
+ "Digest uri=\"/dir/index.html\",qop=auth"}})
+ .get<http::header::WWWAuthenticate>());
}