ACCUMULO-4461: modified ClientOpts to prompt for missing password#154
ACCUMULO-4461: modified ClientOpts to prompt for missing password#154milleruntime wants to merge 3 commits into
Conversation
joshelser
left a comment
There was a problem hiding this comment.
Nit-picky things about throwing exceptions instead of returning null in expected situations.
| */ | ||
| public static Password promptUser() throws IOException { | ||
| if (System.console() == null) { | ||
| return null; |
There was a problem hiding this comment.
I'm thinking that throwing an exception here would be more clear. This method cannot properly function as the caller expected, so they should get a clear exception in this case (not just a null return value).
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
| if (pass != null) { |
There was a problem hiding this comment.
This becomes simpler too. Either we throw an RTE from the attempt to get a password, or we create a PasswordToken with the results. This method always gets to return a non-null value (woo!).
There was a problem hiding this comment.
I had something like that before running tests. TestClientOpts.test expects for that method and ones that call it to return null.
There was a problem hiding this comment.
That's a weird test. I feel like the fail() is the expected execution path (e.g. it's asserting that getPrincipal() throw an exception) and the assertNull() is an afterthought? I wouldn't be too worried about making sure the tests pass exactly as-is. This isn't public API, so the semantics are likely not well-defined.
There was a problem hiding this comment.
OK I like removing the null return. If I get rid of the try/catch, I'd have to make getToken() throw IOException which will touch a bunch of files.
There was a problem hiding this comment.
I will keep the try catch but remove the check for null
|
This looks good to me. I will try to find some time to test and merge. Thanks Mike! |
Started running a |
|
Uh oh. Looks like we have a failure in ReadWriteIT#sunnyDay() Kind of seems like we don't have a good understanding of commands/tools which need a username + credentials (password) and which don't. Maybe that's how we need to address the problem? |
|
Similar to the test error, this change also forces the user to enter password even when running stop-all.sh. Which is not necessary and cumbersome. |
|
@joshelser check out 52e5444 I tested the Admin commands and I couldn't find any that required password or auth token. This looks to be the only call to getToken that checks for null. |
|
Looks reasonable. Let's see what https://builds.apache.org/job/Accumulo-Pull-Requests/449/console does. It looks like it's doing the right thing. I tweaked this earlier this week to do a normal |
|
Ok cool. I ran mvn verify -Psunny locally but coudln't figure out why tests were failing on ShellServerIT trace https://github.com/apache/accumulo/blob/1.7/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java#L1444 |
Yeah, that one is flaky. Don't worry about it :) |
Closes #154 Signed-off-by: Josh Elser <elserj@apache.org>
Created promptUser() to prompt the user on the console for a password if one is missing. If System.console is null, it will return null causing getToken() to return null (like it does currently).