aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject incubator-aurora git commit: Adding UPDATE_COORDINATOR role access into pause/resume/abort RPCs
Date Fri, 13 Feb 2015 00:25:55 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 847f0da3c -> 530dad89a


Adding UPDATE_COORDINATOR role access into pause/resume/abort RPCs

Bugs closed: AURORA-1119

Reviewed at https://reviews.apache.org/r/30913/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/530dad89
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/530dad89
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/530dad89

Branch: refs/heads/master
Commit: 530dad89a37bdf730d1616144fecc47c9d2cfb3e
Parents: 847f0da
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Thu Feb 12 16:25:39 2015 -0800
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Thu Feb 12 16:25:39 2015 -0800

----------------------------------------------------------------------
 .../thrift/SchedulerThriftInterface.java        |  4 +-
 .../thrift/SchedulerThriftInterfaceTest.java    | 48 +++++++++++++++++---
 2 files changed, 45 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/530dad89/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
index 2a9d36a..7014d59 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -1476,7 +1476,9 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
     final IJobKey jobKey = JobKeys.assertValid(IJobKey.build(requireNonNull(mutableJobKey)));
     final SessionContext context;
     try {
-      context = sessionValidator.checkAuthenticated(session, ImmutableSet.of(jobKey.getRole()));
+      // TODO(maxim): pass a JobUpdateKey here instead of generating a fake one. AURORA-1093.
+      IJobUpdateKey updateKey = IJobUpdateKey.build(new JobUpdateKey().setJob(mutableJobKey));
+      context = authorizeJobUpdateAction(updateKey, session);
     } catch (AuthFailedException e) {
       return errorResponse(AUTH_FAILED, e);
     }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/530dad89/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index ee32949..491aa34 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -2956,8 +2956,19 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
   }
 
   @Test
-  public void testPauseJobUpdate() throws Exception {
+  public void testPauseJobUpdateByCoordinator() throws Exception {
+    expectAuth(UPDATE_COORDINATOR, true);
+    jobUpdateController.pause(JOB_KEY, USER);
+
+    control.replay();
+
+    assertResponse(OK, thrift.pauseJobUpdate(JOB_KEY.newBuilder(), SESSION));
+  }
+
+  @Test
+  public void testPauseJobUpdateByUser() throws Exception {
     expectAuth(ROLE, true);
+    expectAuth(UPDATE_COORDINATOR, false);
     jobUpdateController.pause(JOB_KEY, USER);
 
     control.replay();
@@ -2967,6 +2978,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testPauseJobUpdateFailsAuth() throws Exception {
+    expectAuth(UPDATE_COORDINATOR, false);
     expectAuth(ROLE, false);
 
     control.replay();
@@ -2976,7 +2988,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testPauseJobUpdateFailsInController() throws Exception {
-    expectAuth(ROLE, true);
+    expectAuth(UPDATE_COORDINATOR, true);
     jobUpdateController.pause(JOB_KEY, USER);
     expectLastCall().andThrow(new UpdateStateException("failed"));
 
@@ -2986,8 +2998,19 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
   }
 
   @Test
-  public void testResumeJobUpdate() throws Exception {
+  public void testResumeJobUpdateByCoordinator() throws Exception {
+    expectAuth(UPDATE_COORDINATOR, true);
+    jobUpdateController.resume(JOB_KEY, USER);
+
+    control.replay();
+
+    assertResponse(OK, thrift.resumeJobUpdate(JOB_KEY.newBuilder(), SESSION));
+  }
+
+  @Test
+  public void testResumeJobUpdateByUser() throws Exception {
     expectAuth(ROLE, true);
+    expectAuth(UPDATE_COORDINATOR, false);
     jobUpdateController.resume(JOB_KEY, USER);
 
     control.replay();
@@ -2997,6 +3020,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testResumeJobUpdateFailsAuth() throws Exception {
+    expectAuth(UPDATE_COORDINATOR, false);
     expectAuth(ROLE, false);
 
     control.replay();
@@ -3006,7 +3030,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testResumeJobUpdateFailsInController() throws Exception {
-    expectAuth(ROLE, true);
+    expectAuth(UPDATE_COORDINATOR, true);
     jobUpdateController.resume(JOB_KEY, USER);
     expectLastCall().andThrow(new UpdateStateException("failed"));
 
@@ -3016,8 +3040,19 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
   }
 
   @Test
-  public void testAbortJobUpdate() throws Exception {
+  public void testAbortJobUpdateByCoordinator() throws Exception {
+    expectAuth(UPDATE_COORDINATOR, true);
+    jobUpdateController.abort(JOB_KEY, USER);
+
+    control.replay();
+
+    assertResponse(OK, thrift.abortJobUpdate(JOB_KEY.newBuilder(), SESSION));
+  }
+
+  @Test
+  public void testAbortJobUpdateByUser() throws Exception {
     expectAuth(ROLE, true);
+    expectAuth(UPDATE_COORDINATOR, false);
     jobUpdateController.abort(JOB_KEY, USER);
 
     control.replay();
@@ -3027,6 +3062,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testAbortJobUpdateFailsAuth() throws Exception {
+    expectAuth(UPDATE_COORDINATOR, false);
     expectAuth(ROLE, false);
 
     control.replay();
@@ -3036,7 +3072,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testAbortJobUpdateFailsInController() throws Exception {
-    expectAuth(ROLE, true);
+    expectAuth(UPDATE_COORDINATOR, true);
     jobUpdateController.abort(JOB_KEY, USER);
     expectLastCall().andThrow(new UpdateStateException("failed"));
 


Mime
View raw message