ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject ambari git commit: AMBARI-9514. Kerberos: Keytab regeneration not invoked when initiated via API (rlevas)
Date Sat, 07 Feb 2015 00:47:55 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 443a71abe -> acc29738a


AMBARI-9514. Kerberos: Keytab regeneration not invoked when initiated via API (rlevas)


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

Branch: refs/heads/trunk
Commit: acc29738a6525a8b70e3ccc76180ff2d8b750a9b
Parents: 443a71a
Author: Robert Levas <rlevas@hortonworks.com>
Authored: Fri Feb 6 19:47:36 2015 -0500
Committer: Robert Levas <rlevas@hortonworks.com>
Committed: Fri Feb 6 19:47:46 2015 -0500

----------------------------------------------------------------------
 .../server/controller/KerberosHelper.java       |  2 +-
 .../server/controller/KerberosHelperTest.java   | 61 ++++++++++++--------
 2 files changed, 37 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/acc29738/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
index 8341826..3606199 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
@@ -239,7 +239,7 @@ public class KerberosHelper {
               }
 
               if ("true".equalsIgnoreCase(value)) {
-                handle(cluster, getKerberosDetails(cluster), null, null, requestStageContainer,
new CreatePrincipalsAndKeytabsHandler());
+                requestStageContainer = handle(cluster, getKerberosDetails(cluster), null,
null, requestStageContainer, new CreatePrincipalsAndKeytabsHandler());
               }
               break;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/acc29738/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
index 5cf15d8..472178b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
@@ -318,8 +318,13 @@ public class KerberosHelperTest extends EasyMockSupport {
   }
 
   @Test
+  public void testRegenerateKeytabsValidateRequestStageContainer() throws Exception {
+    testRegenerateKeytabs(new KerberosCredential("principal", "password", "keytab"), false);
+  }
+
+  @Test
   public void testRegenerateKeytabs() throws Exception {
-    testRegenerateKeytabs(new KerberosCredential("principal", "password", "keytab"));
+    testRegenerateKeytabs(new KerberosCredential("principal", "password", "keytab"), false);
   }
 
   @Test
@@ -821,7 +826,7 @@ public class KerberosHelperTest extends EasyMockSupport {
     verifyAll();
   }
 
-  private void testRegenerateKeytabs(final KerberosCredential kerberosCredential) throws
Exception {
+  private void testRegenerateKeytabs(final KerberosCredential kerberosCredential, boolean
mockRequestStageContainer) throws Exception {
 
     KerberosHelper kerberosHelper = injector.getInstance(KerberosHelper.class);
 
@@ -1017,35 +1022,41 @@ public class KerberosHelperTest extends EasyMockSupport {
         })
         .anyTimes();
 
-    // This is a STRICT mock to help ensure that the end result is what we want.
-    final RequestStageContainer requestStageContainer = createStrictMock(RequestStageContainer.class);
-    // Create Principals Stage
-    expect(requestStageContainer.getLastStageId()).andReturn(-1L).anyTimes();
-    expect(requestStageContainer.getId()).andReturn(1L).once();
-    requestStageContainer.addStages(anyObject(List.class));
-    expectLastCall().once();
-    // Create Keytabs Stage
-    expect(requestStageContainer.getLastStageId()).andReturn(0L).anyTimes();
-    expect(requestStageContainer.getId()).andReturn(1L).once();
-    requestStageContainer.addStages(anyObject(List.class));
-    expectLastCall().once();
-    // Distribute Keytabs Stage
-    expect(requestStageContainer.getLastStageId()).andReturn(1L).anyTimes();
-    expect(requestStageContainer.getId()).andReturn(1L).once();
-    requestStageContainer.addStages(anyObject(List.class));
-    expectLastCall().once();
-    // Clean-up/Finalize Stage
-    expect(requestStageContainer.getLastStageId()).andReturn(3L).anyTimes();
-    expect(requestStageContainer.getId()).andReturn(1L).once();
-    requestStageContainer.addStages(anyObject(List.class));
-    expectLastCall().once();
+
+    final RequestStageContainer requestStageContainer;
+    if (mockRequestStageContainer) {
+      // This is a STRICT mock to help ensure that the end result is what we want.
+      requestStageContainer = createStrictMock(RequestStageContainer.class);
+      // Create Principals Stage
+      expect(requestStageContainer.getLastStageId()).andReturn(-1L).anyTimes();
+      expect(requestStageContainer.getId()).andReturn(1L).once();
+      requestStageContainer.addStages(anyObject(List.class));
+      expectLastCall().once();
+      // Create Keytabs Stage
+      expect(requestStageContainer.getLastStageId()).andReturn(0L).anyTimes();
+      expect(requestStageContainer.getId()).andReturn(1L).once();
+      requestStageContainer.addStages(anyObject(List.class));
+      expectLastCall().once();
+      // Distribute Keytabs Stage
+      expect(requestStageContainer.getLastStageId()).andReturn(1L).anyTimes();
+      expect(requestStageContainer.getId()).andReturn(1L).once();
+      requestStageContainer.addStages(anyObject(List.class));
+      expectLastCall().once();
+      // Clean-up/Finalize Stage
+      expect(requestStageContainer.getLastStageId()).andReturn(3L).anyTimes();
+      expect(requestStageContainer.getId()).andReturn(1L).once();
+      requestStageContainer.addStages(anyObject(List.class));
+      expectLastCall().once();
+    } else {
+      requestStageContainer = null;
+    }
 
     replayAll();
 
     // Needed by infrastructure
     metaInfo.init();
 
-    kerberosHelper.executeCustomOperations(cluster, Collections.singletonMap("regenerate_keytabs",
"true"), requestStageContainer);
+    Assert.assertNotNull(kerberosHelper.executeCustomOperations(cluster, Collections.singletonMap("regenerate_keytabs",
"true"), requestStageContainer));
 
     verifyAll();
   }


Mime
View raw message