justinmclean opened a new issue, #8033:
URL: https://github.com/apache/gravitino/issues/8033
### What would you like to be improved?
In
api/src/main/java/org/apache/gravitino/credential/SupportsCredentials.java
SupportsCredentials#getCredential should only flag duplicates among credentials
of the requested type, avoiding false positives when multiple credential types
exist.
Here is some test code that should help explain the issue:
```
public class TestSupportsCredentials {
static class DummyCredential implements Credential {
private final String type;
DummyCredential(String type) { this.type = type; }
@Override
public String credentialType() { return type; }
@Override
public long expireTimeInMs() { return 0; }
@Override
public Map<String, String> credentialInfo() { return ImmutableMap.of(); }
@Override
public void initialize(Map<String, String> credentialInfo, long
expireTimeInMs) {}
}
static class DummySupports implements SupportsCredentials {
private final Credential[] credentials;
DummySupports(Credential... credentials) { this.credentials =
credentials; }
@Override
public Credential[] getCredentials() { return credentials; }
}
@Test
public void testGetCredentialReturnsMatchingCredential() throws Exception {
Credential c1 = new DummyCredential("typeA");
Credential c2 = new DummyCredential("typeB");
SupportsCredentials sc = new DummySupports(c1, c2);
Assertions.assertEquals(c1, sc.getCredential("typeA"));
}
@Test
public void testGetCredentialThrowsWhenMultipleSameType() {
Credential c1 = new DummyCredential("typeA");
Credential c2 = new DummyCredential("typeA");
SupportsCredentials sc = new DummySupports(c1, c2);
Assertions.assertThrows(IllegalStateException.class, () ->
sc.getCredential("typeA"));
}
}
```
### How should we improve?
check the filteredCredentials length not the credential length.
--
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]