You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ad...@apache.org on 2017/06/19 13:14:02 UTC
ambari git commit: AMBARI-21242. Improve error message for Blueprints
deployment with incorrect credential type (Balazs Bence Sari via adoroszlai)
Repository: ambari
Updated Branches:
refs/heads/trunk cedb42881 -> e8e9781a8
AMBARI-21242. Improve error message for Blueprints deployment with incorrect credential type (Balazs Bence Sari via adoroszlai)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e8e9781a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e8e9781a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e8e9781a
Branch: refs/heads/trunk
Commit: e8e9781a8e98a5afdc31becc419e3792ba0a8515
Parents: cedb428
Author: Balazs Bence Sari <bs...@hortonworks.com>
Authored: Mon Jun 19 15:12:06 2017 +0200
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Mon Jun 19 15:12:06 2017 +0200
----------------------------------------------------------------------
.../controller/internal/ProvisionClusterRequest.java | 5 ++++-
.../internal/ProvisionClusterRequestTest.java | 13 ++++++++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e8e9781a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
index 2c95806..b053366 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
@@ -17,6 +17,7 @@
*/
package org.apache.ambari.server.controller.internal;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -223,7 +224,9 @@ public class ProvisionClusterRequest extends BaseClusterRequest {
}
CredentialStoreType type = Enums.getIfPresent(CredentialStoreType.class, typeString.toUpperCase()).orNull();
if (type == null) {
- throw new InvalidTopologyTemplateException("credential.type is invalid.");
+ throw new InvalidTopologyTemplateException(
+ String.format("credential.type [%s] is invalid. acceptable values: %s", typeString.toUpperCase(),
+ Arrays.toString(CredentialStoreType.values())));
}
credentialHashMap.put(alias, new Credential(alias, principal, key, type));
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e8e9781a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
index e0735be..69bb17c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
@@ -33,6 +33,7 @@ import static org.powermock.api.easymock.PowerMock.reset;
import java.lang.reflect.Field;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -43,6 +44,7 @@ import java.util.Map;
import java.util.Set;
import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.security.encryption.CredentialStoreType;
import org.apache.ambari.server.state.quicklinksprofile.QuickLinksProfileBuilderTest;
import org.apache.ambari.server.topology.Blueprint;
import org.apache.ambari.server.topology.BlueprintFactory;
@@ -52,7 +54,9 @@ import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
import org.apache.ambari.server.topology.TopologyRequest;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import com.google.common.collect.Sets;
@@ -72,6 +76,9 @@ public class ProvisionClusterRequestTest {
Collections.<String, Map<String, String>>emptyMap(),
Collections.<String, Map<String, Map<String, String>>>emptyMap());
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
@Before
public void setUp() throws Exception {
reset(blueprintFactory, blueprint, hostResourceProvider);
@@ -303,8 +310,12 @@ public class ProvisionClusterRequestTest {
}
- @Test(expected=InvalidTopologyTemplateException.class)
+ @Test
public void test_CreditentialsInvalidType() throws Exception {
+ expectedException.expect(InvalidTopologyTemplateException.class);
+ expectedException.expectMessage("credential.type [TESTTYPE] is invalid. acceptable values: " +
+ Arrays.toString(CredentialStoreType.values()));
+
Map<String, Object> properties = createBlueprintRequestProperties(CLUSTER_NAME, BLUEPRINT_NAME);
HashMap<String, String> credentialHashMap = new HashMap<>();
credentialHashMap.put("alias", "testAlias");