You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2019/12/05 15:32:19 UTC

[mesos] 01/03: Cleaned up `HTTPTest.WWWAuthenticateHeader`.

This is an automated email from the ASF dual-hosted git repository.

bennoe pushed a commit to branch 1.9.x
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 5f6d218a3123ec35b3a14ce20e72b5ca3594cef2
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 8cb5f16..b0f1272 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -1614,11 +1614,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);
 
@@ -1626,17 +1624,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);
 
@@ -1646,35 +1641,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>());
 }