### Question:
DefaultAuthorizationProvider implements AuthorizationProvider { @Override public void authorizeEntity(String entityName, String entityType, AccessControlList acl, String action, UserGroupInformation authenticatedUGI) throws AuthorizationException { try { LOG.info("Authorizing authenticatedUser={}, action={}, entity={}, type{}", authenticatedUGI.getShortUserName(), action, entityName, entityType); if (isSuperUser(authenticatedUGI)) { return; } checkUser(entityName, acl.getOwner(), acl.getGroup(), action, authenticatedUGI); } catch (IOException e) { throw new AuthorizationException(e); } } DefaultAuthorizationProvider(); boolean isSuperUser(UserGroupInformation authenticatedUGI); @Override boolean shouldProxy(UserGroupInformation authenticatedUGI,
                               final String aclOwner,
                               final String aclGroup); @Override void authorizeResource(String resource, String action,
                                  String entityType, String entityName,
                                  UserGroupInformation authenticatedUGI); @Override void authorizeEntity(String entityName, String entityType, AccessControlList acl,
                                String action, UserGroupInformation authenticatedUGI);  }### Answer:
@Test public void testAuthorizeValidatePOSTOperations() throws Exception { StartupProperties.get().setProperty("falcon.security.authorization.admin.users", "admin"); StartupProperties.get().setProperty("falcon.security.authorization.admin.groups", "admin"); UserGroupInformation proxyUgi = UserGroupInformation.createProxyUserForTesting( "admin", realUser, new String[]{"admin", }); EntityBuilderTestUtil.addProcessACL(processEntity, "admin", "admin"); DefaultAuthorizationProvider provider = new DefaultAuthorizationProvider(); provider.authorizeEntity(processEntity.getName(), "process", processEntity.getACL(), "submit", proxyUgi); }
@Test public void testAuthorizeValidatePOSTOperationsGroupBadUser() throws Exception { StartupProperties.get().setProperty("falcon.security.authorization.enabled", "true"); StartupProperties.get().setProperty("falcon.security.authorization.admin.users", "admin"); StartupProperties.get().setProperty("falcon.security.authorization.admin.groups", "admin"); UserGroupInformation proxyUgi = UserGroupInformation.createProxyUserForTesting( "admin", realUser, new String[]{"admin", }); EntityBuilderTestUtil.addProcessACL(processEntity, "admin-user", "admin"); DefaultAuthorizationProvider provider = new DefaultAuthorizationProvider(); provider.authorizeEntity(processEntity.getName(), "process", processEntity.getACL(), "submit", proxyUgi); }
@Test (expectedExceptions = AuthorizationException.class) public void testAuthorizeValidatePOSTOperationsBadUserAndGroup() throws Exception { StartupProperties.get().setProperty("falcon.security.authorization.enabled", "true"); StartupProperties.get().setProperty("falcon.security.authorization.admin.users", "admin"); StartupProperties.get().setProperty("falcon.security.authorization.admin.groups", "admin"); UserGroupInformation proxyUgi = UserGroupInformation.createProxyUserForTesting( "admin", realUser, new String[]{"admin", }); EntityBuilderTestUtil.addProcessACL(processEntity, "admin-user", "admin-group"); DefaultAuthorizationProvider provider = new DefaultAuthorizationProvider(); provider.authorizeEntity(processEntity.getName(), "process", processEntity.getACL(), "submit", proxyUgi); }