You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by me...@apache.org on 2015/06/02 10:42:49 UTC
[3/3] mesos git commit: Updated test-frameworks to support principal
only credential.
Updated test-frameworks to support principal only credential.
Review: https://reviews.apache.org/r/33058
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0aab1bb0
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0aab1bb0
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0aab1bb0
Branch: refs/heads/master
Commit: 0aab1bb0f85fec362bc23afc5aff07bf8a7de217
Parents: 73e6186
Author: Till Toenshoff <to...@me.com>
Authored: Tue Jun 2 01:05:16 2015 -0700
Committer: Adam B <ad...@mesosphere.io>
Committed: Tue Jun 2 01:06:29 2015 -0700
----------------------------------------------------------------------
src/examples/java/TestFramework.java | 15 ++++++---------
src/examples/python/test_framework.py | 8 +++-----
src/examples/test_framework.cpp | 8 +++-----
3 files changed, 12 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/0aab1bb0/src/examples/java/TestFramework.java
----------------------------------------------------------------------
diff --git a/src/examples/java/TestFramework.java b/src/examples/java/TestFramework.java
index 9e95369..265005b 100644
--- a/src/examples/java/TestFramework.java
+++ b/src/examples/java/TestFramework.java
@@ -242,15 +242,12 @@ public class TestFramework {
System.exit(1);
}
- if (System.getenv("DEFAULT_SECRET") == null) {
- System.err.println("Expecting authentication secret in the environment");
- System.exit(1);
- }
+ Credential.Builder credentialBuilder = Credential.newBuilder()
+ .setPrincipal(System.getenv("DEFAULT_PRINCIPAL"));
- Credential credential = Credential.newBuilder()
- .setPrincipal(System.getenv("DEFAULT_PRINCIPAL"))
- .setSecret(ByteString.copyFrom(System.getenv("DEFAULT_SECRET").getBytes()))
- .build();
+ if (System.getenv("DEFAULT_SECRET") != null) {
+ credentialBuilder.setSecret(ByteString.copyFrom(System.getenv("DEFAULT_SECRET").getBytes()));
+ }
frameworkBuilder.setPrincipal(System.getenv("DEFAULT_PRINCIPAL"));
@@ -259,7 +256,7 @@ public class TestFramework {
frameworkBuilder.build(),
args[0],
implicitAcknowledgements,
- credential);
+ credentialBuilder.build());
} else {
frameworkBuilder.setPrincipal("test-framework-java");
http://git-wip-us.apache.org/repos/asf/mesos/blob/0aab1bb0/src/examples/python/test_framework.py
----------------------------------------------------------------------
diff --git a/src/examples/python/test_framework.py b/src/examples/python/test_framework.py
index a179df5..6af6d22 100755
--- a/src/examples/python/test_framework.py
+++ b/src/examples/python/test_framework.py
@@ -185,13 +185,11 @@ if __name__ == "__main__":
print "Expecting authentication principal in the environment"
sys.exit(1);
- if not os.getenv("DEFAULT_SECRET"):
- print "Expecting authentication secret in the environment"
- sys.exit(1);
-
credential = mesos_pb2.Credential()
credential.principal = os.getenv("DEFAULT_PRINCIPAL")
- credential.secret = os.getenv("DEFAULT_SECRET")
+
+ if os.getenv("DEFAULT_SECRET"):
+ credential.secret = os.getenv("DEFAULT_SECRET")
framework.principal = os.getenv("DEFAULT_PRINCIPAL")
http://git-wip-us.apache.org/repos/asf/mesos/blob/0aab1bb0/src/examples/test_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/test_framework.cpp b/src/examples/test_framework.cpp
index 9f4b53e..25f5f8c 100644
--- a/src/examples/test_framework.cpp
+++ b/src/examples/test_framework.cpp
@@ -261,13 +261,11 @@ int main(int argc, char** argv)
EXIT(1) << "Expecting authentication principal in the environment";
}
- if (!os::hasenv("DEFAULT_SECRET")) {
- EXIT(1) << "Expecting authentication secret in the environment";
- }
-
Credential credential;
credential.set_principal(getenv("DEFAULT_PRINCIPAL"));
- credential.set_secret(getenv("DEFAULT_SECRET"));
+ if (os::hasenv("DEFAULT_SECRET")) {
+ credential.set_secret(getenv("DEFAULT_SECRET"));
+ }
framework.set_principal(getenv("DEFAULT_PRINCIPAL"));