mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
fix testcase
This commit is contained in:
parent
34fe0a6773
commit
086dfdab58
2 changed files with 10 additions and 6 deletions
|
|
@ -76,6 +76,8 @@ public class JDBCInterpreter extends Interpreter {
|
|||
private Logger logger = LoggerFactory.getLogger(JDBCInterpreter.class);
|
||||
|
||||
static final String INTERPRETER_NAME = "jdbc";
|
||||
static final String JDBC_DEFAULT_USER_KEY = "default.user";
|
||||
static final String JDBC_DEFAULT_PASSWORD_KEY = "default.password";
|
||||
static final String COMMON_KEY = "common";
|
||||
static final String MAX_LINE_KEY = "max_count";
|
||||
static final String MAX_LINE_DEFAULT = "1000";
|
||||
|
|
@ -330,15 +332,11 @@ public class JDBCInterpreter extends Interpreter {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean existAccountInProperty() {
|
||||
return property.containsKey("default.user") && property.containsKey("default.password");
|
||||
}
|
||||
|
||||
private UsernamePassword getUsernamePassword(InterpreterContext interpreterContext,
|
||||
String replName) {
|
||||
UserCredentials uc = interpreterContext.getAuthenticationInfo().getUserCredentials();
|
||||
if (uc != null) {
|
||||
return uc.existUsernamePassword(replName) ? uc.getUsernamePassword(replName) : null;
|
||||
return uc.getUsernamePassword(replName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -351,6 +349,11 @@ public class JDBCInterpreter extends Interpreter {
|
|||
return entityName.toString();
|
||||
}
|
||||
|
||||
private boolean existAccountInProperty() {
|
||||
return property.containsKey(JDBC_DEFAULT_USER_KEY) &&
|
||||
property.containsKey(JDBC_DEFAULT_PASSWORD_KEY);
|
||||
}
|
||||
|
||||
public void setAccountOfCredential(String propertyKey, InterpreterContext interpreterContext) {
|
||||
UsernamePassword usernamePassword = getUsernamePassword(interpreterContext,
|
||||
getEntityName(interpreterContext.getReplName()));
|
||||
|
|
|
|||
|
|
@ -265,11 +265,12 @@ public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
public void testMultiTenant() throws SQLException, IOException {
|
||||
String replName1 = "jdbc1";
|
||||
String replName2 = "jdbc2";
|
||||
String entityName = "jdbc.jdbc1";
|
||||
|
||||
// create an user credential with replName1(entity name).
|
||||
UserCredentials userCredentials = new UserCredentials();
|
||||
UsernamePassword up = new UsernamePassword("user2", "pass2");
|
||||
userCredentials.putUsernamePassword(replName1, up);
|
||||
userCredentials.putUsernamePassword(entityName, up);
|
||||
AuthenticationInfo authInfo = new AuthenticationInfo();
|
||||
authInfo.setUserCredentials(userCredentials);
|
||||
assertEquals(up.getUsername(), "user2");
|
||||
|
|
|
|||
Loading…
Reference in a new issue