ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject [2/3] ambari git commit: AMBARI-14192. Enforce granular role-based access control for service functions (rlevas)
Date Wed, 09 Dec 2015 17:51:47 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/f08db5c9/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 9dbfcff..599d566 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -104,6 +104,7 @@ import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
 import org.apache.ambari.server.orm.entities.WidgetEntity;
 import org.apache.ambari.server.orm.entities.WidgetLayoutEntity;
 import org.apache.ambari.server.orm.entities.WidgetLayoutUserWidgetEntity;
+import org.apache.ambari.server.security.TestAuthenticationFactory;
 import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.security.authorization.Users;
 import org.apache.ambari.server.security.authorization.internal.InternalAuthenticationToken;
@@ -222,9 +223,7 @@ public class AmbariManagementControllerTest {
   @BeforeClass
   public static void setupAuthentication() {
     // Set authenticated user so that authorization checks will pass
-    InternalAuthenticationToken authenticationToken = new InternalAuthenticationToken("admin");
-    authenticationToken.setAuthenticated(true);
-    SecurityContextHolder.getContext().setAuthentication(authenticationToken);
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator());
   }
 
   @Before
@@ -300,7 +299,7 @@ public class AmbariManagementControllerTest {
   }
 
   private void createService(String clusterName,
-      String serviceName, State desiredState) throws AmbariException {
+      String serviceName, State desiredState) throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();
@@ -314,7 +313,7 @@ public class AmbariManagementControllerTest {
 
   private void createServiceComponent(String clusterName,
       String serviceName, String componentName, State desiredState)
-          throws AmbariException {
+      throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();
@@ -329,7 +328,7 @@ public class AmbariManagementControllerTest {
 
   private void createServiceComponentHost(String clusterName,
       String serviceName, String componentName, String hostname,
-      State desiredState) throws AmbariException {
+      State desiredState) throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();
@@ -344,7 +343,7 @@ public class AmbariManagementControllerTest {
 
   private void deleteServiceComponentHost(String clusterName,
                                           String serviceName, String componentName, String hostname,
-                                          State desiredState) throws AmbariException {
+                                          State desiredState) throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();
@@ -385,7 +384,7 @@ public class AmbariManagementControllerTest {
 
   private long stopService(String clusterName, String serviceName,
       boolean runSmokeTests, boolean reconfigureClients) throws
-    AmbariException {
+      AmbariException, AuthorizationException {
     ServiceRequest r = new ServiceRequest(clusterName, serviceName, State.INSTALLED.toString());
     Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
     requests.add(r);
@@ -442,7 +441,7 @@ public class AmbariManagementControllerTest {
 
   private long startService(String clusterName, String serviceName,
                             boolean runSmokeTests, boolean reconfigureClients) throws
-      AmbariException {
+      AmbariException, AuthorizationException {
     return startService(clusterName, serviceName, runSmokeTests, reconfigureClients, null);
   }
 
@@ -450,7 +449,7 @@ public class AmbariManagementControllerTest {
   private long startService(String clusterName, String serviceName,
                             boolean runSmokeTests, boolean reconfigureClients,
                             MaintenanceStateHelper maintenanceStateHelper) throws
-      AmbariException {
+      AmbariException, AuthorizationException {
     ServiceRequest r = new ServiceRequest(clusterName, serviceName,
         State.STARTED.toString());
     Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
@@ -491,14 +490,14 @@ public class AmbariManagementControllerTest {
 
   private long installService(String clusterName, String serviceName,
                               boolean runSmokeTests, boolean reconfigureClients)
-          throws AmbariException {
+      throws AmbariException, AuthorizationException {
     return installService(clusterName, serviceName, runSmokeTests, reconfigureClients, null, null);
   }
 
   private long installService(String clusterName, String serviceName,
                               boolean runSmokeTests, boolean reconfigureClients,
                               Map<String, String> mapRequestPropsInput)
-      throws AmbariException {
+      throws AmbariException, AuthorizationException {
     return installService(clusterName, serviceName, runSmokeTests, reconfigureClients, null, mapRequestPropsInput);
   }
 
@@ -511,7 +510,7 @@ public class AmbariManagementControllerTest {
                               boolean runSmokeTests, boolean reconfigureClients,
                               MaintenanceStateHelper maintenanceStateHelper,
                               Map<String, String> mapRequestPropsInput)
-          throws AmbariException {
+      throws AmbariException, AuthorizationException {
     ServiceRequest r = new ServiceRequest(clusterName, serviceName,
         State.INSTALLED.toString());
     Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
@@ -679,7 +678,7 @@ public class AmbariManagementControllerTest {
   }
 
   @Test
-  public void testCreateServicesWithInvalidRequest() throws AmbariException {
+  public void testCreateServicesWithInvalidRequest() throws AmbariException, AuthorizationException {
     // invalid request
     // dups in requests
     // multi cluster updates
@@ -714,7 +713,7 @@ public class AmbariManagementControllerTest {
       fail("Expected failure for invalid cluster");
     } catch (AmbariException e) {
       // Expected
-      Assert.assertTrue(checkExceptionType(e, ParentObjectNotFoundException.class));
+      Assert.assertTrue(checkExceptionType(e, ClusterNotFoundException.class));
     }
 
     clusters.addCluster("foo", new StackId("HDP-0.1"));
@@ -821,7 +820,7 @@ public class AmbariManagementControllerTest {
   }
 
   @Test
-  public void testCreateServicesMultiple() throws AmbariException {
+  public void testCreateServicesMultiple() throws AmbariException, AuthorizationException {
     Set<ServiceRequest> set1 = new HashSet<ServiceRequest>();
     clusters.addCluster("foo", new StackId("HDP-0.1"));
 
@@ -891,7 +890,7 @@ public class AmbariManagementControllerTest {
 
   @Test
   public void testCreateServiceComponentWithInvalidRequest()
-      throws AmbariException {
+      throws AmbariException, AuthorizationException {
     // multiple clusters
     // dup objects
     // existing components
@@ -1249,7 +1248,7 @@ public class AmbariManagementControllerTest {
   }
 
   @Test
-  public void testCreateServiceComponentMultiple() throws AmbariException {
+  public void testCreateServiceComponentMultiple() throws AmbariException, AuthorizationException {
     clusters.addCluster("c1", new StackId("HDP-0.2"));
     clusters.addCluster("c2", new StackId("HDP-0.2"));
 
@@ -1449,7 +1448,7 @@ public class AmbariManagementControllerTest {
 
   @Test
   public void testCreateServiceComponentHostWithInvalidRequest()
-      throws AmbariException {
+      throws AmbariException, AuthorizationException {
     // multiple clusters
     // dup objects
     // existing components
@@ -9706,7 +9705,7 @@ public class AmbariManagementControllerTest {
   private void testRunSmokeTestFlag(Map<String, String> mapRequestProps,
                                     AmbariManagementController amc,
                                     Set<ServiceRequest> serviceRequests)
-      throws AmbariException {
+      throws AmbariException, AuthorizationException {
     RequestStatusResponse response;//Starting HDFS service. No run_smoke_test flag is set, smoke
 
     //Stopping HDFS service

http://git-wip-us.apache.org/repos/asf/ambari/blob/f08db5c9/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
index e1e9104..fc39521 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
@@ -35,13 +35,13 @@ import org.apache.ambari.server.actionmanager.Request;
 import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.agent.AgentCommand.AgentCommandType;
 import org.apache.ambari.server.agent.ExecutionCommand;
-import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.internal.ComponentResourceProviderTest;
 import org.apache.ambari.server.controller.internal.RequestResourceFilter;
 import org.apache.ambari.server.controller.internal.ServiceResourceProviderTest;
 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.Clusters;
 import org.apache.ambari.server.state.Host;
@@ -63,16 +63,14 @@ import org.mockito.runners.MockitoJUnitRunner;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
+import org.springframework.security.core.context.SecurityContextHolder;
 
 @RunWith(MockitoJUnitRunner.class)
 public class BackgroundCustomCommandExecutionTest {
   private Injector injector;
   private AmbariManagementController controller;
-  private AmbariMetaInfo ambariMetaInfo;
-  private Configuration configuration;
   private Clusters clusters;
-  private TopologyManager topologyManager;
-  
+
   private static final String REQUEST_CONTEXT_PROPERTY = "context";
   
   @Captor ArgumentCaptor<Request> requestCapture;
@@ -80,6 +78,9 @@ public class BackgroundCustomCommandExecutionTest {
   
   @Before
   public void setup() throws Exception {
+    Configuration configuration;
+    TopologyManager topologyManager;
+
     InMemoryDefaultTestModule module = new InMemoryDefaultTestModule(){
       
       
@@ -100,13 +101,19 @@ public class BackgroundCustomCommandExecutionTest {
     topologyManager = injector.getInstance(TopologyManager.class);
     
     Assert.assertEquals("src/main/resources/custom_action_definitions", configuration.getCustomActionDefinitionPath());
-    
-    ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
+
     StageUtils.setTopologyManager(topologyManager);
+
+    // Set the authenticated user
+    // TODO: remove this or replace the authenticated user to test authorization rules
+    // Set the authenticated user
+    // TODO: remove this or replace the authenticated user to test authorization rules
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator());
   }
   @After
   public void teardown() {
     injector.getInstance(PersistService.class).stop();
+    SecurityContextHolder.getContext().setAuthentication(null);
   }
 
   @SuppressWarnings("serial")
@@ -189,7 +196,7 @@ public class BackgroundCustomCommandExecutionTest {
   }
   
   private void createService(String clusterName,
-      String serviceName, State desiredState) throws AmbariException {
+      String serviceName, State desiredState) throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();
@@ -203,7 +210,7 @@ public class BackgroundCustomCommandExecutionTest {
 
   private void createServiceComponent(String clusterName,
       String serviceName, String componentName, State desiredState)
-          throws AmbariException {
+      throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();
@@ -216,7 +223,8 @@ public class BackgroundCustomCommandExecutionTest {
     ComponentResourceProviderTest.createComponents(controller, requests);
   }
 
-  private void createServiceComponentHost(String clusterName, String serviceName, String componentName, String hostname, State desiredState) throws AmbariException {
+  private void createServiceComponentHost(String clusterName, String serviceName, String componentName, String hostname, State desiredState)
+      throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();

http://git-wip-us.apache.org/repos/asf/ambari/blob/f08db5c9/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java
index c871ec7..179f658 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java
@@ -27,7 +27,6 @@ import java.util.Set;
 import junit.framework.Assert;
 
 import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.internal.ComponentResourceProviderTest;
 import org.apache.ambari.server.controller.internal.ServiceResourceProviderTest;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
@@ -58,7 +57,6 @@ public class RefreshYarnCapacitySchedulerReleaseConfigTest {
 
   private Injector injector;
   private AmbariManagementController controller;
-  private AmbariMetaInfo ambariMetaInfo;
   private Clusters clusters;
   private ConfigHelper configHelper;
 
@@ -71,11 +69,10 @@ public class RefreshYarnCapacitySchedulerReleaseConfigTest {
     controller = injector.getInstance(AmbariManagementController.class);
     clusters = injector.getInstance(Clusters.class);
     configHelper = injector.getInstance(ConfigHelper.class);
-    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"));
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator());
   }
 
   @After
@@ -200,7 +197,7 @@ public class RefreshYarnCapacitySchedulerReleaseConfigTest {
   }
   
   private void createService(String clusterName,
-      String serviceName, State desiredState) throws AmbariException {
+      String serviceName, State desiredState) throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();
@@ -214,7 +211,7 @@ public class RefreshYarnCapacitySchedulerReleaseConfigTest {
 
   private void createServiceComponent(String clusterName,
       String serviceName, String componentName, State desiredState)
-          throws AmbariException {
+      throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();
@@ -227,7 +224,8 @@ public class RefreshYarnCapacitySchedulerReleaseConfigTest {
     ComponentResourceProviderTest.createComponents(controller, requests);
   }
 
-  private void createServiceComponentHost(String clusterName, String serviceName, String componentName, String hostname, State desiredState) throws AmbariException {
+  private void createServiceComponentHost(String clusterName, String serviceName, String componentName, String hostname, State desiredState)
+      throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();

http://git-wip-us.apache.org/repos/asf/ambari/blob/f08db5c9/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 827f979..179a09e 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
@@ -129,12 +129,12 @@ public class ClusterResourceProviderTest {
 
   @Test
   public void testCreateResource_blueprint_asAdministrator() throws Exception {
-    testCreateResource_blueprint(TestAuthenticationFactory.createAdministrator("admin"));
+    testCreateResource_blueprint(TestAuthenticationFactory.createAdministrator());
   }
 
   @Test(expected = AuthorizationException.class)
   public void testCreateResource_blueprint__NonAdministrator() throws Exception {
-    testCreateResource_blueprint(TestAuthenticationFactory.createClusterAdministrator("User1"));
+    testCreateResource_blueprint(TestAuthenticationFactory.createClusterAdministrator());
   }
 
   @Test(expected = IllegalArgumentException.class)
@@ -160,7 +160,7 @@ public class ClusterResourceProviderTest {
     expect(requestStatusResponse.getRequestId()).andReturn(5150L).anyTimes();
 
     replayAll();
-    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator());
     RequestStatus requestStatus = provider.createResources(request);
   }
 
@@ -185,7 +185,7 @@ public class ClusterResourceProviderTest {
     expect(requestStatusResponse.getRequestId()).andReturn(5150L).anyTimes();
 
     replayAll();
-    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator());
     RequestStatus requestStatus = provider.createResources(request);
     assertEquals(5150L, requestStatus.getRequestResource().getPropertyValue(PropertyHelper.getPropertyId("Requests", "id")));
     assertEquals(Resource.Type.Request, requestStatus.getRequestResource().getType());
@@ -206,18 +206,18 @@ public class ClusterResourceProviderTest {
       ("test"));
 
     replayAll();
-    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator());
     provider.createResources(request);
   }
 
   @Test
   public void testCreateResourcesAsAdministrator() throws Exception{
-    testCreateResources(TestAuthenticationFactory.createAdministrator("admin"));
+    testCreateResources(TestAuthenticationFactory.createAdministrator());
   }
 
   @Test(expected = AuthorizationException.class)
   public void testCreateResourcesAsNonAdministrator() throws Exception{
-    testCreateResources(TestAuthenticationFactory.createClusterAdministrator("User1"));
+    testCreateResources(TestAuthenticationFactory.createClusterAdministrator());
   }
 
   @Test
@@ -235,7 +235,7 @@ public class ClusterResourceProviderTest {
     // replay
     replay(managementController, response);
 
-    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator());
 
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
@@ -282,12 +282,12 @@ public class ClusterResourceProviderTest {
 
   @Test
   public void testGetResourcesAsAdministrator() throws Exception{
-    testGetResources(TestAuthenticationFactory.createAdministrator("admin"));
+    testGetResources(TestAuthenticationFactory.createAdministrator());
   }
 
   @Test
   public void testGetResourcesAsNonAdministrator() throws Exception{
-    testGetResources(TestAuthenticationFactory.createClusterAdministrator("User1"));
+    testGetResources(TestAuthenticationFactory.createClusterAdministrator());
   }
 
   public void testGetResources(Authentication authentication) throws Exception{
@@ -376,42 +376,42 @@ public class ClusterResourceProviderTest {
 
   @Test
   public void testUpdateResourcesAsAdministrator() throws Exception{
-    testUpdateResources(TestAuthenticationFactory.createAdministrator("admin"));
+    testUpdateResources(TestAuthenticationFactory.createAdministrator());
   }
 
   @Test
   public void testUpdateResourcesAsClusterAdministrator() throws Exception{
-    testUpdateResources(TestAuthenticationFactory.createClusterAdministrator("User1"));
+    testUpdateResources(TestAuthenticationFactory.createClusterAdministrator());
   }
 
   @Test(expected = AuthorizationException.class)
-  public void testUpdateResourcesAsServiceAdministrator() throws Exception {
-    testUpdateResources(TestAuthenticationFactory.createServiceAdministrator("User10"));
+  public void testUpdateResourcesAsServiceOperator() throws Exception {
+    testUpdateResources(TestAuthenticationFactory.createServiceOperator());
   }
 
   @Test
   public void testUpdateWithConfigurationAsAdministrator() throws Exception {
-    testUpdateWithConfiguration(TestAuthenticationFactory.createAdministrator("admin"));
+    testUpdateWithConfiguration(TestAuthenticationFactory.createAdministrator());
   }
 
   @Test
   public void testUpdateWithConfigurationAsClusterAdministrator() throws Exception {
-    testUpdateWithConfiguration(TestAuthenticationFactory.createClusterAdministrator("User1"));
+    testUpdateWithConfiguration(TestAuthenticationFactory.createClusterAdministrator());
   }
 
   @Test(expected = AuthorizationException.class)
-  public void testUpdateWithConfigurationAsServiceAdministrator() throws Exception {
-    testUpdateWithConfiguration(TestAuthenticationFactory.createServiceAdministrator("User10"));
+  public void testUpdateWithConfigurationAsServiceOperator() throws Exception {
+    testUpdateWithConfiguration(TestAuthenticationFactory.createServiceOperator());
   }
 
   @Test
   public void testDeleteResourcesAsAdministrator() throws Exception{
-    testDeleteResources(TestAuthenticationFactory.createAdministrator("admin"));
+    testDeleteResources(TestAuthenticationFactory.createAdministrator());
   }
 
   @Test(expected = AuthorizationException.class)
   public void testDeleteResourcesAsNonAdministrator() throws Exception{
-    testDeleteResources(TestAuthenticationFactory.createClusterAdministrator("User1"));
+    testDeleteResources(TestAuthenticationFactory.createClusterAdministrator());
   }
 
   //todo: configuration properties are not being added to props

http://git-wip-us.apache.org/repos/asf/ambari/blob/f08db5c9/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
index 5fb2831..6ec27ad 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
@@ -20,9 +20,7 @@ package org.apache.ambari.server.controller.internal;
 
 import static org.easymock.EasyMock.anyBoolean;
 import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMockBuilder;
 import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.eq;
 import static org.easymock.EasyMock.capture;
 import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.createNiceMock;
@@ -35,7 +33,6 @@ import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import java.lang.reflect.Method;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -49,7 +46,6 @@ import java.util.Set;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ObjectNotFoundException;
 import org.apache.ambari.server.ServiceComponentNotFoundException;
-import org.apache.ambari.server.StackAccessException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.AmbariManagementControllerImpl;
@@ -64,6 +60,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.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ComponentInfo;
@@ -76,19 +74,41 @@ import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.State;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
 import com.google.gson.Gson;
 import com.google.inject.Injector;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
 
 /**
  * Tests for the component resource provider.
  */
 public class ComponentResourceProviderTest {
+
+  @Before
+  public void clearAuthentication() {
+    SecurityContextHolder.getContext().setAuthentication(null);
+  }
+
+  @Test
+  public void testCreateResourcesAsAdministrator() throws Exception {
+    testCreateResources(TestAuthenticationFactory.createAdministrator());
+  }
+
   @Test
-  public void testCreateResources() throws Exception {
+  public void testCreateResourcesAsClusterAdministrator() throws Exception {
+    testCreateResources(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testCreateResourcesAsServiceAdministrator() throws Exception {
+    testCreateResources(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  private void testCreateResources(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.Component;
 
     MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);
@@ -108,6 +128,7 @@ public class ComponentResourceProviderTest {
 
     expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
     expect(cluster.getService("Service100")).andReturn(service).anyTimes();
+    expect(cluster.getClusterId()).andReturn(2L).anyTimes();
 
     expect(service.getDesiredStackVersion()).andReturn(stackId).anyTimes();
     expect(service.getName()).andReturn("Service100").anyTimes();
@@ -123,6 +144,8 @@ public class ComponentResourceProviderTest {
     replay(managementController, response, clusters, cluster, service, stackId, ambariMetaInfo,
         serviceComponentFactory, serviceComponent);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = new ComponentResourceProvider(PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
         managementController, maintenanceStateHelper);
@@ -151,7 +174,21 @@ public class ComponentResourceProviderTest {
   }
 
   @Test
-  public void testGetResources() throws Exception {
+  public void testGetResourcesAsAdministrator() throws Exception {
+    testGetResources(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testGetResourcesAsClusterAdministrator() throws Exception {
+    testGetResources(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test
+  public void testGetResourcesAsServiceAdministrator() throws Exception {
+    testGetResources(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  private void testGetResources(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.Component;
 
     MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);
@@ -201,6 +238,8 @@ public class ComponentResourceProviderTest {
       serviceComponent1, serviceComponent2, serviceComponent3, stackId,
       componentInfo1, componentInfo2);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = new ComponentResourceProvider(
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -247,7 +286,21 @@ public class ComponentResourceProviderTest {
   }
 
   @Test
-  public void testUpdateResources() throws Exception {
+  public void testUpdateResourcesAsAdministrator() throws Exception {
+    testUpdateResources(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testUpdateResourcesAsClusterAdministrator() throws Exception {
+    testUpdateResources(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test
+  public void testUpdateResourcesAsServiceAdministrator() throws Exception {
+    testUpdateResources(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  private void testUpdateResources(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.Component;
 
     MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);
@@ -276,7 +329,7 @@ public class ComponentResourceProviderTest {
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
     expect(managementController.getEffectiveMaintenanceState(
-        capture(new Capture<ServiceComponentHost>()))).andReturn(MaintenanceState.OFF).anyTimes();
+        capture(EasyMock.<ServiceComponentHost>newCapture()))).andReturn(MaintenanceState.OFF).anyTimes();
 
     expect(stackId.getStackName()).andReturn("stackName").anyTimes();
     expect(stackId.getStackVersion()).andReturn("1").anyTimes();
@@ -294,6 +347,7 @@ public class ComponentResourceProviderTest {
     expect(serviceComponent3.getName()).andReturn("Component103").anyTimes();
 
     expect(cluster.getServices()).andReturn(Collections.singletonMap("Service100", service)).anyTimes();
+    expect(cluster.getClusterId()).andReturn(2L).anyTimes();
 
     expect(service.getServiceComponents()).andReturn(serviceComponentMap).anyTimes();
 
@@ -324,13 +378,13 @@ public class ComponentResourceProviderTest {
 
     expect(maintenanceStateHelper.isOperationAllowed(anyObject(Resource.Type.class), anyObject(Service.class))).andReturn(true).anyTimes();
 
-    Capture<Map<String, String>> requestPropertiesCapture = new Capture<Map<String, String>>();
-    Capture<Map<State, List<Service>>> changedServicesCapture = new Capture<Map<State, List<Service>>>();
-    Capture<Map<State, List<ServiceComponent>>> changedCompsCapture = new Capture<Map<State, List<ServiceComponent>>>();
-    Capture<Map<String, Map<State, List<ServiceComponentHost>>>> changedScHostsCapture = new Capture<Map<String, Map<State, List<ServiceComponentHost>>>>();
-    Capture<Map<String, String>> requestParametersCapture = new Capture<Map<String, String>>();
-    Capture<Collection<ServiceComponentHost>> ignoredScHostsCapture = new Capture<Collection<ServiceComponentHost>>();
-    Capture<Cluster> clusterCapture = new Capture<Cluster>();
+    Capture<Map<String, String>> requestPropertiesCapture = EasyMock.newCapture();
+    Capture<Map<State, List<Service>>> changedServicesCapture = EasyMock.newCapture();
+    Capture<Map<State, List<ServiceComponent>>> changedCompsCapture = EasyMock.newCapture();
+    Capture<Map<String, Map<State, List<ServiceComponentHost>>>> changedScHostsCapture = EasyMock.newCapture();
+    Capture<Map<String, String>> requestParametersCapture = EasyMock.newCapture();
+    Capture<Collection<ServiceComponentHost>> ignoredScHostsCapture = EasyMock.newCapture();
+    Capture<Cluster> clusterCapture = EasyMock.newCapture();
 
     expect(managementController.createAndPersistStages(capture(clusterCapture), capture(requestPropertiesCapture), capture(requestParametersCapture), capture(changedServicesCapture), capture(changedCompsCapture), capture(changedScHostsCapture), capture(ignoredScHostsCapture), anyBoolean(), anyBoolean()
     )).andReturn(requestStatusResponse);
@@ -344,6 +398,8 @@ public class ComponentResourceProviderTest {
         component2Info, component3Info, serviceComponent1, serviceComponent2, serviceComponent3,
         serviceComponentHost, requestStatusResponse, stackId, maintenanceStateHelper);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = new ComponentResourceProvider(
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -368,7 +424,22 @@ public class ComponentResourceProviderTest {
         serviceComponentHost, requestStatusResponse, stackId, maintenanceStateHelper);
   }
 
-  public void testSuccessDeleteResources() throws Exception {
+  @Test
+  public void testSuccessDeleteResourcesAsAdministrator() throws Exception {
+    testSuccessDeleteResources(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testSuccessDeleteResourcesAsClusterAdministrator() throws Exception {
+    testSuccessDeleteResources(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testSuccessDeleteResourcesAsServiceAdministrator() throws Exception {
+    testSuccessDeleteResources(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  private void testSuccessDeleteResources(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.Component;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
@@ -390,6 +461,7 @@ public class ComponentResourceProviderTest {
 
     expect(clusters.getCluster("Cluster100")).andReturn(cluster);
     expect(cluster.getService("Service100")).andReturn(service);
+    expect(cluster.getClusterId()).andReturn(2L).anyTimes();
 
     expect(service.getServiceComponent("Component100")).andReturn(serviceComponent);
 
@@ -406,6 +478,8 @@ public class ComponentResourceProviderTest {
     replay(managementController, clusters, cluster, service, stackId, ambariMetaInfo,
            serviceComponent, serviceComponentHost, maintenanceStateHelper);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = new ComponentResourceProvider(
                 PropertyHelper.getPropertyIds(type),
                 PropertyHelper.getKeyPropertyIds(type),
@@ -433,7 +507,21 @@ public class ComponentResourceProviderTest {
   }
 
   @Test
-  public void testDeleteResourcesWithEmptyClusterComponentNames() throws Exception {
+  public void testDeleteResourcesWithEmptyClusterComponentNamesAsAdministrator() throws Exception {
+    testDeleteResourcesWithEmptyClusterComponentNames(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testDeleteResourcesWithEmptyClusterComponentNamesAsClusterAdministrator() throws Exception {
+    testDeleteResourcesWithEmptyClusterComponentNames(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testDeleteResourcesWithEmptyClusterComponentNamesAsServiceAdministrator() throws Exception {
+    testDeleteResourcesWithEmptyClusterComponentNames(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  private void testDeleteResourcesWithEmptyClusterComponentNames(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.Component;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
@@ -447,6 +535,8 @@ public class ComponentResourceProviderTest {
 
     replay(managementController, clusters, ambariMetaInfo, maintenanceStateHelper);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = new ComponentResourceProvider(
                 PropertyHelper.getPropertyIds(type),
                 PropertyHelper.getKeyPropertyIds(type),
@@ -490,7 +580,21 @@ public class ComponentResourceProviderTest {
   }
 
   @Test
-  public void testDeleteResourcesWithServiceComponentStarted() throws Exception {
+  public void testDeleteResourcesWithServiceComponentStartedAsAdministrator() throws Exception {
+    testDeleteResourcesWithServiceComponentStarted(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testDeleteResourcesWithServiceComponentStartedAsClusterAdministrator() throws Exception {
+    testDeleteResourcesWithServiceComponentStarted(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testDeleteResourcesWithServiceComponentStartedAsServiceAdministrator() throws Exception {
+    testDeleteResourcesWithServiceComponentStarted(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  private void testDeleteResourcesWithServiceComponentStarted(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.Component;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
@@ -512,6 +616,7 @@ public class ComponentResourceProviderTest {
 
     expect(clusters.getCluster("Cluster100")).andReturn(cluster);
     expect(cluster.getService("Service100")).andReturn(service);
+    expect(cluster.getClusterId()).andReturn(2L).anyTimes();
 
     expect(service.getServiceComponent("Component100")).andReturn(serviceComponent);
 
@@ -525,6 +630,8 @@ public class ComponentResourceProviderTest {
     replay(managementController, clusters, cluster, service, stackId, ambariMetaInfo,
            serviceComponent, serviceComponentHost, maintenanceStateHelper);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = new ComponentResourceProvider(
                 PropertyHelper.getPropertyIds(type),
                 PropertyHelper.getKeyPropertyIds(type),
@@ -548,6 +655,9 @@ public class ComponentResourceProviderTest {
       provider.deleteResources(predicate);
       Assert.fail("Expected exception.");
     } catch(Exception e) {
+      if (e instanceof AuthorizationException) {
+        throw e;
+      }
       //expected
     }
 
@@ -556,7 +666,21 @@ public class ComponentResourceProviderTest {
   }
 
   @Test
-  public void testDeleteResourcesWithServiceComponentHostStarted() throws Exception {
+  public void testDeleteResourcesWithServiceComponentHostStartedAsAdministrator() throws Exception {
+    testDeleteResourcesWithServiceComponentHostStarted(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testDeleteResourcesWithServiceComponentHostStartedAsClusterAdministrator() throws Exception {
+    testDeleteResourcesWithServiceComponentHostStarted(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testDeleteResourcesWithServiceComponentHostStartedAsServiceAdministrator() throws Exception {
+    testDeleteResourcesWithServiceComponentHostStarted(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  private void testDeleteResourcesWithServiceComponentHostStarted(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.Component;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
@@ -578,6 +702,7 @@ public class ComponentResourceProviderTest {
 
     expect(clusters.getCluster("Cluster100")).andReturn(cluster);
     expect(cluster.getService("Service100")).andReturn(service);
+    expect(cluster.getClusterId()).andReturn(2L).anyTimes();
 
     expect(service.getServiceComponent("Component100")).andReturn(serviceComponent);
 
@@ -591,6 +716,8 @@ public class ComponentResourceProviderTest {
     replay(managementController, clusters, cluster, service, stackId, ambariMetaInfo,
            serviceComponent, serviceComponentHost, maintenanceStateHelper);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = new ComponentResourceProvider(
                 PropertyHelper.getPropertyIds(type),
                 PropertyHelper.getKeyPropertyIds(type),
@@ -614,6 +741,9 @@ public class ComponentResourceProviderTest {
       provider.deleteResources(predicate);
       Assert.fail("Expected exception.");
     } catch(Exception e) {
+      if (e instanceof AuthorizationException) {
+        throw e;
+      }
       //expected
     }
 
@@ -781,7 +911,7 @@ public class ComponentResourceProviderTest {
   public void testGetComponents___ServiceComponentNotFoundException() throws Exception {
     // member state mocks
     Injector injector = createStrictMock(Injector.class);
-    Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
+    Capture<AmbariManagementController> controllerCapture = EasyMock.newCapture();
     Clusters clusters = createNiceMock(Clusters.class);
     MaintenanceStateHelper maintHelper = createNiceMock(MaintenanceStateHelper.class);
     Cluster cluster = createNiceMock(Cluster.class);
@@ -824,7 +954,8 @@ public class ComponentResourceProviderTest {
     verify(injector, clusters, cluster, service);
   }
   
-  public static void createComponents(AmbariManagementController controller, Set<ServiceComponentRequest> requests) throws AmbariException {
+  public static void createComponents(AmbariManagementController controller, Set<ServiceComponentRequest> requests)
+      throws AmbariException, AuthorizationException {
     ComponentResourceProvider provider = getComponentResourceProvider(controller);
     provider.createComponents(requests);
   }
@@ -837,8 +968,8 @@ public class ComponentResourceProviderTest {
 
   public static RequestStatusResponse updateComponents(AmbariManagementController controller,
                                                      Set<ServiceComponentRequest> requests,
-                                                     Map<String, String> requestProperties, boolean runSmokeTest) throws AmbariException
-  {
+                                                     Map<String, String> requestProperties, boolean runSmokeTest)
+      throws AmbariException, AuthorizationException {
     ComponentResourceProvider provider = getComponentResourceProvider(controller);
     return provider.updateComponents(requests, requestProperties, runSmokeTest);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f08db5c9/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
index 734bbc4..f9c1fe4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
@@ -18,7 +18,6 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.createNiceMock;
 import static org.easymock.EasyMock.eq;
@@ -49,10 +48,13 @@ import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.RequestStatus;
 import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Resource.Type;
 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.orm.dao.HostVersionDAO;
+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;
@@ -63,16 +65,38 @@ import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.state.UpgradeState;
 import org.easymock.EasyMock;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
 import com.google.inject.Injector;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
 
 /**
  * HostComponentResourceProvider tests.
  */
 public class HostComponentResourceProviderTest {
+  @Before
+  public void clearAuthentication() {
+    SecurityContextHolder.getContext().setAuthentication(null);
+  }
+
+  @Test
+  public void testCreateResourcesAsAdministrator() throws Exception {
+    testCreateResources(TestAuthenticationFactory.createAdministrator());
+  }
+
   @Test
-  public void testCreateResources() throws Exception {
+  public void testCreateResourcesAsClusterAdministrator() throws Exception {
+    testCreateResources(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testCreateResourcesAsServiceAdministrator() throws Exception {
+    testCreateResources(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  private void testCreateResources(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.HostComponent;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
@@ -90,8 +114,8 @@ public class HostComponentResourceProviderTest {
         AbstractResourceProviderTest.Matcher.getHostComponentRequestSet(
             "Cluster100", "Service100", "Component100", "Host100", null, null));
 
-    expect(resourceProviderFactory.getHostComponentResourceProvider(anyObject(Set.class),
-        anyObject(Map.class),
+    expect(resourceProviderFactory.getHostComponentResourceProvider(EasyMock.<Set<String>>anyObject(),
+        EasyMock.<Map<Type,String>>anyObject(),
         eq(managementController))).
         andReturn(hostComponentResourceProvider).anyTimes();
 
@@ -99,6 +123,8 @@ public class HostComponentResourceProviderTest {
     // replay
     replay(managementController, response, resourceProviderFactory);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
@@ -129,7 +155,21 @@ public class HostComponentResourceProviderTest {
   }
 
   @Test
-  public void testGetResources() throws Exception {
+  public void testGetResourcesAsAdministrator() throws Exception {
+    testGetResources(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testGetResourcesAsClusterAdministrator() throws Exception {
+    testGetResources(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test
+  public void testGetResourcesAsServiceAdministrator() throws Exception {
+    testGetResources(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  private void testGetResources(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.HostComponent;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
@@ -167,8 +207,8 @@ public class HostComponentResourceProviderTest {
 
 
     // set expectations
-    expect(resourceProviderFactory.getHostComponentResourceProvider(anyObject(Set.class),
-        anyObject(Map.class),
+    expect(resourceProviderFactory.getHostComponentResourceProvider(EasyMock.<Set<String>>anyObject(),
+        EasyMock.<Map<Type,String>>anyObject(),
         eq(managementController))).
         andReturn(hostComponentResourceProvider).anyTimes();
 
@@ -229,6 +269,8 @@ public class HostComponentResourceProviderTest {
     // replay
     replay(managementController, resourceProviderFactory, hostComponentResourceProvider);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
@@ -257,7 +299,21 @@ public class HostComponentResourceProviderTest {
   }
 
   @Test
-  public void testUpdateResources() throws Exception {
+  public void testUpdateResourcesAsAdministrator() throws Exception {
+    testUpdateResources(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testUpdateResourcesAsClusterAdministrator() throws Exception {
+    testUpdateResources(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test
+  public void testUpdateResourcesAsServiceAdministrator() throws Exception {
+    testUpdateResources(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  private void testUpdateResources(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.HostComponent;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
@@ -285,6 +341,7 @@ public class HostComponentResourceProviderTest {
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.findServiceName(cluster, "Component100")).andReturn("Service100").anyTimes();
     expect(clusters.getCluster("Cluster102")).andReturn(cluster).anyTimes();
+    expect(cluster.getClusterId()).andReturn(2L).anyTimes();
     expect(cluster.getService("Service100")).andReturn(service).anyTimes();
     expect(service.getServiceComponent("Component100")).andReturn(component).anyTimes();
     expect(component.getServiceComponentHost("Host100")).andReturn(componentHost).anyTimes();
@@ -317,8 +374,8 @@ public class HostComponentResourceProviderTest {
     provider.setFieldValue("maintenanceStateHelper", maintenanceStateHelper);
     provider.setFieldValue("hostVersionDAO", hostVersionDAO);
 
-    expect(resourceProviderFactory.getHostComponentResourceProvider(anyObject(Set.class),
-        anyObject(Map.class),
+    expect(resourceProviderFactory.getHostComponentResourceProvider(EasyMock.<Set<String>>anyObject(),
+        EasyMock.<Map<Type,String>>anyObject(),
         eq(managementController))).
         andReturn(provider).anyTimes();
 
@@ -326,6 +383,8 @@ public class HostComponentResourceProviderTest {
     replay(managementController, response, resourceProviderFactory, clusters, cluster, service,
         component, componentHost, stageContainer, maintenanceStateHelper);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     Map<String, Object> properties = new LinkedHashMap<String, Object>();
 
     properties.put(HostComponentResourceProvider.HOST_COMPONENT_STATE_PROPERTY_ID, "STARTED");
@@ -351,7 +410,21 @@ public class HostComponentResourceProviderTest {
 
 
   @Test
-  public void testDeleteResources() throws Exception {
+  public void testDeleteResourcesAsAdministrator() throws Exception {
+    testDeleteResources(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testDeleteResourcesAsClusterAdministrator() throws Exception {
+    testDeleteResources(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testDeleteResourcesAsServiceAdministrator() throws Exception {
+    testDeleteResources(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  private void testDeleteResources(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.HostComponent;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
@@ -360,8 +433,8 @@ public class HostComponentResourceProviderTest {
 
     HostComponentResourceProvider provider =
         new HostComponentResourceProvider(PropertyHelper.getPropertyIds(type),
-        PropertyHelper.getKeyPropertyIds(type),
-        managementController, injector);
+            PropertyHelper.getKeyPropertyIds(type),
+            managementController, injector);
 
     // set expectations
     expect(managementController.deleteHostComponents(
@@ -371,6 +444,8 @@ public class HostComponentResourceProviderTest {
     // replay
     replay(managementController, response);
 
+    SecurityContextHolder.getContext().setAuthentication(authentication);
+
     AbstractResourceProviderTest.TestObserver observer = new AbstractResourceProviderTest.TestObserver();
 
     provider.addObserver(observer);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f08db5c9/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 36286e7..d1bf6f4 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
@@ -28,7 +28,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.ClusterRequest;
 import org.apache.ambari.server.controller.ConfigurationRequest;
@@ -83,11 +82,10 @@ public class JMXHostProviderTest {
     injector.getInstance(GuiceJpaInitializer.class);
     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"));
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator());
   }
 
   @After
@@ -99,7 +97,8 @@ public class JMXHostProviderTest {
   }
 
   private void createService(String clusterName,
-                             String serviceName, State desiredState) throws AmbariException {
+                             String serviceName, State desiredState)
+      throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();
@@ -112,7 +111,7 @@ public class JMXHostProviderTest {
 
   private void createServiceComponent(String clusterName,
                                       String serviceName, String componentName, State desiredState)
-    throws AmbariException {
+      throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();
@@ -127,7 +126,7 @@ public class JMXHostProviderTest {
 
   private void createServiceComponentHost(String clusterName,
                                           String serviceName, String componentName, String hostname,
-                                          State desiredState) throws AmbariException {
+                                          State desiredState) throws AmbariException, AuthorizationException {
     String dStateStr = null;
     if (desiredState != null) {
       dStateStr = desiredState.toString();
@@ -152,9 +151,6 @@ public class JMXHostProviderTest {
     String componentName2 = "DATANODE";
     String componentName3 = "HDFS_CLIENT";
 
-    Map<String, String> mapRequestProps = new HashMap<String, String>();
-    mapRequestProps.put("context", "Called from a test");
-
     createServiceComponent(clusterName, serviceName, componentName1,
       State.INIT);
     createServiceComponent(clusterName, serviceName, componentName2,
@@ -390,7 +386,7 @@ public class JMXHostProviderTest {
     providerModule.managementController = managementControllerMock;
 
     Set<String> result = providerModule.getHostNames("c1", "DATANODE");
-    Assert.assertTrue(result.iterator().next().toString().equals("host1"));
+    Assert.assertTrue(result.iterator().next().equals("host1"));
 
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f08db5c9/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
index 22aa124..b3168f2 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
@@ -24,6 +24,7 @@ import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.createNiceMock;
 import static org.easymock.EasyMock.eq;
 import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.newCapture;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.reset;
 import static org.easymock.EasyMock.verify;
@@ -61,15 +62,20 @@ import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
 import org.apache.ambari.server.orm.dao.HostRoleCommandStatusSummaryDTO;
 import org.apache.ambari.server.orm.dao.RequestDAO;
 import org.apache.ambari.server.orm.entities.RequestEntity;
+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.topology.LogicalRequest;
 import org.apache.ambari.server.topology.TopologyManager;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
+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;
 
 /**
  * RequestResourceProvider tests.
@@ -111,6 +117,10 @@ public class RequestResourceProviderTest {
     field.set(null, topologyManager);
   }
 
+  @After
+  public void cleanAuthentication() {
+    SecurityContextHolder.getContext().setAuthentication(null);
+  }
 
   @Test
   public void testCreateResources() throws Exception {
@@ -234,7 +244,7 @@ public class RequestResourceProviderTest {
     expect(requestMock.getRequestContext()).andReturn("this is a context").anyTimes();
     expect(requestMock.getRequestId()).andReturn(100L).anyTimes();
 
-    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();
+    Capture<Collection<Long>> requestIdsCapture = newCapture();
 
     // set expectations
     expect(managementController.getActionManager()).andReturn(actionManager);
@@ -284,7 +294,7 @@ public class RequestResourceProviderTest {
     expect(requestMock.getRequestId()).andReturn(100L).anyTimes();
     expect(requestMock.getRequestScheduleId()).andReturn(11L).anyTimes();
 
-    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();
+    Capture<Collection<Long>> requestIdsCapture = newCapture();
 
     // set expectations
     expect(managementController.getActionManager()).andReturn(actionManager);
@@ -337,7 +347,7 @@ public class RequestResourceProviderTest {
     expect(requestMock.getRequestId()).andReturn(100L).anyTimes();
     expect(requestMock.getRequestScheduleId()).andReturn(null).anyTimes();
 
-    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();
+    Capture<Collection<Long>> requestIdsCapture = newCapture();
 
     // set expectations
     expect(managementController.getActionManager()).andReturn(actionManager);
@@ -394,7 +404,7 @@ public class RequestResourceProviderTest {
     expect(requestMock.getClusterId()).andReturn(50L).anyTimes();
     expect(requestMock.getRequestId()).andReturn(100L).anyTimes();
 
-    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();
+    Capture<Collection<Long>> requestIdsCapture = newCapture();
 
     // set expectations
     expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();
@@ -464,7 +474,7 @@ public class RequestResourceProviderTest {
     expect(requestMock1.getRequestContext()).andReturn("this is a context").anyTimes();
     expect(requestMock1.getRequestId()).andReturn(101L).anyTimes();
 
-    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();
+    Capture<Collection<Long>> requestIdsCapture = newCapture();
 
     // set expectations
     expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();
@@ -518,7 +528,7 @@ public class RequestResourceProviderTest {
     expect(requestMock1.getRequestContext()).andReturn("this is a context").anyTimes();
     expect(requestMock1.getRequestId()).andReturn(101L).anyTimes();
 
-    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();
+    Capture<Collection<Long>> requestIdsCapture = newCapture();
 
     // set expectations
     expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();
@@ -752,7 +762,7 @@ public class RequestResourceProviderTest {
 
     expect(stage.getOrderedHostRoleCommands()).andReturn(hostRoleCommands).anyTimes();
 
-    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();
+    Capture<Collection<Long>> requestIdsCapture = newCapture();
 
     // set expectations
     expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();
@@ -871,21 +881,54 @@ public class RequestResourceProviderTest {
   }
 
   @Test
-  public void testCreateResourcesForCommands() throws Exception {
+  public void testCreateResourcesForCommandsAsAdministrator() throws Exception {
+    testCreateResourcesForCommands(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testCreateResourcesForCommandsAsClusterAdministrator() throws Exception {
+    testCreateResourcesForCommands(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test
+  public void testCreateResourcesForCommandsAsServiceAdministrator() throws Exception {
+    testCreateResourcesForCommands(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  @Test
+  public void testCreateResourcesForCommandsAsServiceOperator() throws Exception {
+    testCreateResourcesForCommands(TestAuthenticationFactory.createServiceOperator());
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testCreateResourcesForCommandsAsClusterUser() throws Exception {
+    testCreateResourcesForCommands(TestAuthenticationFactory.createClusterUser());
+  }
+
+  private void testCreateResourcesForCommands(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.Request;
 
-    Capture<ExecuteActionRequest> actionRequest = new Capture<ExecuteActionRequest>();
-    Capture<HashMap<String, String>> propertyMap = new Capture<HashMap<String, String>>();
+    Capture<ExecuteActionRequest> actionRequest = newCapture();
+    Capture<HashMap<String, String>> propertyMap = newCapture();
+
+    Cluster cluster = createMock(Cluster.class);
+    expect(cluster.getClusterId()).andReturn(2L).anyTimes();
+
+    Clusters clusters = createMock(Clusters.class);
+    expect(clusters.getCluster("c1")).andReturn(cluster).anyTimes();
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
 
+    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.createAction(capture(actionRequest), capture(propertyMap)))
         .andReturn(response).anyTimes();
     expect(response.getMessage()).andReturn("Message").anyTimes();
 
     // replay
-    replay(managementController, response);
+    replay(cluster, clusters, managementController, response);
+
+    SecurityContextHolder.getContext().setAuthentication(authentication);
 
     // 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>>();
@@ -934,20 +977,53 @@ public class RequestResourceProviderTest {
   }
 
   @Test
-  public void testCreateResourcesForCommandsWithParams() throws Exception {
+  public void testCreateResourcesForCommandsWithParamsAsAdministrator() throws Exception {
+    testCreateResourcesForCommandsWithParams(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testCreateResourcesForCommandsWithParamsAsClusterAdministrator() throws Exception {
+    testCreateResourcesForCommandsWithParams(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test
+  public void testCreateResourcesForCommandsWithParamsAsServiceAdministrator() throws Exception {
+    testCreateResourcesForCommandsWithParams(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  @Test
+  public void testCreateResourcesForCommandsWithParamsAsServiceOperator() throws Exception {
+    testCreateResourcesForCommandsWithParams(TestAuthenticationFactory.createServiceOperator());
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testCreateResourcesForCommandsWithParamsAsClusterUser() throws Exception {
+    testCreateResourcesForCommandsWithParams(TestAuthenticationFactory.createClusterUser());
+  }
+
+  private void testCreateResourcesForCommandsWithParams(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.Request;
 
-    Capture<ExecuteActionRequest> actionRequest = new Capture<ExecuteActionRequest>();
-    Capture<HashMap<String, String>> propertyMap = new Capture<HashMap<String, String>>();
+    Capture<ExecuteActionRequest> actionRequest = newCapture();
+    Capture<HashMap<String, String>> propertyMap = newCapture();
+
+    Cluster cluster = createMock(Cluster.class);
+    expect(cluster.getClusterId()).andReturn(2L).anyTimes();
+
+    Clusters clusters = createMock(Clusters.class);
+    expect(clusters.getCluster("c1")).andReturn(cluster).anyTimes();
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
 
+    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.createAction(capture(actionRequest), capture(propertyMap)))
         .andReturn(response).anyTimes();
     expect(response.getMessage()).andReturn("Message").anyTimes();
     // replay
-    replay(managementController, response);
+    replay(cluster, clusters, managementController, response);
+
+    SecurityContextHolder.getContext().setAuthentication(authentication);
 
     // 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>>();
@@ -1021,21 +1097,54 @@ public class RequestResourceProviderTest {
   }
 
   @Test
-  public void testCreateResourcesForCommandsWithOpLvl() throws Exception {
+  public void testCreateResourcesForCommandsWithOpLvlAsAdministrator() throws Exception {
+    testCreateResourcesForCommandsWithOpLvl(TestAuthenticationFactory.createAdministrator());
+  }
+
+  @Test
+  public void testCreateResourcesForCommandsWithOpLvlAsClusterAdministrator() throws Exception {
+    testCreateResourcesForCommandsWithOpLvl(TestAuthenticationFactory.createClusterAdministrator());
+  }
+
+  @Test
+  public void testCreateResourcesForCommandsWithOpLvlAsServiceAdministrator() throws Exception {
+    testCreateResourcesForCommandsWithOpLvl(TestAuthenticationFactory.createServiceAdministrator());
+  }
+
+  @Test
+  public void testCreateResourcesForCommandsWithOpLvlAsServiceOperator() throws Exception {
+    testCreateResourcesForCommandsWithOpLvl(TestAuthenticationFactory.createServiceOperator());
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testCreateResourcesForCommandsWithOpLvlAsClusterUser() throws Exception {
+    testCreateResourcesForCommandsWithOpLvl(TestAuthenticationFactory.createClusterUser());
+  }
+
+  private void testCreateResourcesForCommandsWithOpLvl(Authentication authentication) throws Exception {
     Resource.Type type = Resource.Type.Request;
 
-    Capture<ExecuteActionRequest> actionRequest = new Capture<ExecuteActionRequest>();
-    Capture<HashMap<String, String>> propertyMap = new Capture<HashMap<String, String>>();
+    Capture<ExecuteActionRequest> actionRequest = newCapture();
+    Capture<HashMap<String, String>> propertyMap = newCapture();
+
+    Cluster cluster = createMock(Cluster.class);
+    expect(cluster.getClusterId()).andReturn(2L).anyTimes();
+
+    Clusters clusters = createMock(Clusters.class);
+    expect(clusters.getCluster("c1")).andReturn(cluster).anyTimes();
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
 
+    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.createAction(capture(actionRequest), capture(propertyMap)))
             .andReturn(response).anyTimes();
     expect(response.getMessage()).andReturn("Message").anyTimes();
 
     // replay
-    replay(managementController, response);
+    replay(cluster, clusters, managementController, response);
+
+    SecurityContextHolder.getContext().setAuthentication(authentication);
 
     // 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>>();
@@ -1098,8 +1207,8 @@ public class RequestResourceProviderTest {
   public void testCreateResourcesForNonCluster() throws Exception {
     Resource.Type type = Resource.Type.Request;
 
-    Capture<ExecuteActionRequest> actionRequest = new Capture<ExecuteActionRequest>();
-    Capture<HashMap<String, String>> propertyMap = new Capture<HashMap<String, String>>();
+    Capture<ExecuteActionRequest> actionRequest = newCapture();
+    Capture<HashMap<String, String>> propertyMap = newCapture();
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
@@ -1165,7 +1274,7 @@ public class RequestResourceProviderTest {
     expect(requestMock.getRequestContext()).andReturn("this is a context").anyTimes();
     expect(requestMock.getRequestId()).andReturn(100L).anyTimes();
 
-    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();
+    Capture<Collection<Long>> requestIdsCapture = newCapture();
 
     // set expectations
     expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();
@@ -1221,7 +1330,7 @@ public class RequestResourceProviderTest {
     expect(requestMock.getRequestContext()).andReturn("this is a context").anyTimes();
     expect(requestMock.getRequestId()).andReturn(100L).anyTimes();
 
-    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();
+    Capture<Collection<Long>> requestIdsCapture = newCapture();
 
     // set expectations
     expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();


Mime
View raw message