knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject knox git commit: KNOX-1034 - Make Default identity-assertion provider actually be the default
Date Sat, 04 Nov 2017 16:09:21 GMT
Repository: knox
Updated Branches:
  refs/heads/master 4d60e4149 -> 67ad3e38f


KNOX-1034 - Make Default identity-assertion provider actually be the default


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

Branch: refs/heads/master
Commit: 67ad3e38f3d415d4ed7f7ae76ed5e27d9cb33a3f
Parents: 4d60e41
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Sat Nov 4 12:08:43 2017 -0400
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Sat Nov 4 12:09:10 2017 -0400

----------------------------------------------------------------------
 .../gateway/deploy/DeploymentFactory.java       | 23 ++++++++++++++++++++
 .../deploy/DeploymentFactoryFuncTest.java       |  5 +++++
 2 files changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/67ad3e38/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
index 5c9922c..36cbb2a 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
@@ -239,11 +239,34 @@ public abstract class DeploymentFactory {
   // list add it.
   private static Map<String,List<ProviderDeploymentContributor>> selectContextProviders(
Topology topology ) {
     Map<String,List<ProviderDeploymentContributor>> providers = new LinkedHashMap<String,
List<ProviderDeploymentContributor>>();
+    addMissingDefaultProviders(topology);
     collectTopologyProviders( topology, providers );
     collectDefaultProviders( providers );
     return providers;
   }
 
+  private static void addMissingDefaultProviders(Topology topology) {
+    Collection<Provider> providers = topology.getProviders();
+    HashMap<String, String> providerMap = new HashMap<>();
+    for (Provider provider : providers) {
+      providerMap.put(provider.getRole(), provider.getName());
+    }
+    // first make sure that the required provider is available from the serviceloaders
+    // for some tests the number of providers are limited to the classpath of the module
+    // and exceptions will be thrown as topologies are deployed even though they will
+    // work fine at actual server runtime.
+    if (PROVIDER_CONTRIBUTOR_MAP.get("identity-assertion") != null) {
+      // check for required providers and add the defaults if missing
+      if (!providerMap.containsKey("identity-assertion")) {
+        Provider idassertion = new Provider();
+        idassertion.setRole("identity-assertion");
+        idassertion.setName("Default");
+        idassertion.setEnabled(true);
+        providers.add(idassertion);
+      }
+    }
+  }
+
   private static void collectTopologyProviders(
       Topology topology, Map<String, List<ProviderDeploymentContributor>> defaults
) {
     for( Provider provider : topology.getProviders() ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/67ad3e38/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
index 6f0924c..8d0d74f 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
@@ -139,6 +139,11 @@ public class DeploymentFactoryFuncTest {
     assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/param[1]/value", equalTo(
"org.opensource.ExistingFilter" ) ) );
     assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/param[2]/name", equalTo(
"test-param-name" ) ) );
     assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/param[2]/value", equalTo(
"test-param-value" ) ) );
+
+    // testing for the adding of missing identity assertion provider - since it isn't explicitly
added above
+    assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[4]/role", equalTo( "identity-assertion"
) ) );
+    assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[4]/name", equalTo( "Default"
) ) );
+
     LOG_EXIT();
   }
 


Mime
View raw message