Skip to content
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

Auth Manager API part 2: AuthManager #11809

Merged
merged 6 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
mainSession -> catalogSession
  • Loading branch information
adutra committed Dec 19, 2024
commit 52f4423858a7e217fba223d06bda0e25c1a440a5
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public interface AuthManager extends AutoCloseable {
* <p>This method cannot return null. By default, it returns the catalog session.
*/
default AuthSession initSession(RESTClient initClient, Map<String, String> properties) {
return mainSession(initClient, properties);
return catalogSession(initClient, properties);
}

/**
Expand All @@ -60,7 +60,7 @@ default AuthSession initSession(RESTClient initClient, Map<String, String> prope
* <p>It is not required to cache the returned session internally, as the catalog will keep it
* alive for the lifetime of the catalog.
*/
AuthSession mainSession(RESTClient sharedClient, Map<String, String> properties);
AuthSession catalogSession(RESTClient sharedClient, Map<String, String> properties);

/**
* Returns a session for a specific context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public final class BasicAuthManager implements AuthManager {

@Override
public AuthSession mainSession(RESTClient sharedClient, Map<String, String> properties) {
public AuthSession catalogSession(RESTClient sharedClient, Map<String, String> properties) {
Preconditions.checkArgument(
properties.containsKey(AuthProperties.BASIC_USERNAME),
"Invalid username: missing required property %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class NoopAuthManager implements AuthManager {

@Override
public AuthSession mainSession(RESTClient sharedClient, Map<String, String> properties) {
public AuthSession catalogSession(RESTClient sharedClient, Map<String, String> properties) {
return AuthSession.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TestBasicAuthManager {
@Test
void missingUsername() {
try (AuthManager authManager = new BasicAuthManager()) {
assertThatThrownBy(() -> authManager.mainSession(null, Map.of()))
assertThatThrownBy(() -> authManager.catalogSession(null, Map.of()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(
"Invalid username: missing required property %s", AuthProperties.BASIC_USERNAME);
Expand All @@ -41,7 +41,7 @@ void missingUsername() {
void missingPassword() {
try (AuthManager authManager = new BasicAuthManager()) {
Map<String, String> properties = Map.of(AuthProperties.BASIC_USERNAME, "alice");
assertThatThrownBy(() -> authManager.mainSession(null, properties))
assertThatThrownBy(() -> authManager.catalogSession(null, properties))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(
"Invalid password: missing required property %s", AuthProperties.BASIC_PASSWORD);
Expand All @@ -53,7 +53,7 @@ void success() {
Map<String, String> properties =
Map.of(AuthProperties.BASIC_USERNAME, "alice", AuthProperties.BASIC_PASSWORD, "secret");
try (AuthManager authManager = new BasicAuthManager();
AuthSession session = authManager.mainSession(null, properties)) {
AuthSession session = authManager.catalogSession(null, properties)) {
assertThat(session)
.isEqualTo(
DefaultAuthSession.of(HTTPHeaders.of(OAuth2Util.basicAuthHeaders("alice:secret"))));
Expand Down