|
@@ -93,6 +93,7 @@ import org.apache.hadoop.net.DNSToSwitchMapping;
|
|
import org.apache.hadoop.net.NetUtils;
|
|
import org.apache.hadoop.net.NetUtils;
|
|
import org.apache.hadoop.net.ScriptBasedMapping;
|
|
import org.apache.hadoop.net.ScriptBasedMapping;
|
|
import org.apache.hadoop.net.StaticMapping;
|
|
import org.apache.hadoop.net.StaticMapping;
|
|
|
|
+import org.apache.hadoop.security.AccessControlException;
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
import org.apache.hadoop.test.GenericTestUtils;
|
|
import org.apache.hadoop.test.GenericTestUtils;
|
|
import org.apache.hadoop.util.DataChecksum;
|
|
import org.apache.hadoop.util.DataChecksum;
|
|
@@ -1561,6 +1562,27 @@ public class TestDistributedFileSystem {
|
|
fs.removeErasureCodingPolicy(policyName);
|
|
fs.removeErasureCodingPolicy(policyName);
|
|
assertEquals(policyName, ErasureCodingPolicyManager.getInstance().
|
|
assertEquals(policyName, ErasureCodingPolicyManager.getInstance().
|
|
getRemovedPolicies().get(0).getName());
|
|
getRemovedPolicies().get(0).getName());
|
|
|
|
+
|
|
|
|
+ // remove erasure coding policy as a user without privilege
|
|
|
|
+ UserGroupInformation fakeUGI = UserGroupInformation.createUserForTesting(
|
|
|
|
+ "ProbablyNotARealUserName", new String[] {"ShangriLa"});
|
|
|
|
+ final MiniDFSCluster finalCluster = cluster;
|
|
|
|
+ fakeUGI.doAs(new PrivilegedExceptionAction<Object>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Object run() throws Exception {
|
|
|
|
+ DistributedFileSystem fs = finalCluster.getFileSystem();
|
|
|
|
+ try {
|
|
|
|
+ fs.removeErasureCodingPolicy(policyName);
|
|
|
|
+ fail();
|
|
|
|
+ } catch (AccessControlException ace) {
|
|
|
|
+ GenericTestUtils.assertExceptionContains("Access denied for user " +
|
|
|
|
+ "ProbablyNotARealUserName. Superuser privilege is required",
|
|
|
|
+ ace);
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
} finally {
|
|
} finally {
|
|
if (cluster != null) {
|
|
if (cluster != null) {
|
|
cluster.shutdown();
|
|
cluster.shutdown();
|
|
@@ -1609,6 +1631,34 @@ public class TestDistributedFileSystem {
|
|
GenericTestUtils.assertExceptionContains("does not exists", e);
|
|
GenericTestUtils.assertExceptionContains("does not exists", e);
|
|
// pass
|
|
// pass
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // disable and enable erasure coding policy as a user without privilege
|
|
|
|
+ UserGroupInformation fakeUGI = UserGroupInformation.createUserForTesting(
|
|
|
|
+ "ProbablyNotARealUserName", new String[] {"ShangriLa"});
|
|
|
|
+ final MiniDFSCluster finalCluster = cluster;
|
|
|
|
+ fakeUGI.doAs(new PrivilegedExceptionAction<Object>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Object run() throws Exception {
|
|
|
|
+ DistributedFileSystem fs = finalCluster.getFileSystem();
|
|
|
|
+ try {
|
|
|
|
+ fs.disableErasureCodingPolicy(policyName);
|
|
|
|
+ fail();
|
|
|
|
+ } catch (AccessControlException ace) {
|
|
|
|
+ GenericTestUtils.assertExceptionContains("Access denied for user " +
|
|
|
|
+ "ProbablyNotARealUserName. Superuser privilege is required",
|
|
|
|
+ ace);
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ fs.enableErasureCodingPolicy(policyName);
|
|
|
|
+ fail();
|
|
|
|
+ } catch (AccessControlException ace) {
|
|
|
|
+ GenericTestUtils.assertExceptionContains("Access denied for user " +
|
|
|
|
+ "ProbablyNotARealUserName. Superuser privilege is required",
|
|
|
|
+ ace);
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
} finally {
|
|
} finally {
|
|
if (cluster != null) {
|
|
if (cluster != null) {
|
|
cluster.shutdown();
|
|
cluster.shutdown();
|