You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2017/03/06 20:40:49 UTC

[13/14] mesos git commit: Updated Mesos tests to use the 'Principal' type.

Updated Mesos tests to use the 'Principal' type.

This patch updates the Mesos tests to use authenticated
handlers which accept the `Principal` type instead of an
`Option<string> principal`.

Review: https://reviews.apache.org/r/56621/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/17ef4ddf
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/17ef4ddf
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/17ef4ddf

Branch: refs/heads/master
Commit: 17ef4ddf9b10ec0e86782489bf8dcbb1b47f020b
Parents: e71f957
Author: Greg Mann <gr...@mesosphere.io>
Authored: Mon Mar 6 12:40:06 2017 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Mon Mar 6 12:40:06 2017 -0800

----------------------------------------------------------------------
 src/tests/files_tests.cpp               | 10 ++++++----
 src/tests/http_authentication_tests.cpp |  7 ++++---
 src/tests/master_validation_tests.cpp   |  9 ++++-----
 3 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/17ef4ddf/src/tests/files_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/files_tests.cpp b/src/tests/files_tests.cpp
index 6c6353e..d492adf 100644
--- a/src/tests/files_tests.cpp
+++ b/src/tests/files_tests.cpp
@@ -52,6 +52,8 @@ using process::http::OK;
 using process::http::Response;
 using process::http::Unauthorized;
 
+using process::http::authentication::Principal;
+
 using std::string;
 
 using mesos::http::authentication::BasicAuthenticatorFactory;
@@ -110,7 +112,7 @@ TEST_F(FilesTest, AttachTest)
   AWAIT_EXPECT_READY(files.attach("file", "myname"));       // Re-attach.
   AWAIT_EXPECT_FAILED(files.attach("missing", "somename")); // Missing file.
 
-  auto authorization = [](const Option<string>&) { return true; };
+  auto authorization = [](const Option<Principal>&) { return true; };
 
   // Attach with required authorization.
   AWAIT_EXPECT_READY(files.attach("file", "myname", authorization));
@@ -183,7 +185,7 @@ TEST_F(FilesTest, ReadTest)
 
   // Test reads with authorization enabled.
   bool authorized = true;
-  auto authorization = [&authorized](const Option<string>&) {
+  auto authorization = [&authorized](const Option<Principal>&) {
     return authorized;
   };
 
@@ -373,7 +375,7 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(FilesTest, BrowseTest)
   files.detach("one");
 
   bool authorized = true;
-  auto authorization = [&authorized](const Option<string>&) {
+  auto authorization = [&authorized](const Option<Principal>&) {
     return authorized;
   };
 
@@ -463,7 +465,7 @@ TEST_F(FilesTest, DownloadTest)
 
   // Test downloads with authorization enabled.
   bool authorized = true;
-  auto authorization = [&authorized](const Option<string>&) {
+  auto authorization = [&authorized](const Option<Principal>&) {
     return authorized;
   };
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/17ef4ddf/src/tests/http_authentication_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/http_authentication_tests.cpp b/src/tests/http_authentication_tests.cpp
index 95f01c4..d5fabf0 100644
--- a/src/tests/http_authentication_tests.cpp
+++ b/src/tests/http_authentication_tests.cpp
@@ -78,6 +78,7 @@ using process::http::Request;
 using process::http::Unauthorized;
 
 using process::http::authentication::Authenticator;
+using process::http::authentication::Principal;
 using process::http::authentication::AuthenticationResult;
 
 
@@ -205,14 +206,14 @@ TYPED_TEST(HttpAuthenticationTest, BasicWithCredentialsTest)
   {
     Request request;
 
-    AuthenticationResult principal;
-    principal.principal = "user";
+    AuthenticationResult result;
+    result.principal = Principal("user");
 
     request.headers.put(
         "Authorization",
         "Basic " + base64::encode("user:password"));
 
-    AWAIT_EXPECT_EQ(principal, authenticator->authenticate(request));
+    AWAIT_EXPECT_EQ(result, authenticator->authenticate(request));
   }
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/17ef4ddf/src/tests/master_validation_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_validation_tests.cpp b/src/tests/master_validation_tests.cpp
index 5a84c8d..9bfc743 100644
--- a/src/tests/master_validation_tests.cpp
+++ b/src/tests/master_validation_tests.cpp
@@ -403,9 +403,9 @@ TEST_F(ReserveOperationValidationTest, NonMatchingPrincipal)
   EXPECT_TRUE(
       strings::contains(
           error->message,
-          "A reserve operation was attempted by principal 'principal1', but "
-          "there is a reserved resource in the request with principal "
-          "'principal2' set in `ReservationInfo`"));
+          "A reserve operation was attempted by authenticated principal "
+          "'principal1', which does not match a reserved resource in the "
+          "request with principal 'principal2'"));
 }
 
 
@@ -432,8 +432,7 @@ TEST_F(ReserveOperationValidationTest, ReservationInfoMissingPrincipal)
       strings::contains(
           error->message,
           "A reserve operation was attempted by principal 'principal', but "
-          "there is a reserved resource in the request with no principal set "
-          "in `ReservationInfo`"));
+          "there is a reserved resource in the request with no principal set"));
 }