You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2018/12/13 14:51:43 UTC

[GitHub] klion26 commented on a change in pull request #7294: [FLINK-11126][YARN][security] Filter out AMRMToken in the TaskManager credentials

klion26 commented on a change in pull request #7294: [FLINK-11126][YARN][security] Filter out AMRMToken in the TaskManager credentials
URL: https://github.com/apache/flink/pull/7294#discussion_r241425568
 
 

 ##########
 File path: flink-yarn/src/test/java/org/apache/flink/yarn/YarnApplicationMasterRunnerTest.java
 ##########
 @@ -108,5 +131,39 @@ public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
 		ContainerLaunchContext ctx = Utils.createTaskExecutorContext(flinkConf, yarnConf, env, tmParams,
 			taskManagerConf, workingDirectory, taskManagerMainClass, LOG);
 		assertEquals("file", ctx.getLocalResources().get("flink.jar").getResource().getScheme());
+
+		Credentials credentials = new Credentials();
+		try (DataInputStream dis = new DataInputStream(new ByteArrayInputStream(ctx.getTokens().array()))) {
+			credentials.readTokenStorageStream(dis);
+		}
+		Collection<Token<? extends TokenIdentifier>> tokens = credentials.getAllTokens();
+		boolean hasHdfsDelegationToken = false;
+		boolean hasAmRmToken = false;
+		for (Token<? extends TokenIdentifier> token : tokens) {
+			if (token.getKind().equals(amRmTokenKind)) {
+				hasAmRmToken = true;
+			} else if (token.getKind().equals(hdfsDelegationTokenKind)) {
+				hasHdfsDelegationToken = true;
+			}
+		}
+		assertTrue(hasHdfsDelegationToken);
+		assertFalse(hasAmRmToken);
+	}
+
+	// A helper method used for setting system env variables for the test.
+	// See https://stackoverflow.com/a/496849/6558955
+	private static void setEnv(Map<String, String> newEnv) throws Exception {
 
 Review comment:
   Maybe you could use `org.apache.flink.core.testutils.CommonTestUtils#setEnv`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services