|
19 | 19 |
|
20 | 20 | import org.junit.jupiter.api.Test; |
21 | 21 |
|
| 22 | +import org.apache.hadoop.fs.Path; |
22 | 23 | import org.apache.hadoop.mapred.JobConf; |
23 | 24 | import org.apache.hadoop.mapreduce.MRConfig; |
24 | 25 | import org.apache.hadoop.mapreduce.MRJobConfig; |
| 26 | +import org.apache.hadoop.yarn.conf.YarnConfiguration; |
25 | 27 |
|
26 | 28 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
27 | 29 | import static org.junit.jupiter.api.Assertions.assertThrows; |
@@ -110,6 +112,22 @@ public void testTurnOff() { |
110 | 112 | assertPass(conf); |
111 | 113 | } |
112 | 114 |
|
| 115 | + @Test |
| 116 | + public void testJobConfigCanNotOverwriteMapreduceConfig() { |
| 117 | + JobConf mapreduceConf = new JobConf(); |
| 118 | + mapreduceConf.setBoolean(MRConfig.SECURITY_ENABLED, true); |
| 119 | + mapreduceConf.setStrings(MRConfig.SECURITY_DENIED_TASKS, "org.apache.hadoop.streaming"); |
| 120 | + mapreduceConf.setStrings(MRConfig.SECURITY_ALLOWED_USERS, "alice"); |
| 121 | + |
| 122 | + JobConf jobConf = new JobConf(); |
| 123 | + jobConf.setStrings(MRConfig.SECURITY_ALLOWED_USERS, "bob"); |
| 124 | + jobConf.set(MRJobConfig.MAP_CLASS_ATTR, "org.apache.hadoop.streaming.PipeMapper"); |
| 125 | + jobConf.set(MRJobConfig.USER_NAME, "bob"); |
| 126 | + |
| 127 | + mapreduceConf.addResource(jobConf); |
| 128 | + assertDenied(mapreduceConf); |
| 129 | + } |
| 130 | + |
113 | 131 | private void assertPass(JobConf conf) { |
114 | 132 | assertDoesNotThrow( |
115 | 133 | () -> TaskLevelSecurityEnforcer.validate(conf), |
|
0 commit comments