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 2014/06/11 03:23:28 UTC
git commit: Re-enabled "--acls" flag on master and updated example
tests to use authorization.
Repository: mesos
Updated Branches:
refs/heads/master 57f352e20 -> bdb30b906
Re-enabled "--acls" flag on master and updated example tests to use authorization.
Review: https://reviews.apache.org/r/22447
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/bdb30b90
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/bdb30b90
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/bdb30b90
Branch: refs/heads/master
Commit: bdb30b906c9f4c7a73b1fb1230ea4d4bda4fb7bf
Parents: 57f352e
Author: Vinod Kone <vi...@twitter.com>
Authored: Tue Jun 10 17:16:01 2014 -0700
Committer: Vinod Kone <vi...@twitter.com>
Committed: Tue Jun 10 18:20:34 2014 -0700
----------------------------------------------------------------------
src/master/flags.hpp | 48 +++++++++++++++++------------------
src/tests/script.cpp | 31 +++++++++++++++++++---
src/tests/test_framework_test.sh | 2 --
3 files changed, 51 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/bdb30b90/src/master/flags.hpp
----------------------------------------------------------------------
diff --git a/src/master/flags.hpp b/src/master/flags.hpp
index ed08c6b..780e219 100644
--- a/src/master/flags.hpp
+++ b/src/master/flags.hpp
@@ -208,30 +208,30 @@ public:
"Each line contains 'principal' and 'secret' separated by whitespace.\n"
"Path could be of the form 'file:///path/to/file' or '/path/to/file'.");
- // TODO(vinod): Expose this flag once the authorization feature is
- // code complete.
-// add(&Flags::acls,
-// "acls",
-// "The value could be a JSON formatted string of ACLs\n"
-// "or a file path containing the JSON formatted ACLs used\n"
-// "for authorization. Path could be of the form 'file:///path/to/file'\n"
-// "or '/path/to/file'.\n"
-// "\n"
-// "See the ACL protobuf in mesos.proto for the expected format.\n"
-// "\n"
-// "Example:\n"
-// "{\n"
-// " \"run_tasks\": [\n"
-// " {\n"
-// " \"principals\": { values: [\"foo\", \"bar\"] },\n"
-// " \"users\": { values: [\"root\"] }\n"
-// " },\n"
-// " {\n"
-// " \"principals\": { type: \"ANY\" },\n"
-// " \"users\": { values: [\"guest\"] }\n"
-// " }\n"
-// " ]\n"
-// "}");
+ add(&Flags::acls,
+ "acls",
+ "The value could be a JSON formatted string of ACLs\n"
+ "or a file path containing the JSON formatted ACLs used\n"
+ "for authorization. Path could be of the form 'file:///path/to/file'\n"
+ "or '/path/to/file'.\n"
+ "\n"
+ "See the ACLs protobuf in mesos.proto for the expected format.\n"
+ "\n"
+ "Example:\n"
+ "{\n"
+ " \"run_tasks\": [\n"
+ " {\n"
+ " \"principals\": { \"values\": [\"a\", \"b\"] },\n"
+ " \"users\": { \"values\": [\"root\"] }\n"
+ " }\n"
+ " ],\n"
+ " \"receive_offers\": [\n"
+ " {\n"
+ " \"principals\": { \"type\": \"ANY\" },\n"
+ " \"roles\": { \"values\": [\"foo\"] }\n"
+ " }\n"
+ " ]\n"
+ "}");
}
bool version;
http://git-wip-us.apache.org/repos/asf/mesos/blob/bdb30b90/src/tests/script.cpp
----------------------------------------------------------------------
diff --git a/src/tests/script.cpp b/src/tests/script.cpp
index e5885ee..9f1be63 100644
--- a/src/tests/script.cpp
+++ b/src/tests/script.cpp
@@ -27,8 +27,12 @@
#include <stout/check.hpp>
#include <stout/os.hpp>
#include <stout/path.hpp>
+#include <stout/protobuf.hpp>
+#include <stout/stringify.hpp>
#include <stout/strings.hpp>
+#include "mesos/mesos.hpp"
+
#include "tests/environment.hpp"
#include "tests/flags.hpp"
#include "tests/mesos.hpp"
@@ -114,12 +118,12 @@ void execute(const string& script)
os::setenv("MESOS_AUTHENTICATE", "true");
// Create test credentials.
- const std::string& credentialsPath =
- path::join(directory.get(), "credentials");
-
- const std::string& credentials =
+ const string& credentials =
DEFAULT_CREDENTIAL.principal() + " " + DEFAULT_CREDENTIAL.secret();
+ const string& credentialsPath =
+ path::join(directory.get(), "credentials");
+
CHECK_SOME(os::write(credentialsPath, credentials))
<< "Failed to write credentials to '" << credentialsPath << "'";
@@ -129,6 +133,25 @@ void execute(const string& script)
os::setenv("DEFAULT_PRINCIPAL", DEFAULT_CREDENTIAL.principal());
os::setenv("DEFAULT_SECRET", DEFAULT_CREDENTIAL.secret());
+ // Create test ACLs.
+ ACLs acls;
+ acls.set_permissive(false);
+
+ mesos::ACL::RunTasks* run = acls.add_run_tasks();
+ run->mutable_principals()->add_values(DEFAULT_CREDENTIAL.principal());
+ run->mutable_users()->add_values(os::user());
+
+ mesos::ACL::ReceiveOffers* offer = acls.add_receive_offers();
+ offer->mutable_principals()->add_values(DEFAULT_CREDENTIAL.principal());
+ offer->mutable_roles()->add_values("*");
+
+ const string& aclsPath = path::join(directory.get(), "acls");
+
+ CHECK_SOME(os::write(aclsPath, stringify(JSON::Protobuf(acls))))
+ << "Failed to write ACLs to '" << aclsPath << "'";
+
+ os::setenv("MESOS_ACLS", "file://" + aclsPath);
+
// Now execute the script.
execl(path.get().c_str(), path.get().c_str(), (char*) NULL);
http://git-wip-us.apache.org/repos/asf/mesos/blob/bdb30b90/src/tests/test_framework_test.sh
----------------------------------------------------------------------
diff --git a/src/tests/test_framework_test.sh b/src/tests/test_framework_test.sh
index a521b47..277245d 100755
--- a/src/tests/test_framework_test.sh
+++ b/src/tests/test_framework_test.sh
@@ -1,7 +1,5 @@
#!/usr/bin/env bash
-set -x
-
# Expecting MESOS_SOURCE_DIR and MESOS_BUILD_DIR to be in environment.
env | grep MESOS_SOURCE_DIR >/dev/null