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-622 - Misconfigured providers should cause topology deployment to fail
Date Fri, 13 Nov 2015 20:08:08 GMT
Repository: knox
Updated Branches:
  refs/heads/master 99d7b8f73 -> 4124b556b


KNOX-622 - Misconfigured providers should cause topology deployment to fail

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

Branch: refs/heads/master
Commit: 4124b556b66c72f51208fac59fbcbccd2e3f26e8
Parents: 99d7b8f
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Fri Nov 13 15:07:54 2015 -0500
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Fri Nov 13 15:07:54 2015 -0500

----------------------------------------------------------------------
 .../hadoop/gateway/deploy/DeploymentException.java  |  4 ++++
 .../hadoop/gateway/deploy/DeploymentFactory.java    | 13 +++++++++++++
 .../gateway/deploy/DeploymentFactoryFuncTest.java   | 16 +++++++++-------
 3 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/4124b556/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentException.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentException.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentException.java
index ce7a132..1c4aa19 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentException.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentException.java
@@ -24,4 +24,8 @@ public class DeploymentException extends RuntimeException {
     super(message, e);
   }
 
+  public DeploymentException(String message) {
+    super(message);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/4124b556/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 e5d75d5..fd28b8e 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
@@ -515,6 +515,19 @@ public abstract class DeploymentFactory {
       }
     } else {
       contributor = getProviderContributor( role, name );
+      // Explicit configuration that is wrong should just fail
+      // rather than randomly select a provider. Implicit default
+      // providers can be selected when no name is provided.
+      if (name != null) {
+        if (contributor == null || !contributor.getRole().equals(role) ||
+            !contributor.getName().equals(name)) {
+          throw new DeploymentException(
+              "Failed to contribute provider. Role: " +
+              role + " Name: " + name + ". Please check the topology for" +
+              		" errors in name and role and that the provider is " +
+              		"on the classpath.");
+        }
+      }
     }
     return contributor;
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/4124b556/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 a23e675..fc28dba 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
@@ -109,8 +109,8 @@ public class DeploymentFactoryFuncTest {
     topology.addService( service );
 
     Provider provider = new Provider();
-    provider.setRole( "authentication" );
-    provider.setName( "generic" );
+    provider.setRole( "federation" );
+    provider.setName( "HeaderPreAuth" );
     provider.setEnabled( true );
     Param param = new Param();
     param.setName( "filter" );
@@ -132,11 +132,13 @@ public class DeploymentFactoryFuncTest {
     assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[1]/name", equalTo( "XForwardedHeaderFilter"
) ) );
     assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[1]/class", equalTo( "org.apache.hadoop.gateway.filter.XForwardedHeaderFilter"
) ) );
 
-    assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/role", equalTo( "authentication"
) ) );
-    assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/name", equalTo( "generic"
) ) );
-    assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/class", equalTo( "org.opensource.ExistingFilter"
) ) );
-    assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/param[1]/name", equalTo(
"test-param-name" ) ) );
-    assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/param[1]/value", equalTo(
"test-param-value" ) ) );
+    assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/role", equalTo( "federation"
) ) );
+    assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/name", equalTo( "HeaderPreAuth"
) ) );
+    assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/class", equalTo( "org.apache.hadoop.gateway.preauth.filter.HeaderPreAuthFederationFilter"
) ) );
+    assertThat( gateway, hasXPath( "/gateway/resource[1]/filter[2]/param[1]/name", equalTo(
"filter" ) ) );
+    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" ) ) );
     LOG_EXIT();
   }
 


Mime
View raw message