ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject [1/2] ambari git commit: AMBARI-14072. Enforce granular role-based access control for cluster functions (rlevas)
Date Thu, 03 Dec 2015 23:47:12 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk e62e8eaa3 -> 19194e0b2


http://git-wip-us.apache.org/repos/asf/ambari/blob/19194e0b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
index 84de604..827f979 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
@@ -30,6 +30,8 @@ import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.security.TestAuthenticationFactory;
+import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.SecurityType;
 import org.apache.ambari.server.state.State;
@@ -48,6 +50,8 @@ import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -108,6 +112,9 @@ public class ClusterResourceProviderTest {
   public void tearDown() {
     reset(request, topologyManager, topologyFactory, topologyRequest, blueprintFactory, securityFactory,
       requestStatusResponse, blueprint);
+
+    // Clear the security context
+    SecurityContextHolder.getContext().setAuthentication(null);
   }
 
   private void replayAll() {
@@ -121,29 +128,13 @@ public class ClusterResourceProviderTest {
   }
 
   @Test
-  public void testCreateResource_blueprint() throws Exception {
-    Set<Map<String, Object>> requestProperties = createBlueprintRequestProperties(CLUSTER_NAME, BLUEPRINT_NAME);
-    Map<String, Object> properties = requestProperties.iterator().next();
-    Map<String, String> requestInfoProperties = new HashMap<String, String>();
-    requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{}");
-
-    // set expectations
-    expect(request.getProperties()).andReturn(requestProperties).anyTimes();
-    expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes();
-
-    expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class), anyBoolean())).andReturn(null)
-      .once();
-    expect(topologyFactory.createProvisionClusterRequest(properties, null)).andReturn(topologyRequest).once();
-    expect(topologyManager.provisionCluster(topologyRequest)).andReturn(requestStatusResponse).once();
-    expect(requestStatusResponse.getRequestId()).andReturn(5150L).anyTimes();
-
-    replayAll();
-    RequestStatus requestStatus = provider.createResources(request);
-    assertEquals(5150L, requestStatus.getRequestResource().getPropertyValue(PropertyHelper.getPropertyId("Requests", "id")));
-    assertEquals(Resource.Type.Request, requestStatus.getRequestResource().getType());
-    assertEquals("Accepted", requestStatus.getRequestResource().getPropertyValue(PropertyHelper.getPropertyId("Requests", "status")));
+  public void testCreateResource_blueprint_asAdministrator() throws Exception {
+    testCreateResource_blueprint(TestAuthenticationFactory.createAdministrator("admin"));
+  }
 
-    verifyAll();
+  @Test(expected = AuthorizationException.class)
+  public void testCreateResource_blueprint__NonAdministrator() throws Exception {
+    testCreateResource_blueprint(TestAuthenticationFactory.createClusterAdministrator("User1"));
   }
 
   @Test(expected = IllegalArgumentException.class)
@@ -169,6 +160,7 @@ public class ClusterResourceProviderTest {
     expect(requestStatusResponse.getRequestId()).andReturn(5150L).anyTimes();
 
     replayAll();
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
     RequestStatus requestStatus = provider.createResources(request);
   }
 
@@ -193,6 +185,7 @@ public class ClusterResourceProviderTest {
     expect(requestStatusResponse.getRequestId()).andReturn(5150L).anyTimes();
 
     replayAll();
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
     RequestStatus requestStatus = provider.createResources(request);
     assertEquals(5150L, requestStatus.getRequestResource().getPropertyValue(PropertyHelper.getPropertyId("Requests", "id")));
     assertEquals(Resource.Type.Request, requestStatus.getRequestResource().getType());
@@ -213,73 +206,18 @@ public class ClusterResourceProviderTest {
       ("test"));
 
     replayAll();
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
     provider.createResources(request);
   }
 
   @Test
-  public void testCreateResources() throws Exception{
-    Resource.Type type = Resource.Type.Cluster;
-
-    AmbariManagementController managementController = createMock(AmbariManagementController.class);
-    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
-
-    managementController.createCluster(
-        AbstractResourceProviderTest.Matcher.getClusterRequest(null, "Cluster100", "HDP-0.1", null));
-    managementController.createCluster(
-        AbstractResourceProviderTest.Matcher.getClusterRequest(99L, null, "HDP-0.1", null));
-
-    // replay
-    replay(managementController, response);
-
-    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
-        type,
-        PropertyHelper.getPropertyIds(type),
-        PropertyHelper.getKeyPropertyIds(type),
-        managementController);
-
-    AbstractResourceProviderTest.TestObserver observer = new AbstractResourceProviderTest.TestObserver();
-
-    ((ObservableResourceProvider)provider).addObserver(observer);
-
-    // add the property map to a set for the request.  add more maps for multiple creates
-    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
-
-    // Cluster 1: create a map of properties for the request
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
-
-    // add the cluster name to the properties map
-    properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100");
-
-    // add the version to the properties map
-    properties.put(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, "HDP-0.1");
-
-    propertySet.add(properties);
-
-    // Cluster 2: create a map of properties for the request
-    properties = new LinkedHashMap<String, Object>();
-
-    // add the cluster id to the properties map
-    properties.put(ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID, 99L);
-
-    // add the version to the properties map
-    properties.put(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, "HDP-0.1");
-
-    propertySet.add(properties);
-
-    // create the request
-    Request request = PropertyHelper.getCreateRequest(propertySet, null);
-
-    provider.createResources(request);
-
-    ResourceProviderEvent lastEvent = observer.getLastEvent();
-    Assert.assertNotNull(lastEvent);
-    Assert.assertEquals(Resource.Type.Cluster, lastEvent.getResourceType());
-    Assert.assertEquals(ResourceProviderEvent.Type.Create, lastEvent.getType());
-    Assert.assertEquals(request, lastEvent.getRequest());
-    Assert.assertNull(lastEvent.getPredicate());
+  public void testCreateResourcesAsAdministrator() throws Exception{
+    testCreateResources(TestAuthenticationFactory.createAdministrator("admin"));
+  }
 
-    // verify
-    verify(managementController, response);
+  @Test(expected = AuthorizationException.class)
+  public void testCreateResourcesAsNonAdministrator() throws Exception{
+    testCreateResources(TestAuthenticationFactory.createClusterAdministrator("User1"));
   }
 
   @Test
@@ -297,6 +235,8 @@ public class ClusterResourceProviderTest {
     // replay
     replay(managementController, response);
 
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
+
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
@@ -341,7 +281,16 @@ public class ClusterResourceProviderTest {
   }
 
   @Test
-  public void testGetResources() throws Exception{
+  public void testGetResourcesAsAdministrator() throws Exception{
+    testGetResources(TestAuthenticationFactory.createAdministrator("admin"));
+  }
+
+  @Test
+  public void testGetResourcesAsNonAdministrator() throws Exception{
+    testGetResources(TestAuthenticationFactory.createClusterAdministrator("User1"));
+  }
+
+  public void testGetResources(Authentication authentication) throws Exception{
     Resource.Type type = Resource.Type.Cluster;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
@@ -369,15 +318,11 @@ public class ClusterResourceProviderTest {
 
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
 
-    expect(clusters.checkPermission("Cluster100", true)).andReturn(true).anyTimes();
-    expect(clusters.checkPermission("Cluster101", true)).andReturn(true).anyTimes();
-    expect(clusters.checkPermission("Cluster102", true)).andReturn(true).anyTimes();
-    expect(clusters.checkPermission("Cluster103", true)).andReturn(true).anyTimes();
-    expect(clusters.checkPermission("Cluster104", true)).andReturn(false).anyTimes();
-
     // replay
     replay(managementController, clusters);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
@@ -395,7 +340,7 @@ public class ClusterResourceProviderTest {
     // get all ... no predicate
     Set<Resource> resources = provider.getResources(request, null);
 
-    Assert.assertEquals(4, resources.size());
+    Assert.assertEquals(5, resources.size());
     for (Resource resource : resources) {
       Long id = (Long) resource.getPropertyValue(ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID);
       String name = (String) resource.getPropertyValue(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID);
@@ -430,7 +375,181 @@ public class ClusterResourceProviderTest {
   }
 
   @Test
-  public void testUpdateResources() throws Exception{
+  public void testUpdateResourcesAsAdministrator() throws Exception{
+    testUpdateResources(TestAuthenticationFactory.createAdministrator("admin"));
+  }
+
+  @Test
+  public void testUpdateResourcesAsClusterAdministrator() throws Exception{
+    testUpdateResources(TestAuthenticationFactory.createClusterAdministrator("User1"));
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testUpdateResourcesAsServiceAdministrator() throws Exception {
+    testUpdateResources(TestAuthenticationFactory.createServiceAdministrator("User10"));
+  }
+
+  @Test
+  public void testUpdateWithConfigurationAsAdministrator() throws Exception {
+    testUpdateWithConfiguration(TestAuthenticationFactory.createAdministrator("admin"));
+  }
+
+  @Test
+  public void testUpdateWithConfigurationAsClusterAdministrator() throws Exception {
+    testUpdateWithConfiguration(TestAuthenticationFactory.createClusterAdministrator("User1"));
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testUpdateWithConfigurationAsServiceAdministrator() throws Exception {
+    testUpdateWithConfiguration(TestAuthenticationFactory.createServiceAdministrator("User10"));
+  }
+
+  @Test
+  public void testDeleteResourcesAsAdministrator() throws Exception{
+    testDeleteResources(TestAuthenticationFactory.createAdministrator("admin"));
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testDeleteResourcesAsNonAdministrator() throws Exception{
+    testDeleteResources(TestAuthenticationFactory.createClusterAdministrator("User1"));
+  }
+
+  //todo: configuration properties are not being added to props
+  private Set<Map<String, Object>> createBlueprintRequestProperties(String clusterName, String blueprintName) {
+    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+
+    properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName);
+    properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName);
+    propertySet.add(properties);
+
+    Collection<Map<String, Object>> hostGroups = new ArrayList<Map<String, Object>>();
+    Map<String, Object> hostGroupProperties = new HashMap<String, Object>();
+    hostGroups.add(hostGroupProperties);
+    hostGroupProperties.put("name", "group1");
+    Collection<Map<String, String>> hostGroupHosts = new ArrayList<Map<String, String>>();
+    hostGroupProperties.put("hosts", hostGroupHosts);
+    Map<String, String> hostGroupHostProperties = new HashMap<String, String>();
+    hostGroupHostProperties.put("fqdn", "host.domain");
+    hostGroupHosts.add(hostGroupHostProperties);
+    properties.put("host_groups", hostGroups);
+
+    Map<String, String> mapGroupConfigProperties = new HashMap<String, String>();
+    mapGroupConfigProperties.put("myGroupProp", "awesomeValue");
+
+    // blueprint core-site cluster configuration properties
+    Map<String, String> blueprintCoreConfigProperties = new HashMap<String, String>();
+    blueprintCoreConfigProperties.put("property1", "value2");
+    blueprintCoreConfigProperties.put("new.property", "new.property.value");
+
+    Map<String, String> blueprintGlobalConfigProperties = new HashMap<String, String>();
+    blueprintGlobalConfigProperties.put("hive_database", "New MySQL Database");
+
+    Map<String, String> oozieEnvConfigProperties = new HashMap<String, String>();
+    oozieEnvConfigProperties.put("property1","value2");
+    Map<String, String> hbaseEnvConfigProperties = new HashMap<String, String>();
+    hbaseEnvConfigProperties.put("property1","value2");
+    Map<String, String> falconEnvConfigProperties = new HashMap<String, String>();
+    falconEnvConfigProperties.put("property1","value2");
+
+    return propertySet;
+  }
+
+  private void testCreateResource_blueprint(Authentication authentication) throws Exception {
+    Set<Map<String, Object>> requestProperties = createBlueprintRequestProperties(CLUSTER_NAME, BLUEPRINT_NAME);
+    Map<String, Object> properties = requestProperties.iterator().next();
+    Map<String, String> requestInfoProperties = new HashMap<String, String>();
+    requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{}");
+
+    // set expectations
+    expect(request.getProperties()).andReturn(requestProperties).anyTimes();
+    expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes();
+
+    expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class), anyBoolean())).andReturn(null)
+        .once();
+    expect(topologyFactory.createProvisionClusterRequest(properties, null)).andReturn(topologyRequest).once();
+    expect(topologyManager.provisionCluster(topologyRequest)).andReturn(requestStatusResponse).once();
+    expect(requestStatusResponse.getRequestId()).andReturn(5150L).anyTimes();
+
+    replayAll();
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
+    RequestStatus requestStatus = provider.createResources(request);
+    assertEquals(5150L, requestStatus.getRequestResource().getPropertyValue(PropertyHelper.getPropertyId("Requests", "id")));
+    assertEquals(Resource.Type.Request, requestStatus.getRequestResource().getType());
+    assertEquals("Accepted", requestStatus.getRequestResource().getPropertyValue(PropertyHelper.getPropertyId("Requests", "status")));
+
+    verifyAll();
+  }
+
+  private void testCreateResources(Authentication authentication) throws Exception{
+    Resource.Type type = Resource.Type.Cluster;
+
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
+
+    managementController.createCluster(
+        AbstractResourceProviderTest.Matcher.getClusterRequest(null, "Cluster100", "HDP-0.1", null));
+    managementController.createCluster(
+        AbstractResourceProviderTest.Matcher.getClusterRequest(99L, null, "HDP-0.1", null));
+
+    // replay
+    replay(managementController, response);
+
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
+        type,
+        PropertyHelper.getPropertyIds(type),
+        PropertyHelper.getKeyPropertyIds(type),
+        managementController);
+
+    AbstractResourceProviderTest.TestObserver observer = new AbstractResourceProviderTest.TestObserver();
+
+    ((ObservableResourceProvider)provider).addObserver(observer);
+
+    // add the property map to a set for the request.  add more maps for multiple creates
+    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+
+    // Cluster 1: create a map of properties for the request
+    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+
+    // add the cluster name to the properties map
+    properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100");
+
+    // add the version to the properties map
+    properties.put(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, "HDP-0.1");
+
+    propertySet.add(properties);
+
+    // Cluster 2: create a map of properties for the request
+    properties = new LinkedHashMap<String, Object>();
+
+    // add the cluster id to the properties map
+    properties.put(ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID, 99L);
+
+    // add the version to the properties map
+    properties.put(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, "HDP-0.1");
+
+    propertySet.add(properties);
+
+    // create the request
+    Request request = PropertyHelper.getCreateRequest(propertySet, null);
+
+    provider.createResources(request);
+
+    ResourceProviderEvent lastEvent = observer.getLastEvent();
+    Assert.assertNotNull(lastEvent);
+    Assert.assertEquals(Resource.Type.Cluster, lastEvent.getResourceType());
+    Assert.assertEquals(ResourceProviderEvent.Type.Create, lastEvent.getType());
+    Assert.assertEquals(request, lastEvent.getRequest());
+    Assert.assertNull(lastEvent.getPredicate());
+
+    // verify
+    verify(managementController, response);
+  }
+
+  public void testUpdateResources(Authentication authentication) throws Exception{
     Resource.Type type = Resource.Type.Cluster;
 
     Clusters clusters = createMock(Clusters.class);
@@ -458,15 +577,11 @@ public class ClusterResourceProviderTest {
 
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
 
-    expect(clusters.checkPermission("Cluster102", false)).andReturn(true).anyTimes();
-    expect(clusters.checkPermission("Cluster102", true)).andReturn(true).anyTimes();
-    expect(clusters.checkPermission("Cluster103", false)).andReturn(true).anyTimes();
-    expect(clusters.checkPermission("Cluster103", true)).andReturn(true).anyTimes();
-    expect(clusters.checkPermission(null, false)).andReturn(true).anyTimes();
-
     // replay
     replay(managementController, response, clusters);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
@@ -505,8 +620,7 @@ public class ClusterResourceProviderTest {
     verify(managementController, response, clusters);
   }
 
-  @Test
-  public void testUpdateWithConfiguration() throws Exception {
+  public void testUpdateWithConfiguration(Authentication authentication) throws Exception {
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     Clusters clusters = createMock(Clusters.class);
     RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
@@ -525,12 +639,11 @@ public class ClusterResourceProviderTest {
 
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
 
-    expect(clusters.checkPermission("Cluster100", true)).andReturn(true).anyTimes();
-    expect(clusters.checkPermission("Cluster100", false)).andReturn(true).anyTimes();
-
     // replay
     replay(managementController, response, clusters);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     Map<String, Object> properties = new LinkedHashMap<String, Object>();
 
     properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -582,8 +695,7 @@ public class ClusterResourceProviderTest {
     verify(managementController, response, clusters);
   }
 
-  @Test
-  public void testDeleteResources() throws Exception{
+  public void testDeleteResources(Authentication authentication) throws Exception{
     Resource.Type type = Resource.Type.Cluster;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
@@ -598,12 +710,11 @@ public class ClusterResourceProviderTest {
 
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
 
-    expect(clusters.checkPermission("Cluster102", false)).andReturn(true).anyTimes();
-    expect(clusters.checkPermission(null, false)).andReturn(true).anyTimes();
-
     // replay
     replay(managementController, response, clusters);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
@@ -634,733 +745,4 @@ public class ClusterResourceProviderTest {
     // verify
     verify(managementController, response, clusters);
   }
-
-  //todo: What are these testing and where do they go?
-  //todo: these were added when the new security type property was added to enable/disable kerberos
-//  @Test
-//  public void testSetMissingConfigurationsOozieIncluded() throws Exception {
-//    EasyMockSupport mockSupport = new EasyMockSupport();
-//
-//    AmbariManagementController mockMgmtController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    ResourceProvider mockServiceProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockConfigGroupProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    AmbariManagementController mockManagementController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    StackServiceResponse mockStackServiceResponseOne =
-//      mockSupport.createMock(StackServiceResponse.class);
-//    StackServiceComponentResponse mockStackComponentResponse =
-//      mockSupport.createMock(StackServiceComponentResponse.class);
-//    AmbariMetaInfo mockAmbariMetaInfo =
-//      mockSupport.createMock(AmbariMetaInfo.class);
-//
-//    expect(mockStackComponentResponse.getComponentName()).andReturn("OOZIE_SERVER").atLeastOnce();
-//    expect(mockStackComponentResponse.getCardinality()).andReturn("1");
-//    expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
-//
-//
-//    expect(mockStackServiceResponseOne.getServiceName()).andReturn("OOZIE").atLeastOnce();
-//    expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
-//    expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
-//    expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
-//    expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//    expect(mockManagementController.getStackLevelConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//
-//    expect(mockAmbariMetaInfo.getComponentDependencies("HDP", "2.1", "OOZIE", "OOZIE_SERVER")).andReturn(Collections.<DependencyInfo>emptyList());
-//
-//    mockSupport.replayAll();
-//
-//
-//    ClusterResourceProvider.init(null, mockAmbariMetaInfo, null);
-//
-//    Stack stack =
-//      new Stack("HDP", "2.1", mockManagementController);
-//
-//    ClusterResourceProvider clusterResourceProvider =
-//      new TestClusterResourceProvider(mockMgmtController, mockServiceProvider,
-//        mockComponentProvider, mockHostProvider, mockHostComponentProvider, mockConfigGroupProvider);
-//
-//
-//    HostGroupEntity hostGroup = new HostGroupEntity();
-//    hostGroup.setComponents(Collections.<HostGroupComponentEntity>emptyList());
-//    HostGroupConfigEntity configEntity = new HostGroupConfigEntity();
-//    configEntity.setConfigData("");
-//
-//    hostGroup.setConfigurations(Collections.singletonList(configEntity));
-//    BaseBlueprintProcessor.HostGroupImpl hostGroupImpl =
-//      new BaseBlueprintProcessor.HostGroupImpl(hostGroup, stack, null);
-//    hostGroupImpl.addComponent("OOZIE_SERVER");
-//
-//    // add empty map for core-site, to simulate this configuration entry
-//    clusterResourceProvider.getClusterConfigurations().put("core-site", new HashMap<String, String>());
-//    clusterResourceProvider.getClusterConfigurations().put("oozie-env", new HashMap<String, String>());
-//    clusterResourceProvider.getClusterConfigurations().get("oozie-env").put("oozie_user", "oozie");
-//
-//    //clusterResourceProvider.setMissingConfigurations(Collections.singletonMap("host_group_one", hostGroupImpl));
-//
-//    Map<String, String> mapCoreSiteConfig =
-//      clusterResourceProvider.getClusterConfigurations().get("core-site");
-//
-//    assertNotNull("core-site map was null.", mapCoreSiteConfig);
-//    assertEquals("Incorrect number of entries in the core-site config map",
-//                 2, mapCoreSiteConfig.size());
-//    assertEquals("Incorrect value for proxy hosts",
-//                 "*", mapCoreSiteConfig.get("hadoop.proxyuser.oozie.hosts"));
-//    assertEquals("Incorrect value for proxy hosts",
-//      "users", mapCoreSiteConfig.get("hadoop.proxyuser.oozie.groups"));
-//
-//    mockSupport.verifyAll();
-//  }
-//
-//
-//  @Test
-//  public void testSetMissingConfigurationsFalconIncluded() throws Exception {
-//    EasyMockSupport mockSupport = new EasyMockSupport();
-//
-//    AmbariManagementController mockMgmtController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    ResourceProvider mockServiceProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockConfigGroupProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    AmbariManagementController mockManagementController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    StackServiceResponse mockStackServiceResponseOne =
-//      mockSupport.createMock(StackServiceResponse.class);
-//    StackServiceComponentResponse mockStackComponentResponse =
-//      mockSupport.createMock(StackServiceComponentResponse.class);
-//    AmbariMetaInfo mockAmbariMetaInfo =
-//      mockSupport.createMock(AmbariMetaInfo.class);
-//
-//    expect(mockStackComponentResponse.getComponentName()).andReturn("FALCON_SERVER").atLeastOnce();
-//    expect(mockStackComponentResponse.getCardinality()).andReturn("1");
-//    expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
-//
-//
-//    expect(mockStackServiceResponseOne.getServiceName()).andReturn("FALCON").atLeastOnce();
-//    expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
-//    expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
-//    expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
-//    expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//    expect(mockManagementController.getStackLevelConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//
-//    expect(mockAmbariMetaInfo.getComponentDependencies("HDP", "2.1", "FALCON", "FALCON_SERVER")).andReturn(Collections.<DependencyInfo>emptyList());
-//
-//    mockSupport.replayAll();
-//
-//    ClusterResourceProvider.init(null, mockAmbariMetaInfo, null);
-//
-//    Stack stack =
-//      new Stack("HDP", "2.1", mockManagementController);
-//
-//    ClusterResourceProvider clusterResourceProvider =
-//      new TestClusterResourceProvider(mockMgmtController, mockServiceProvider,
-//        mockComponentProvider, mockHostProvider, mockHostComponentProvider, mockConfigGroupProvider);
-//
-//    HostGroupEntity hostGroup = new HostGroupEntity();
-//    hostGroup.setComponents(Collections.<HostGroupComponentEntity>emptyList());
-//    HostGroupConfigEntity configEntity = new HostGroupConfigEntity();
-//    configEntity.setConfigData("");
-//
-//    hostGroup.setConfigurations(Collections.singletonList(configEntity));
-//    BaseBlueprintProcessor.HostGroupImpl hostGroupImpl =
-//      new BaseBlueprintProcessor.HostGroupImpl(hostGroup, stack, null);
-//    hostGroupImpl.addComponent("FALCON_SERVER");
-//
-//    // add empty map for core-site, to simulate this configuration entry
-//    clusterResourceProvider.getClusterConfigurations().put("core-site", new HashMap<String, String>());
-//    clusterResourceProvider.getClusterConfigurations().put("falcon-env", new HashMap<String, String>());
-//    clusterResourceProvider.getClusterConfigurations().get("falcon-env").put("falcon_user", "falcon");
-//
-//    //clusterResourceProvider.setMissingConfigurations(Collections.singletonMap("host_group_one", hostGroupImpl));
-//
-//    Map<String, String> mapCoreSiteConfig =
-//      clusterResourceProvider.getClusterConfigurations().get("core-site");
-//
-//    assertNotNull("core-site map was null.", mapCoreSiteConfig);
-//    assertEquals("Incorrect number of entries in the core-site config map",
-//      2, mapCoreSiteConfig.size());
-//    assertEquals("Incorrect value for proxy hosts",
-//      "*", mapCoreSiteConfig.get("hadoop.proxyuser.falcon.hosts"));
-//    assertEquals("Incorrect value for proxy hosts",
-//      "users", mapCoreSiteConfig.get("hadoop.proxyuser.falcon.groups"));
-//
-//    mockSupport.verifyAll();
-//  }
-//
-//
-//  @Test
-//  public void testSetMissingConfigurationsOozieNotIncluded() throws Exception {
-//    EasyMockSupport mockSupport = new EasyMockSupport();
-//
-//    AmbariManagementController mockMgmtController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    ResourceProvider mockServiceProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockConfigGroupProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    AmbariManagementController mockManagementController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    StackServiceResponse mockStackServiceResponseOne =
-//      mockSupport.createMock(StackServiceResponse.class);
-//    StackServiceComponentResponse mockStackComponentResponse =
-//      mockSupport.createMock(StackServiceComponentResponse.class);
-//    AmbariMetaInfo mockAmbariMetaInfo =
-//      mockSupport.createMock(AmbariMetaInfo.class);
-//
-//    expect(mockStackComponentResponse.getComponentName()).andReturn("OOZIE_SERVER");
-//    expect(mockStackComponentResponse.getCardinality()).andReturn("1");
-//    expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
-//
-//
-//    expect(mockStackServiceResponseOne.getServiceName()).andReturn("OOZIE").atLeastOnce();
-//    expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
-//    expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
-//    expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
-//    expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//    expect(mockManagementController.getStackLevelConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//
-//    expect(mockAmbariMetaInfo.getComponentDependencies("HDP", "2.1", "OOZIE", "OOZIE_SERVER")).andReturn(Collections.<DependencyInfo>emptyList());
-//
-//    mockSupport.replayAll();
-//
-//    ClusterResourceProvider.init(null, mockAmbariMetaInfo, null);
-//
-//    Stack stack =
-//      new Stack("HDP", "2.1", mockManagementController);
-//
-//    ClusterResourceProvider clusterResourceProvider =
-//      new TestClusterResourceProvider(mockMgmtController, mockServiceProvider,
-//        mockComponentProvider, mockHostProvider, mockHostComponentProvider, mockConfigGroupProvider);
-//
-//
-//    HostGroupEntity hostGroup = new HostGroupEntity();
-//    hostGroup.setComponents(Collections.<HostGroupComponentEntity>emptyList());
-//    HostGroupConfigEntity configEntity = new HostGroupConfigEntity();
-//    configEntity.setConfigData("");
-//
-//    hostGroup.setConfigurations(Collections.singletonList(configEntity));
-//    BaseBlueprintProcessor.HostGroupImpl hostGroupImpl =
-//      new BaseBlueprintProcessor.HostGroupImpl(hostGroup, stack, null);
-//    hostGroupImpl.addComponent("COMPONENT_ONE");
-//
-//    // add empty map for core-site, to simulate this configuration entry
-//    clusterResourceProvider.getClusterConfigurations().put("core-site", new HashMap<String, String>());
-//
-//    //clusterResourceProvider.setMissingConfigurations(Collections.singletonMap("host_group_one", hostGroupImpl));
-//
-//    Map<String, String> mapCoreSiteConfig =
-//      clusterResourceProvider.getClusterConfigurations().get("core-site");
-//
-//    assertNotNull("core-site map was null.", mapCoreSiteConfig);
-//    assertEquals("Incorrect number of entries in the core-site config map",
-//                0, mapCoreSiteConfig.size());
-//
-//    mockSupport.verifyAll();
-//
-//  }
-//
-//
-//  @Test
-//  public void testSetMissingConfigurationsFalconNotIncluded() throws Exception {
-//    EasyMockSupport mockSupport = new EasyMockSupport();
-//
-//    AmbariManagementController mockMgmtController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    ResourceProvider mockServiceProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockConfigGroupProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    AmbariManagementController mockManagementController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    StackServiceResponse mockStackServiceResponseOne =
-//      mockSupport.createMock(StackServiceResponse.class);
-//    StackServiceComponentResponse mockStackComponentResponse =
-//      mockSupport.createMock(StackServiceComponentResponse.class);
-//    AmbariMetaInfo mockAmbariMetaInfo =
-//      mockSupport.createMock(AmbariMetaInfo.class);
-//
-//    expect(mockStackComponentResponse.getComponentName()).andReturn("FALCON_SERVER");
-//    expect(mockStackComponentResponse.getCardinality()).andReturn("1");
-//    expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
-//
-//    expect(mockStackServiceResponseOne.getServiceName()).andReturn("FALCON").atLeastOnce();
-//    expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
-//
-//    expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
-//    expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
-//    expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//    expect(mockManagementController.getStackLevelConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//
-//    expect(mockAmbariMetaInfo.getComponentDependencies("HDP", "2.1", "FALCON", "FALCON_SERVER")).andReturn(Collections.<DependencyInfo>emptyList());
-//
-//    mockSupport.replayAll();
-//
-//    ClusterResourceProvider.init(null, mockAmbariMetaInfo, null);
-//
-//    Stack stack =
-//      new Stack("HDP", "2.1", mockManagementController);
-//
-//    ClusterResourceProvider clusterResourceProvider =
-//      new TestClusterResourceProvider(mockMgmtController, mockServiceProvider,
-//        mockComponentProvider, mockHostProvider, mockHostComponentProvider, mockConfigGroupProvider);
-//
-//    HostGroupEntity hostGroup = new HostGroupEntity();
-//    hostGroup.setComponents(Collections.<HostGroupComponentEntity>emptyList());
-//    HostGroupConfigEntity configEntity = new HostGroupConfigEntity();
-//    configEntity.setConfigData("");
-//
-//    hostGroup.setConfigurations(Collections.singletonList(configEntity));
-//    BaseBlueprintProcessor.HostGroupImpl hostGroupImpl =
-//      new BaseBlueprintProcessor.HostGroupImpl(hostGroup, stack, null);
-//    // blueprint request will not include a reference to FALCON_SERVER
-//    hostGroupImpl.addComponent("COMPONENT_ONE");
-//
-//    // add empty map for core-site, to simulate this configuration entry
-//    clusterResourceProvider.getClusterConfigurations().put("core-site", new HashMap<String, String>());
-//
-//    //clusterResourceProvider.setMissingConfigurations(Collections.singletonMap("host_group_one", hostGroupImpl));
-//
-//    Map<String, String> mapCoreSiteConfig =
-//      clusterResourceProvider.getClusterConfigurations().get("core-site");
-//
-//    assertNotNull("core-site map was null.", mapCoreSiteConfig);
-//    assertEquals("Incorrect number of entries in the core-site config map",
-//      0, mapCoreSiteConfig.size());
-//
-//    mockSupport.verifyAll();
-//
-//  }
-//
-//
-//  @Test
-//  public void testSetMissingConfigurationsHiveNotIncluded() throws Exception {
-//    EasyMockSupport mockSupport = new EasyMockSupport();
-//
-//    AmbariManagementController mockMgmtController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    ResourceProvider mockServiceProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockConfigGroupProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    AmbariManagementController mockManagementController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    StackServiceResponse mockStackServiceResponseOne =
-//      mockSupport.createMock(StackServiceResponse.class);
-//    StackServiceComponentResponse mockStackComponentResponse =
-//      mockSupport.createMock(StackServiceComponentResponse.class);
-//    AmbariMetaInfo mockAmbariMetaInfo =
-//      mockSupport.createMock(AmbariMetaInfo.class);
-//
-//    expect(mockStackComponentResponse.getComponentName()).andReturn("HIVE_SERVER");
-//    expect(mockStackComponentResponse.getCardinality()).andReturn("1");
-//    expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
-//
-//    expect(mockStackServiceResponseOne.getServiceName()).andReturn("HIVE").atLeastOnce();
-//    expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
-//    expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
-//    expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
-//    expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//    expect(mockManagementController.getStackLevelConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//
-//    expect(mockAmbariMetaInfo.getComponentDependencies("HDP", "2.1", "HIVE", "HIVE_SERVER")).andReturn(Collections.<DependencyInfo>emptyList());
-//
-//    mockSupport.replayAll();
-//
-//    ClusterResourceProvider.init(null, mockAmbariMetaInfo, null);
-//
-//    Stack stack =
-//      new Stack("HDP", "2.1", mockManagementController);
-//
-//    ClusterResourceProvider clusterResourceProvider =
-//      new TestClusterResourceProvider(mockMgmtController, mockServiceProvider,
-//        mockComponentProvider, mockHostProvider, mockHostComponentProvider, mockConfigGroupProvider);
-//
-//    HostGroupEntity hostGroup = new HostGroupEntity();
-//    hostGroup.setComponents(Collections.<HostGroupComponentEntity>emptyList());
-//    HostGroupConfigEntity configEntity = new HostGroupConfigEntity();
-//    configEntity.setConfigData("");
-//
-//    hostGroup.setConfigurations(Collections.singletonList(configEntity));
-//    BaseBlueprintProcessor.HostGroupImpl hostGroupImpl =
-//      new BaseBlueprintProcessor.HostGroupImpl(hostGroup, stack, null);
-//    // blueprint request will not include a reference to a HIVE component
-//    hostGroupImpl.addComponent("COMPONENT_ONE");
-//
-//    // add empty map for core-site, to simulate this configuration entry
-//    clusterResourceProvider.getClusterConfigurations().put("core-site", new HashMap<String, String>());
-//
-//    //clusterResourceProvider.setMissingConfigurations(Collections.singletonMap("host_group_one", hostGroupImpl));
-//
-//    Map<String, String> mapCoreSiteConfig =
-//      clusterResourceProvider.getClusterConfigurations().get("core-site");
-//
-//    assertNotNull("core-site map was null.", mapCoreSiteConfig);
-//    assertEquals("Incorrect number of entries in the core-site config map",
-//      0, mapCoreSiteConfig.size());
-//
-//    mockSupport.verifyAll();
-//
-//  }
-//
-//
-//  @Test
-//  public void testSetMissingConfigurationsHBaseNotIncluded() throws Exception {
-//    EasyMockSupport mockSupport = new EasyMockSupport();
-//
-//    AmbariManagementController mockMgmtController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    ResourceProvider mockServiceProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockConfigGroupProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    AmbariManagementController mockManagementController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    StackServiceResponse mockStackServiceResponseOne =
-//      mockSupport.createMock(StackServiceResponse.class);
-//    StackServiceComponentResponse mockStackComponentResponse =
-//      mockSupport.createMock(StackServiceComponentResponse.class);
-//    AmbariMetaInfo mockAmbariMetaInfo =
-//      mockSupport.createMock(AmbariMetaInfo.class);
-//
-//    expect(mockStackComponentResponse.getComponentName()).andReturn("HBASE_SERVER");
-//    expect(mockStackComponentResponse.getCardinality()).andReturn("1");
-//    expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
-//
-//    expect(mockStackServiceResponseOne.getServiceName()).andReturn("HBASE").atLeastOnce();
-//    expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
-//
-//    expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
-//    expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
-//    expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//    expect(mockManagementController.getStackLevelConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
-//
-//    expect(mockAmbariMetaInfo.getComponentDependencies("HDP", "2.1", "HBASE", "HBASE_SERVER")).andReturn(Collections.<DependencyInfo>emptyList());
-//
-//    mockSupport.replayAll();
-//
-//    ClusterResourceProvider.init(null, mockAmbariMetaInfo, null);
-//
-//    Stack stack =
-//      new Stack("HDP", "2.1", mockManagementController);
-//
-//    ClusterResourceProvider clusterResourceProvider =
-//      new TestClusterResourceProvider(mockMgmtController, mockServiceProvider,
-//        mockComponentProvider, mockHostProvider, mockHostComponentProvider, mockConfigGroupProvider);
-//
-//    HostGroupEntity hostGroup = new HostGroupEntity();
-//    hostGroup.setComponents(Collections.<HostGroupComponentEntity>emptyList());
-//    HostGroupConfigEntity configEntity = new HostGroupConfigEntity();
-//    configEntity.setConfigData("");
-//
-//    hostGroup.setConfigurations(Collections.singletonList(configEntity));
-//    BaseBlueprintProcessor.HostGroupImpl hostGroupImpl =
-//      new BaseBlueprintProcessor.HostGroupImpl(hostGroup, stack, null);
-//    // blueprint request will not include a reference to an HBASE component
-//    hostGroupImpl.addComponent("COMPONENT_ONE");
-//
-//    // add empty map for core-site, to simulate this configuration entry
-//    clusterResourceProvider.getClusterConfigurations().put("core-site", new HashMap<String, String>());
-//
-//    //clusterResourceProvider.setMissingConfigurations(Collections.singletonMap("host_group_one", hostGroupImpl));
-//
-//    Map<String, String> mapCoreSiteConfig =
-//      clusterResourceProvider.getClusterConfigurations().get("core-site");
-//
-//    assertNotNull("core-site map was null.", mapCoreSiteConfig);
-//    assertEquals("Incorrect number of entries in the core-site config map",
-//      0, mapCoreSiteConfig.size());
-//
-//    mockSupport.verifyAll();
-//
-//  }
-//
-//  @Test
-//  public void testSetConfigurationsOnClusterWithExcludedTypes() throws Exception {
-//    EasyMockSupport mockSupport = new EasyMockSupport();
-//    AmbariManagementController mockMgmtController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    ResourceProvider mockServiceProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockConfigGroupProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    Stack mockStack =
-//      mockSupport.createMock(Stack.class);
-//    BaseBlueprintProcessor.HostGroupImpl mockHostGroupOne =
-//      mockSupport.createMock(BaseBlueprintProcessor.HostGroupImpl.class);
-//
-//    ArrayList<Capture<Set<ClusterRequest>>> listOfRequestCaptures =
-//      new ArrayList<Capture<Set<ClusterRequest>>>();
-//    for (int i = 0; i < 2; i++) {
-//      listOfRequestCaptures.add(new Capture<Set<ClusterRequest>>());
-//    }
-//
-//    ArrayList<Capture<Map<String, String>>> listOfPropertiesCaptures =
-//      new ArrayList<Capture<Map<String, String>>>();
-//    for (int i = 0; i < 2; i++) {
-//      listOfPropertiesCaptures.add(new Capture<Map<String, String>>());
-//    }
-//
-//    expect(mockHostGroupOne.getHostInfo()).andReturn(Collections.singleton("c6401.ambari.apache.org")).atLeastOnce();
-//    expect(mockHostGroupOne.getComponents()).andReturn(Arrays.asList("FALCON_SERVER", "FALCON_CLIENT"));
-//    expect(mockStack.getServicesForComponents(Arrays.asList("FALCON_SERVER", "FALCON_CLIENT")))
-//      .andReturn(Arrays.asList("FALCON")).atLeastOnce();
-//    expect(mockStack.getConfigurationTypes("FALCON")).andReturn(Arrays.asList("falcon-site", "falcon-env", "oozie-site")).atLeastOnce();
-//    // configure falcon to include a single excluded config type
-//    expect(mockStack.getExcludedConfigurationTypes("FALCON")).andReturn(Collections.<String>singleton("oozie-site")).atLeastOnce();
-//
-//    // setup expectations for controller.updateClusters() calls
-//    for (int i = 0; i < 2; i++) {
-//      expect(mockMgmtController.updateClusters(capture(listOfRequestCaptures.get(i)), capture(listOfPropertiesCaptures.get(i)))).andReturn(null);
-//    }
-//
-//    Map<String, BaseBlueprintProcessor.HostGroupImpl> testMapOfHostGroups =
-//      new HashMap<String, BaseBlueprintProcessor.HostGroupImpl>();
-//    testMapOfHostGroups.put("host-group-one", mockHostGroupOne);
-//
-//    mockSupport.replayAll();
-//
-//    ClusterResourceProvider clusterResourceProvider =
-//      new TestClusterResourceProvider(mockMgmtController, mockServiceProvider,
-//        mockComponentProvider, mockHostProvider, mockHostComponentProvider, mockConfigGroupProvider);
-//
-//    Map<String, Map<String, String>> clusterConfig =
-//      clusterResourceProvider.getClusterConfigurations();
-//    clusterConfig.put("falcon-site", Collections.singletonMap("key1", "value1"));
-//    clusterConfig.put("falcon-env", Collections.singletonMap("envKey1", "envValue1"));
-//    clusterConfig.put("oozie-site", Collections.singletonMap("oozie-key-one", "oozie-value-one"));
-//    clusterConfig.put("cluster-env", Collections.<String, String>emptyMap());
-//
-//    // call the method being tested
-//    clusterResourceProvider.setConfigurationsOnCluster(clusterConfig, Collections.<String, Map<String,
-//        Map<String, String>>>emptyMap(),"clusterone", mockStack, testMapOfHostGroups, "1");
-//
-//    // verify that the ClusterRequest's passed to the controller include the expected information
-//    for (Capture<Set<ClusterRequest>> requestCapture : listOfRequestCaptures) {
-//      Set<ClusterRequest> request = requestCapture.getValue();
-//      assertEquals("Incorrect number of cluster requests in this update",
-//                   1, request.size());
-//    }
-//
-//
-//    for (Capture<Map<String, String>> propertiesCapture : listOfPropertiesCaptures) {
-//      assertNull("Incorrect request properties sent with this update",
-//                 propertiesCapture.getValue());
-//    }
-//
-//    // verify that the config requests include the expected information
-//    ClusterRequest requestOne = listOfRequestCaptures.get(0).getValue().iterator().next();
-//    ClusterRequest requestTwo = listOfRequestCaptures.get(1).getValue().iterator().next();
-//
-//    if (requestOne.getDesiredConfig().size() == 1) {
-//      verifyClusterRequest(requestOne, "cluster-env");
-//      // verify that the falcon config does not include oozie-site, since it is excluded
-//      verifyClusterRequest(requestTwo, "falcon-site", "falcon-env");
-//    } else {
-//      verifyClusterRequest(requestTwo, "cluster-env");
-//      // verify that the falcon config does not include oozie-site, since it is excluded
-//      verifyClusterRequest(requestOne, "falcon-site", "falcon-env");
-//    }
-//
-//    mockSupport.verifyAll();
-//  }
-//
-//  @Test
-//  public void testSetConfigurationsOnClusterWithNoExcludedTypes() throws Exception {
-//    EasyMockSupport mockSupport = new EasyMockSupport();
-//    AmbariManagementController mockMgmtController =
-//      mockSupport.createMock(AmbariManagementController.class);
-//    ResourceProvider mockServiceProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockHostComponentProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    ResourceProvider mockConfigGroupProvider =
-//      mockSupport.createMock(ResourceProvider.class);
-//    Stack mockStack =
-//      mockSupport.createMock(Stack.class);
-//    org.apache.ambari.server.topology.HostGroup mockHostGroupOne =
-//      mockSupport.createMock(org.apache.ambari.server.topology.HostGroup.class);
-//
-//    ArrayList<Capture<Set<ClusterRequest>>> listOfRequestCaptures =
-//      new ArrayList<Capture<Set<ClusterRequest>>>();
-//    for (int i = 0; i < 2; i++) {
-//      listOfRequestCaptures.add(new Capture<Set<ClusterRequest>>());
-//    }
-//
-//    ArrayList<Capture<Map<String, String>>> listOfPropertiesCaptures =
-//      new ArrayList<Capture<Map<String, String>>>();
-//    for (int i = 0; i < 2; i++) {
-//      listOfPropertiesCaptures.add(new Capture<Map<String, String>>());
-//    }
-//
-//    expect(mockHostGroupOne.getHostInfo()).andReturn(Collections.singleton("c6401.ambari.apache.org")).atLeastOnce();
-//    expect(mockHostGroupOne.getComponents()).andReturn(Arrays.asList("FALCON_SERVER", "FALCON_CLIENT"));
-//    expect(mockStack.getServicesForComponents(Arrays.asList("FALCON_SERVER", "FALCON_CLIENT")))
-//      .andReturn(Arrays.asList("FALCON")).atLeastOnce();
-//    expect(mockStack.getConfigurationTypes("FALCON")).andReturn(Arrays.asList("falcon-site", "falcon-env", "oozie-site")).atLeastOnce();
-//    // configure falcon to NOT have any excluded types
-//    expect(mockStack.getExcludedConfigurationTypes("FALCON")).andReturn(Collections.<String>emptySet()).atLeastOnce();
-//
-//    // setup expectations for controller.updateClusters() calls
-//    for (int i = 0; i < 2; i++) {
-//      expect(mockMgmtController.updateClusters(capture(listOfRequestCaptures.get(i)), capture(listOfPropertiesCaptures.get(i)))).andReturn(null);
-//    }
-//
-//    Map<String, org.apache.ambari.server.topology.HostGroup> testMapOfHostGroups =
-//      new HashMap<String, org.apache.ambari.server.topology.HostGroup>();
-//    testMapOfHostGroups.put("host-group-one", mockHostGroupOne);
-//
-//    mockSupport.replayAll();
-//
-//    ClusterResourceProvider clusterResourceProvider =
-//      new TestClusterResourceProvider(mockMgmtController, mockServiceProvider,
-//        mockComponentProvider, mockHostProvider, mockHostComponentProvider, mockConfigGroupProvider);
-//
-//    Map<String, Map<String, String>> clusterConfig =
-//      clusterResourceProvider.getClusterConfigurations();
-//
-//    clusterConfig.put("falcon-site", Collections.singletonMap("key1", "value1"));
-//    clusterConfig.put("falcon-env", Collections.singletonMap("envKey1", "envValue1"));
-//    clusterConfig.put("oozie-site", Collections.singletonMap("oozie-key-one", "oozie-value-one"));
-//    clusterConfig.put("cluster-env", Collections.<String, String>emptyMap());
-//
-//    // call the method being tested
-//    clusterResourceProvider.setAllConfigurationsOnCluster(clusterConfig, Collections.<String, Map<String, Map<String, String>>>emptyMap(),
-//        "clusterone", mockStack, testMapOfHostGroups, "1");
-//
-//    // verify that the ClusterRequest's passed to the controller include the expected information
-//    for (Capture<Set<ClusterRequest>> requestCapture : listOfRequestCaptures) {
-//      Set<ClusterRequest> request = requestCapture.getValue();
-//      assertEquals("Incorrect number of cluster requests in this update",
-//        1, request.size());
-//    }
-//
-//    for (Capture<Map<String, String>> propertiesCapture : listOfPropertiesCaptures) {
-//      assertNull("Incorrect request properties sent with this update",
-//        propertiesCapture.getValue());
-//    }
-//
-//    // verify that the config requests include the expected information
-//    ClusterRequest requestOne = listOfRequestCaptures.get(0).getValue().iterator().next();
-//    ClusterRequest requestTwo = listOfRequestCaptures.get(1).getValue().iterator().next();
-//
-//    if (requestOne.getDesiredConfig().size() == 1) {
-//      verifyClusterRequest(requestOne, "cluster-env");
-//      // verify that the falcon config includes oozie-site, since nothing is excluded in this test
-//      verifyClusterRequest(requestTwo, "falcon-site", "falcon-env", "oozie-site");
-//    } else {
-//      verifyClusterRequest(requestTwo, "cluster-env");
-//      // verify that the falcon config includes oozie-site, since nothing is excluded in this test
-//      verifyClusterRequest(requestOne, "falcon-site", "falcon-env", "oozie-site");
-//    }
-//
-//    mockSupport.verifyAll();
-//  }
-//
-//  private static void verifyClusterRequest(ClusterRequest request, String... expectedConfigTypes) throws Exception {
-//    assertEquals("Incorrect number of cluster requests ",
-//                 expectedConfigTypes.length, request.getDesiredConfig().size());
-//
-//    Set<String> foundConfigTypes = new HashSet<String>();
-//    // build set of config types listed in this request
-//    for (ConfigurationRequest configRequest : request.getDesiredConfig()) {
-//      foundConfigTypes.add(configRequest.getType());
-//    }
-//
-//    // verify that the expected types are found
-//    for (String expectedType : expectedConfigTypes) {
-//      assertTrue("Expected config type not found in this config request",
-//                 foundConfigTypes.contains(expectedType));
-//    }
-//
-//  }
-
-  //todo: configuration properties are not being added to props
-  private Set<Map<String, Object>> createBlueprintRequestProperties(String clusterName, String blueprintName) {
-    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
-
-    properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName);
-    properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName);
-    propertySet.add(properties);
-
-    Collection<Map<String, Object>> hostGroups = new ArrayList<Map<String, Object>>();
-    Map<String, Object> hostGroupProperties = new HashMap<String, Object>();
-    hostGroups.add(hostGroupProperties);
-    hostGroupProperties.put("name", "group1");
-    Collection<Map<String, String>> hostGroupHosts = new ArrayList<Map<String, String>>();
-    hostGroupProperties.put("hosts", hostGroupHosts);
-    Map<String, String> hostGroupHostProperties = new HashMap<String, String>();
-    hostGroupHostProperties.put("fqdn", "host.domain");
-    hostGroupHosts.add(hostGroupHostProperties);
-    properties.put("host_groups", hostGroups);
-
-    Map<String, String> mapGroupConfigProperties = new HashMap<String, String>();
-    mapGroupConfigProperties.put("myGroupProp", "awesomeValue");
-
-    // blueprint core-site cluster configuration properties
-    Map<String, String> blueprintCoreConfigProperties = new HashMap<String, String>();
-    blueprintCoreConfigProperties.put("property1", "value2");
-    blueprintCoreConfigProperties.put("new.property", "new.property.value");
-
-    Map<String, String> blueprintGlobalConfigProperties = new HashMap<String, String>();
-    blueprintGlobalConfigProperties.put("hive_database", "New MySQL Database");
-
-    Map<String, String> oozieEnvConfigProperties = new HashMap<String, String>();
-    oozieEnvConfigProperties.put("property1","value2");
-    Map<String, String> hbaseEnvConfigProperties = new HashMap<String, String>();
-    hbaseEnvConfigProperties.put("property1","value2");
-    Map<String, String> falconEnvConfigProperties = new HashMap<String, String>();
-    falconEnvConfigProperties.put("property1","value2");
-
-    return propertySet;
-  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/19194e0b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
index 2c6905d..36286e7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
@@ -46,6 +46,8 @@ import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.security.TestAuthenticationFactory;
+import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Service;
@@ -61,6 +63,7 @@ import org.junit.Test;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
+import org.springframework.security.core.context.SecurityContextHolder;
 
 public class JMXHostProviderTest {
   private Injector injector;
@@ -81,11 +84,18 @@ public class JMXHostProviderTest {
     clusters = injector.getInstance(Clusters.class);
     controller = injector.getInstance(AmbariManagementController.class);
     AmbariMetaInfo ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
+
+    // Set the authenticated user
+    // TODO: remove this or replace the authenticated user to test authorization rules
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
   }
 
   @After
   public void teardown() {
     injector.getInstance(PersistService.class).stop();
+
+    // Clear the authenticated user
+    SecurityContextHolder.getContext().setAuthentication(null);
   }
 
   private void createService(String clusterName,
@@ -130,7 +140,7 @@ public class JMXHostProviderTest {
     controller.createHostComponents(requests);
   }
 
-  private void createHDFSServiceConfigs(boolean version1) throws AmbariException {
+  private void createHDFSServiceConfigs(boolean version1) throws AmbariException, AuthorizationException {
     String clusterName = "c1";
     ClusterRequest r = new ClusterRequest(null, clusterName, "HDP-0.1", null);
     controller.createCluster(r);
@@ -207,7 +217,7 @@ public class JMXHostProviderTest {
     }
   }
 
-  private void createConfigs() throws AmbariException {
+  private void createConfigs() throws AmbariException, AuthorizationException {
     String clusterName = "c1";
     ClusterRequest r = new ClusterRequest(null, clusterName, "HDP-2.0.6", null);
     controller.createCluster(r);

http://git-wip-us.apache.org/repos/asf/ambari/blob/19194e0b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariAuthorizationFilterTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariAuthorizationFilterTest.java b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariAuthorizationFilterTest.java
index 5b66a3f..03a7442 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariAuthorizationFilterTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariAuthorizationFilterTest.java
@@ -266,7 +266,7 @@ public class AmbariAuthorizationFilterTest {
   public void testDoFilter_viewUserAccess() throws Exception {
     final Table<String, String, Boolean> urlTests = HashBasedTable.create();
     urlTests.put("/api/v1/clusters/cluster", "GET",  true);
-    urlTests.put("/api/v1/clusters/cluster", "POST",  false);
+    urlTests.put("/api/v1/clusters/cluster", "POST",  true);
     urlTests.put("/api/v1/views", "GET", true);
     urlTests.put("/api/v1/views", "POST", true);
     urlTests.put("/api/v1/persist/SomeValue", "GET", true);
@@ -299,7 +299,7 @@ public class AmbariAuthorizationFilterTest {
   public void testDoFilter_userNoPermissionsAccess() throws Exception {
     final Table<String, String, Boolean> urlTests = HashBasedTable.create();
     urlTests.put("/api/v1/clusters/cluster", "GET",  true);
-    urlTests.put("/api/v1/clusters/cluster", "POST",  false);
+    urlTests.put("/api/v1/clusters/cluster", "POST",  true);
     urlTests.put("/api/v1/views", "GET", true);
     urlTests.put("/api/v1/views", "POST", false);
     urlTests.put("/api/v1/persist/SomeValue", "GET", true);

http://git-wip-us.apache.org/repos/asf/ambari/blob/19194e0b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
index bdb5156..bf023c2 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
@@ -49,6 +49,7 @@ import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.security.SecurityHelper;
+import org.apache.ambari.server.security.TestAuthenticationFactory;
 import org.apache.ambari.server.stack.StackManagerFactory;
 import org.apache.ambari.server.state.cluster.ClusterFactory;
 import org.apache.ambari.server.state.cluster.ClustersImpl;
@@ -67,6 +68,7 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 import com.google.inject.persist.Transactional;
+import org.springframework.security.core.context.SecurityContextHolder;
 
 
 @RunWith(Enclosed.class)
@@ -82,6 +84,10 @@ public class ConfigHelperTest {
 
     @Before
     public void setup() throws Exception {
+      // Set the authenticated user
+      // TODO: remove this or replace the authenticated user to test authorization rules
+      SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
+
       injector = Guice.createInjector(new InMemoryDefaultTestModule());
       injector.getInstance(GuiceJpaInitializer.class);
       clusters = injector.getInstance(Clusters.class);
@@ -189,6 +195,9 @@ public class ConfigHelperTest {
     @After
     public void tearDown() {
       injector.getInstance(PersistService.class).stop();
+
+      // Clear the authenticated user
+      SecurityContextHolder.getContext().setAuthentication(null);
     }
 
     @Transactional
@@ -708,6 +717,15 @@ public class ConfigHelperTest {
         }
       });
 
+      // Set the authenticated user
+      // TODO: remove this or replace the authenticated user to test authorization rules
+      SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
+    }
+
+    @After
+    public void teardown() {
+      // Clear the authenticated user
+      SecurityContextHolder.getContext().setAuthentication(null);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/19194e0b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
index fa6598c..7e61942 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
@@ -44,6 +44,8 @@ import org.apache.ambari.server.controller.ConfigurationRequest;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.OrmTestHelper;
+import org.apache.ambari.server.security.TestAuthenticationFactory;
+import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.stack.HostsType;
 import org.apache.ambari.server.stack.MasterHostResolver;
 import org.apache.ambari.server.state.UpgradeHelper.UpgradeGroupHolder;
@@ -70,6 +72,7 @@ import com.google.inject.Injector;
 import com.google.inject.Module;
 import com.google.inject.persist.PersistService;
 import com.google.inject.util.Modules;
+import org.springframework.security.core.context.SecurityContextHolder;
 
 /**
  * Tests the {@link UpgradeHelper} class
@@ -144,11 +147,18 @@ public class UpgradeHelperTest {
 //    repositoryVersionDAO.create(stackEntityTo, "2.2.0", "2.2.0", "");
 //
 //    replay(m_configHelper);
+
+    // Set the authenticated user
+    // TODO: remove this or replace the authenticated user to test authorization rules
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
   }
 
   @After
   public void teardown() {
     injector.getInstance(PersistService.class).stop();
+
+    // Clear the authenticated user
+    SecurityContextHolder.getContext().setAuthentication(null);
   }
 
   @Test
@@ -876,7 +886,7 @@ public class UpgradeHelperTest {
   }
 
 
-  private Cluster makeCluster() throws AmbariException {
+  private Cluster makeCluster() throws AmbariException, AuthorizationException {
     return makeCluster(true);
   }
 
@@ -885,7 +895,7 @@ public class UpgradeHelperTest {
    * Create an HA cluster
    * @throws AmbariException
    */
-  private Cluster makeCluster(boolean clean) throws AmbariException {
+  private Cluster makeCluster(boolean clean) throws AmbariException, AuthorizationException {
     Clusters clusters = injector.getInstance(Clusters.class);
     ServiceFactory serviceFactory = injector.getInstance(ServiceFactory.class);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/19194e0b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogTest.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogTest.java
index 319b9fe..1bd1395 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogTest.java
@@ -30,12 +30,14 @@ import org.apache.ambari.server.controller.ClusterRequest;
 import org.apache.ambari.server.controller.ConfigurationRequest;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.security.TestAuthenticationFactory;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.springframework.security.core.context.SecurityContextHolder;
 
 import java.sql.SQLException;
 import java.util.Collections;
@@ -100,11 +102,18 @@ public class UpgradeCatalogTest {
     injector  = Guice.createInjector(new UpgradeHelperModuleTest());
     injector.getInstance(GuiceJpaInitializer.class);
     metaInfo = injector.getInstance(AmbariMetaInfo.class);
+
+    // Set the authenticated user
+    // TODO: remove this or replace the authenticated user to test authorization rules
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
   }
 
   @After
   public void teardown() throws AmbariException {
     injector.getInstance(PersistService.class).stop();
+
+    // Clear the authenticated user
+    SecurityContextHolder.getContext().setAuthentication(null);
   }
 
   @Test


Mime
View raw message