-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-19342. SaslRpcServer.AuthMethod print INFO messages in client side #7173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with this | ||
| * work for additional information regarding copyright ownership. The ASF | ||
| * licenses this file to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| * License for the specific language governing permissions and limitations under | ||
| * the License. | ||
| */ | ||
| package org.apache.hadoop.security; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
|
||
| import org.apache.hadoop.test.GenericTestUtils; | ||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.slf4j.event.Level; | ||
|
|
||
| import java.io.OutputStream; | ||
| import java.net.URLDecoder; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Paths; | ||
| import java.nio.file.StandardOpenOption; | ||
|
|
||
| import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_SASL_MECHANISM_KEY; | ||
|
|
||
| /** Test {@link SaslRpcServer.AuthMethod}. */ | ||
| public class TestAuthMethod { | ||
|
||
| @Test | ||
| public void testConfiguration() throws Exception { | ||
| final Logger log = LoggerFactory.getLogger("org.apache.hadoop.security.SaslMechanismFactory"); | ||
| GenericTestUtils.setLogLevel(log, Level.TRACE); | ||
|
|
||
| // init the mechanism | ||
| final String mechanism = "TEST-MECHANISM"; | ||
| initConf(mechanism, log); | ||
|
|
||
| // test get from new conf | ||
| final Configuration conf = new Configuration(); | ||
| final String confValue = conf.get(HADOOP_SECURITY_SASL_MECHANISM_KEY); | ||
| log.info("getConf: {} = {}", HADOOP_SECURITY_SASL_MECHANISM_KEY, confValue); | ||
| Assert.assertEquals(mechanism, confValue); | ||
|
|
||
| // test AuthMethod | ||
| Assert.assertEquals(mechanism, SaslRpcServer.AuthMethod.TOKEN.getMechanismName()); | ||
|
|
||
| // the mechanism won't change after initialized | ||
| final String newMechanism = "NEW-MECHANISM"; | ||
| initConf(newMechanism, log); | ||
| Assert.assertEquals(mechanism, SaslRpcServer.AuthMethod.TOKEN.getMechanismName()); | ||
| } | ||
|
|
||
| static void initConf(String mechanism, Logger log) throws Exception { | ||
| final Configuration conf = new Configuration(); | ||
| conf.set(HADOOP_SECURITY_SASL_MECHANISM_KEY, mechanism); | ||
| log.info("setConf: {} = {}", HADOOP_SECURITY_SASL_MECHANISM_KEY, mechanism); | ||
|
|
||
| final String coreSite = URLDecoder.decode(conf.getResource("core-site.xml").getPath(), "UTF-8"); | ||
| try (OutputStream out = Files.newOutputStream(Paths.get(coreSite), StandardOpenOption.CREATE)) { | ||
| conf.writeXml(out); | ||
| } | ||
| Configuration.addDefaultResource(coreSite); | ||
|
||
| log.info("writeXml: {}", coreSite); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT this ultimately gets called at roughly the same point during client initialization as previously, it just doesn't show up because the debug level has been reduced to DEBUG from INFO.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So apart from the log level the only difference is that this will pick up changes in the config
if a new SaslRPCServer is created at a later time ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you aren't using SASL stuff
saslMechanismFactory::getMechanismdoesn't get invoked.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will load the config only when
SaslMechanismFactory.getMechanismis called. So, it won't be loaded with UGI.