justinmclean opened a new issue, #8162:
URL: https://github.com/apache/gravitino/issues/8162
### What would you like to be improved?
Correct
clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoConfig.java so that
OAuth and Kerberos authentication data is detected using the parsed authType
rather than the constant key.
These tests should help:
```
@Test
public void oauthConfigFile() throws IOException {
File tempFile = new File(System.getProperty("java.io.tmpdir") +
"/oauth_config.properties");
Properties props = new Properties();
props.setProperty("auth", "oauth");
props.setProperty("serverURI", "http://oauth.example.com");
props.setProperty("credential", "cred");
props.setProperty("token", "token");
props.setProperty("scope", "scope");
try (Writer writer = Files.newBufferedWriter(tempFile.toPath(),
StandardCharsets.UTF_8)) {
props.store(writer, "OAuth Config");
}
GravitinoConfig config = new GravitinoConfig(tempFile.getAbsolutePath());
config.read();
assertEquals("oauth", config.getGravitinoAuthType());
assertNotNull(config.getOAuth());
assertEquals("http://oauth.example.com",
config.getOAuth().getServerURI());
assertEquals("cred", config.getOAuth().getCredential());
assertEquals("token", config.getOAuth().getToken());
assertEquals("scope", config.getOAuth().getScope());
tempFile.delete();
}
@Test
public void kerberosConfigFile() throws IOException {
File tempFile =
new File(System.getProperty("java.io.tmpdir") +
"/kerberos_config.properties");
Properties props = new Properties();
props.setProperty("auth", "kerberos");
props.setProperty("principal", "user@REALM");
props.setProperty("keytabFile", "/path/to/keytab");
try (Writer writer = Files.newBufferedWriter(tempFile.toPath(),
StandardCharsets.UTF_8)) {
props.store(writer, "Kerberos Config");
}
GravitinoConfig config = new GravitinoConfig(tempFile.getAbsolutePath());
config.read();
assertEquals("kerberos", config.getGravitinoAuthType());
assertNotNull(config.getKerberos());
assertEquals("user@REALM", config.getKerberos().getPrincipal());
assertEquals("/path/to/keytab", config.getKerberos().getKeytabFile());
tempFile.delete();
}
```
### How should we improve?
See above
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]