mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vinodk...@apache.org
Subject [11/14] mesos git commit: Updated libprocess tests to use the 'Principal' type.
Date Mon, 06 Mar 2017 20:40:47 GMT
Updated libprocess tests to use the 'Principal' type.

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

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


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

Branch: refs/heads/master
Commit: 602c9db732faa85d73987f3f51ab0e376ba3d18f
Parents: da47646
Author: Greg Mann <greg@mesosphere.io>
Authored: Mon Mar 6 12:39:55 2017 -0800
Committer: Vinod Kone <vinodkone@gmail.com>
Committed: Mon Mar 6 12:39:55 2017 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/src/tests/http_tests.cpp | 31 ++++++++++++-----------
 1 file changed, 16 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/602c9db7/3rdparty/libprocess/src/tests/http_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp
index fb4da9a..0f0b36c 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -60,6 +60,7 @@ namespace unix = process::network::unix;
 using authentication::Authenticator;
 using authentication::AuthenticationResult;
 using authentication::BasicAuthenticator;
+using authentication::Principal;
 
 using process::Failure;
 using process::Future;
@@ -114,7 +115,7 @@ public:
 
   MOCK_METHOD2(
       authenticated,
-      Future<http::Response>(const http::Request&, const Option<string>&));
+      Future<http::Response>(const http::Request&, const Option<Principal>&));
 
 protected:
   virtual void initialize()
@@ -1772,7 +1773,7 @@ TEST_F(HttpAuthenticationTest, NoAuthenticator)
 {
   Http http;
 
-  EXPECT_CALL(*http.process, authenticated(_, Option<string>::none()))
+  EXPECT_CALL(*http.process, authenticated(_, Option<Principal>::none()))
     .WillOnce(Return(http::OK()));
 
   Future<http::Response> response =
@@ -1840,12 +1841,12 @@ TEST_F(HttpAuthenticationTest, Authenticated)
   Http http;
 
   AuthenticationResult authentication;
-  authentication.principal = "principal";
+  authentication.principal = Principal("principal");
 
   EXPECT_CALL((*authenticator), authenticate(_))
     .WillOnce(Return(authentication));
 
-  EXPECT_CALL(*http.process, authenticated(_, Option<string>("principal")))
+  EXPECT_CALL(*http.process, authenticated(_, Option<Principal>("principal")))
     .WillOnce(Return(http::OK()));
 
   // Note that we don't bother pretending to specify a valid
@@ -1875,8 +1876,8 @@ TEST_F(HttpAuthenticationTest, Pipelining)
     .WillOnce(Return(promise1.future()))
     .WillOnce(Return(promise2.future()));
 
-  Future<Option<string>> principal1;
-  Future<Option<string>> principal2;
+  Future<Option<Principal>> principal1;
+  Future<Option<Principal>> principal2;
   EXPECT_CALL(*http.process, authenticated(_, _))
     .WillOnce(DoAll(FutureArg<1>(&principal1), Return(http::OK("1"))))
     .WillOnce(DoAll(FutureArg<1>(&principal2), Return(http::OK("2"))));
@@ -1902,13 +1903,13 @@ TEST_F(HttpAuthenticationTest, Pipelining)
   Future<http::Response> response1 = connection.send(request);
   Future<http::Response> response2 = connection.send(request);
 
-  AuthenticationResult authentiation2;
-  authentiation2.principal = "principal2";
-  promise2.set(authentiation2);
+  AuthenticationResult authentication2;
+  authentication2.principal = Principal("principal2");
+  promise2.set(authentication2);
 
-  AuthenticationResult authentiation1;
-  authentiation1.principal = "princpal1";
-  promise1.set(authentiation1);
+  AuthenticationResult authentication1;
+  authentication1.principal = Principal("principal1");
+  promise1.set(authentication1);
 
   AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response1);
   EXPECT_EQ("1", response1->body);
@@ -1916,8 +1917,8 @@ TEST_F(HttpAuthenticationTest, Pipelining)
   AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response2);
   EXPECT_EQ("2", response2->body);
 
-  AWAIT_EXPECT_EQ(authentiation1.principal, principal1);
-  AWAIT_EXPECT_EQ(authentiation2.principal, principal2);
+  AWAIT_EXPECT_EQ(authentication1.principal, principal1);
+  AWAIT_EXPECT_EQ(authentication2.principal, principal2);
 }
 
 
@@ -1970,7 +1971,7 @@ TEST_F(HttpAuthenticationTest, Basic)
 
   // Right credentials provided.
   {
-    EXPECT_CALL(*http.process, authenticated(_, Option<string>("user")))
+    EXPECT_CALL(*http.process, authenticated(_, Option<Principal>("user")))
       .WillOnce(Return(http::OK()));
 
     http::Headers headers;


Mime
View raw message