You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ka...@apache.org on 2016/01/29 21:56:03 UTC

mesos git commit: Added persistent volume endpoint test without authentication.

Repository: mesos
Updated Branches:
  refs/heads/master 86e7efb44 -> 222446f48


Added persistent volume endpoint test without authentication.

Added persistent volume endpoint tests with HTTP authentication
disabled.

The persistent volume endpoint tests allow volume creation and
destruction when HTTP authentication is disabled; this patch introduces
a test for this scenario:
  `PersistentVolumeEndpointsTest.NoAuthentication`.

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


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

Branch: refs/heads/master
Commit: 222446f4859b04c740bab551835499089b8f9421
Parents: 86e7efb
Author: Greg Mann <gr...@mesosphere.io>
Authored: Fri Jan 29 12:43:25 2016 -0500
Committer: Kapil Arya <ka...@mesosphere.io>
Committed: Fri Jan 29 14:01:07 2016 -0500

----------------------------------------------------------------------
 src/tests/persistent_volume_endpoints_tests.cpp | 66 ++++++++++++++++++++
 1 file changed, 66 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/222446f4/src/tests/persistent_volume_endpoints_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/persistent_volume_endpoints_tests.cpp b/src/tests/persistent_volume_endpoints_tests.cpp
index 22e1875..6069ca1 100644
--- a/src/tests/persistent_volume_endpoints_tests.cpp
+++ b/src/tests/persistent_volume_endpoints_tests.cpp
@@ -1076,6 +1076,72 @@ TEST_F(PersistentVolumeEndpointsTest, GoodCreateAndDestroyACLBadCredential)
 }
 
 
+// This test creates and destroys a volume without authentication headers and
+// with authorization disabled. These requests will succeed because HTTP
+// authentication is disabled, so authentication headers are not required.
+// Additionally, since authorization is not enabled, any principal, including
+// `None()`, can create and destroy volumes.
+TEST_F(PersistentVolumeEndpointsTest, NoAuthentication)
+{
+  const string TEST_ROLE = "role1";
+
+  TestAllocator<> allocator;
+
+  // Create master flags that will disable authentication.
+  master::Flags masterFlags = CreateMasterFlags();
+  masterFlags.authenticate_http = false;
+
+  EXPECT_CALL(allocator, initialize(_, _, _, _));
+
+  Try<PID<Master>> master = StartMaster(&allocator, masterFlags);
+  ASSERT_SOME(master);
+
+  // Create an agent with statically reserved disk resources to allow the
+  // creation of a persistent volume.
+  slave::Flags agentFlags = CreateSlaveFlags();
+  agentFlags.resources = "cpus:1;mem:512;disk(" + TEST_ROLE + "):1024";
+
+  Future<SlaveID> agentId;
+  EXPECT_CALL(allocator, addSlave(_, _, _, _, _))
+    .WillOnce(DoAll(InvokeAddSlave(&allocator), FutureArg<0>(&agentId)));
+
+  Try<PID<Slave>> agent = StartSlave(agentFlags);
+  ASSERT_SOME(agent);
+
+  AWAIT_READY(agentId);
+
+  Resources volume = createPersistentVolume(
+      Megabytes(64),
+      TEST_ROLE,
+      "id1",
+      "path1");
+
+  // Make a request to create a volume with no authentication header.
+  {
+    Future<Response> response = process::http::post(
+        master.get(),
+        "create-volumes",
+        None(),
+        createRequestBody(agentId.get(), "volumes", volume));
+
+    AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+  }
+
+  // Make a request to destroy a volume with no authentication header.
+  {
+    Future<Response> response = process::http::post(
+        master.get(),
+        "destroy-volumes",
+        None(),
+        createRequestBody(agentId.get(), "volumes", volume));
+
+    AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+  }
+
+  Shutdown();
+}
+
+
 // This tests that an attempt to create or destroy a volume with no
 // 'slaveId' results in a 'BadRequest' HTTP error.
 TEST_F(PersistentVolumeEndpointsTest, NoSlaveId)