knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pzamp...@apache.org
Subject knox git commit: KNOX-1267 - Add support for Ranger-related service discovery with HTTPS configurations
Date Mon, 23 Apr 2018 16:41:12 GMT
Repository: knox
Updated Branches:
  refs/heads/master 5d2ed18d4 -> e0fea744d


KNOX-1267 - Add support for Ranger-related service discovery with HTTPS configurations


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

Branch: refs/heads/master
Commit: e0fea744d68ff004c2b258b8a7263311bced2531
Parents: 5d2ed18
Author: Phil Zampino <pzampino@apache.org>
Authored: Mon Apr 23 12:23:44 2018 -0400
Committer: Phil Zampino <pzampino@apache.org>
Committed: Mon Apr 23 12:24:46 2018 -0400

----------------------------------------------------------------------
 .../ambari-service-discovery-url-mappings.xml   | 56 +++++++++++++--
 .../AmbariDynamicServiceURLCreatorTest.java     | 71 ++++++++++++++++----
 2 files changed, 111 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/e0fea744/gateway-discovery-ambari/src/main/resources/ambari-service-discovery-url-mappings.xml
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/resources/ambari-service-discovery-url-mappings.xml
b/gateway-discovery-ambari/src/main/resources/ambari-service-discovery-url-mappings.xml
index 213f531..92abb66 100644
--- a/gateway-discovery-ambari/src/main/resources/ambari-service-discovery-url-mappings.xml
+++ b/gateway-discovery-ambari/src/main/resources/ambari-service-discovery-url-mappings.xml
@@ -386,30 +386,78 @@
     </service>
 
     <service name="RANGER">
-        <url-pattern>http://{HOST}:{PORT}</url-pattern>
+        <url-pattern>{SCHEME}://{HOST}:{PORT}</url-pattern>
         <properties>
             <property name="HOST">
                 <component>RANGER_ADMIN</component>
                 <hostname/>
             </property>
-            <property name="PORT">
+            <property name="SSL">
+                <component>RANGER_ADMIN</component>
+                <config-property>ranger.service.https.attrib.ssl.enabled</config-property>
+            </property>
+            <property name="HTTPS_PORT">
+                <component>RANGER_ADMIN</component>
+                <config-property>ranger.service.https.port</config-property>
+            </property>
+            <property name="HTTP_PORT">
                 <component>RANGER_ADMIN</component>
                 <config-property>ranger.service.http.port</config-property>
             </property>
+            <property name="SCHEME">
+                <config-property>
+                    <if property="SSL" value="true">
+                        <then>https</then>
+                        <else>http</else>
+                    </if>
+                </config-property>
+            </property>
+            <property name="PORT">
+                <config-property>
+                    <if property="SSL" value="true">
+                        <then>HTTPS_PORT</then>
+                        <else>HTTP_PORT</else>
+                    </if>
+                </config-property>
+            </property>
         </properties>
     </service>
 
     <service name="RANGERUI">
-        <url-pattern>http://{HOST}:{PORT}</url-pattern>
+        <url-pattern>{SCHEME}://{HOST}:{PORT}</url-pattern>
         <properties>
             <property name="HOST">
                 <component>RANGER_ADMIN</component>
                 <hostname/>
             </property>
-            <property name="PORT">
+            <property name="SSL">
+                <component>RANGER_ADMIN</component>
+                <config-property>ranger.service.https.attrib.ssl.enabled</config-property>
+            </property>
+            <property name="HTTPS_PORT">
+                <component>RANGER_ADMIN</component>
+                <config-property>ranger.service.https.port</config-property>
+            </property>
+            <property name="HTTP_PORT">
                 <component>RANGER_ADMIN</component>
                 <config-property>ranger.service.http.port</config-property>
             </property>
+            <property name="SCHEME">
+                <config-property>
+                    <if property="SSL" value="true">
+                        <then>https</then>
+                        <else>http</else>
+                    </if>
+                </config-property>
+            </property>
+            <property name="PORT">
+                <config-property>
+                    <if property="SSL" value="true">
+                        <then>HTTPS_PORT</then>
+                        <else>HTTP_PORT</else>
+                    </if>
+                </config-property>
+            </property>
         </properties>
     </service>
 

http://git-wip-us.apache.org/repos/asf/knox/blob/e0fea744/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java
b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java
index 2eb706f..03612c1 100644
--- a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java
+++ b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java
@@ -882,10 +882,10 @@ public class AmbariDynamicServiceURLCreatorTest {
         final String HTTPS_PORT = "8989";
 
         final String[] HOSTNAMES = {"host1", "host4"};
-        final List<String> atlastServerHosts = Arrays.asList(HOSTNAMES);
+        final List<String> atlasServerHosts = Arrays.asList(HOSTNAMES);
 
         AmbariComponent atlasServer = EasyMock.createNiceMock(AmbariComponent.class);
-        EasyMock.expect(atlasServer.getHostNames()).andReturn(atlastServerHosts).anyTimes();
+        EasyMock.expect(atlasServer.getHostNames()).andReturn(atlasServerHosts).anyTimes();
         EasyMock.expect(atlasServer.getConfigProperty("atlas.enableTLS")).andReturn("false").anyTimes();
         EasyMock.expect(atlasServer.getConfigProperty("atlas.server.http.port")).andReturn(HTTP_PORT).anyTimes();
         EasyMock.expect(atlasServer.getConfigProperty("atlas.server.https.port")).andReturn(HTTPS_PORT).anyTimes();
@@ -901,7 +901,7 @@ public class AmbariDynamicServiceURLCreatorTest {
         validateServiceURLs(urls, HOSTNAMES, "http", HTTP_PORT, null);
 
         EasyMock.reset(atlasServer);
-        EasyMock.expect(atlasServer.getHostNames()).andReturn(atlastServerHosts).anyTimes();
+        EasyMock.expect(atlasServer.getHostNames()).andReturn(atlasServerHosts).anyTimes();
         EasyMock.expect(atlasServer.getConfigProperty("atlas.enableTLS")).andReturn("true").anyTimes();
         EasyMock.expect(atlasServer.getConfigProperty("atlas.server.http.port")).andReturn(HTTP_PORT).anyTimes();
         EasyMock.expect(atlasServer.getConfigProperty("atlas.server.https.port")).andReturn(HTTPS_PORT).anyTimes();
@@ -914,15 +914,62 @@ public class AmbariDynamicServiceURLCreatorTest {
 
 
     @Test
+    public void testRangerURL() throws Exception {
+        doTestRangerURLs("RANGER");
+    }
+
+
+    @Test
+    public void testRangerUIURL() throws Exception {
+        doTestRangerURLs("RANGERUI");
+    }
+
+
+    private void doTestRangerURLs(String serviceName) throws Exception {
+        final String HTTP_PORT = "6080";
+        final String HTTPS_PORT = "6182";
+
+        final String[] HOSTNAMES = {"host1", "host3"};
+        final List<String> rangerServerHosts = Arrays.asList(HOSTNAMES);
+
+        AmbariComponent rangerAdmin = EasyMock.createNiceMock(AmbariComponent.class);
+        EasyMock.expect(rangerAdmin.getHostNames()).andReturn(rangerServerHosts).anyTimes();
+        EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.https.attrib.ssl.enabled")).andReturn("false").anyTimes();
+        EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.http.port")).andReturn(HTTP_PORT).anyTimes();
+        EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.https.port")).andReturn(HTTPS_PORT).anyTimes();
+        EasyMock.replay(rangerAdmin);
+
+        AmbariCluster cluster = EasyMock.createNiceMock(AmbariCluster.class);
+        EasyMock.expect(cluster.getComponent("RANGER_ADMIN")).andReturn(rangerAdmin).anyTimes();
+        EasyMock.replay(cluster);
+
+        AmbariDynamicServiceURLCreator builder = newURLCreator(cluster, null);
+
+        // Run the test
+        validateServiceURLs(builder.create(serviceName, null), HOSTNAMES, "http", HTTP_PORT,
null);
+
+        EasyMock.reset(rangerAdmin);
+        EasyMock.expect(rangerAdmin.getHostNames()).andReturn(rangerServerHosts).anyTimes();
+        EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.https.attrib.ssl.enabled")).andReturn("true").anyTimes();
+        EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.http.port")).andReturn(HTTP_PORT).anyTimes();
+        EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.https.port")).andReturn(HTTPS_PORT).anyTimes();
+        EasyMock.replay(rangerAdmin);
+
+        // Run the test
+        validateServiceURLs(builder.create(serviceName, null), HOSTNAMES, "https", HTTPS_PORT,
null);
+    }
+
+
+    @Test
     public void testZeppelinURL() throws Exception {
         final String HTTP_PORT = "8787";
         final String HTTPS_PORT = "8989";
 
         final String[] HOSTNAMES = {"host1", "host4"};
-        final List<String> atlastServerHosts = Arrays.asList(HOSTNAMES);
+        final List<String> zeppelingServerHosts = Arrays.asList(HOSTNAMES);
 
         AmbariComponent zeppelinMaster = EasyMock.createNiceMock(AmbariComponent.class);
-        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(atlastServerHosts).anyTimes();
+        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(zeppelingServerHosts).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.ssl")).andReturn("false").anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.port")).andReturn(HTTP_PORT).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.ssl.port")).andReturn(HTTPS_PORT).anyTimes();
@@ -938,7 +985,7 @@ public class AmbariDynamicServiceURLCreatorTest {
         validateServiceURLs(builder.create("ZEPPELIN", null), HOSTNAMES, "http", HTTP_PORT,
null);
 
         EasyMock.reset(zeppelinMaster);
-        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(atlastServerHosts).anyTimes();
+        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(zeppelingServerHosts).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.ssl")).andReturn("true").anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.port")).andReturn(HTTP_PORT).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.ssl.port")).andReturn(HTTPS_PORT).anyTimes();
@@ -955,10 +1002,10 @@ public class AmbariDynamicServiceURLCreatorTest {
         final String HTTPS_PORT = "8989";
 
         final String[] HOSTNAMES = {"host1", "host4"};
-        final List<String> atlastServerHosts = Arrays.asList(HOSTNAMES);
+        final List<String> zeppelinServerHosts = Arrays.asList(HOSTNAMES);
 
         AmbariComponent zeppelinMaster = EasyMock.createNiceMock(AmbariComponent.class);
-        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(atlastServerHosts).anyTimes();
+        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(zeppelinServerHosts).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.ssl")).andReturn("false").anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.port")).andReturn(HTTP_PORT).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.ssl.port")).andReturn(HTTPS_PORT).anyTimes();
@@ -974,7 +1021,7 @@ public class AmbariDynamicServiceURLCreatorTest {
         validateServiceURLs(builder.create("ZEPPELINUI", null), HOSTNAMES, "http", HTTP_PORT,
null);
 
         EasyMock.reset(zeppelinMaster);
-        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(atlastServerHosts).anyTimes();
+        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(zeppelinServerHosts).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.ssl")).andReturn("true").anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.port")).andReturn(HTTP_PORT).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.ssl.port")).andReturn(HTTPS_PORT).anyTimes();
@@ -991,10 +1038,10 @@ public class AmbariDynamicServiceURLCreatorTest {
         final String HTTPS_PORT = "8989";
 
         final String[] HOSTNAMES = {"host1", "host4"};
-        final List<String> atlastServerHosts = Arrays.asList(HOSTNAMES);
+        final List<String> zeppelinServerHosts = Arrays.asList(HOSTNAMES);
 
         AmbariComponent zeppelinMaster = EasyMock.createNiceMock(AmbariComponent.class);
-        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(atlastServerHosts).anyTimes();
+        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(zeppelinServerHosts).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.ssl")).andReturn("false").anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.port")).andReturn(HTTP_PORT).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.ssl.port")).andReturn(HTTPS_PORT).anyTimes();
@@ -1010,7 +1057,7 @@ public class AmbariDynamicServiceURLCreatorTest {
         validateServiceURLs(builder.create("ZEPPELINWS", null), HOSTNAMES, "ws", HTTP_PORT,
null);
 
         EasyMock.reset(zeppelinMaster);
-        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(atlastServerHosts).anyTimes();
+        EasyMock.expect(zeppelinMaster.getHostNames()).andReturn(zeppelinServerHosts).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.ssl")).andReturn("true").anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.port")).andReturn(HTTP_PORT).anyTimes();
         EasyMock.expect(zeppelinMaster.getConfigProperty("zeppelin.server.ssl.port")).andReturn(HTTPS_PORT).anyTimes();


Mime
View raw message