Skip to content

Commit 4b5872a

Browse files
committed
fixup!
1 parent a1f4f7c commit 4b5872a

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

server/src/test/java/org/elasticsearch/plugins/internal/ReloadAwarePluginTests.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
package org.elasticsearch.plugins.internal;
1111

12+
import org.elasticsearch.cluster.metadata.ProjectId;
1213
import org.elasticsearch.common.settings.Settings;
1314
import org.elasticsearch.node.MockNode;
1415
import org.elasticsearch.plugins.Plugin;
@@ -57,20 +58,26 @@ public void setReloadCallback(ReloadablePlugin reloadablePlugin) {
5758

5859
public void invokeReloadOperation() throws Exception {
5960
reloadablePlugin.reload(Settings.EMPTY);
61+
reloadablePlugin.reload(randomUniqueProjectId(), Settings.EMPTY);
6062
}
6163
}
6264

6365
public static class TestReloadablePlugin extends Plugin implements ReloadablePlugin {
6466

65-
private boolean reloaded = false;
67+
private int reloadCount = 0;
6668

6769
@Override
6870
public void reload(Settings settings) throws Exception {
69-
reloaded = true;
71+
reloadCount++;
72+
}
73+
74+
@Override
75+
public void reload(ProjectId projectId, Settings settings) throws Exception {
76+
reloadCount++;
7077
}
7178

7279
public boolean isReloaded() {
73-
return reloaded;
80+
return reloadCount >= 2;
7481
}
7582
}
7683
}

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ public abstract class CachingUsernamePasswordRealm extends UsernamePasswordRealm
3636
private final UserAuthenticationCache cache;
3737
private final ThreadPool threadPool;
3838
private final boolean authenticationEnabled;
39-
protected final Hasher credentialHasher;
39+
protected final Hasher cacheHasher;
4040

4141
protected CachingUsernamePasswordRealm(RealmConfig config, ThreadPool threadPool) {
4242
this(config, threadPool, buildDefaultCache(config));
4343
}
4444

4545
protected CachingUsernamePasswordRealm(RealmConfig config, ThreadPool threadPool, UserAuthenticationCache cache) {
4646
super(config);
47-
credentialHasher = Hasher.resolve(this.config.getSetting(CachingUsernamePasswordRealmSettings.CACHE_HASH_ALGO_SETTING));
47+
cacheHasher = Hasher.resolve(this.config.getSetting(CachingUsernamePasswordRealmSettings.CACHE_HASH_ALGO_SETTING));
4848
this.threadPool = threadPool;
4949
this.authenticationEnabled = config.getSetting(CachingUsernamePasswordRealmSettings.AUTHC_ENABLED_SETTING);
5050
this.cache = cache;
@@ -255,9 +255,7 @@ private void authenticateWithCache(UsernamePasswordToken token, ActionListener<A
255255
// notify any forestalled request listeners; they will not reach to the
256256
// authentication request and instead will use this result if they contain
257257
// the same credentials
258-
listenableCacheEntry.onResponse(
259-
new CachedResult(authResult, credentialHasher, authResult.getValue(), token.credentials())
260-
);
258+
listenableCacheEntry.onResponse(new CachedResult(authResult, cacheHasher, authResult.getValue(), token.credentials()));
261259
listener.onResponse(authResult);
262260
}, e -> {
263261
cache.invalidate(token.principal(), listenableCacheEntry);
@@ -322,7 +320,7 @@ private void lookupWithCache(String username, ActionListener<User> listener) {
322320
if (false == lookupInCache.get()) {
323321
// attempt lookup against the user directory
324322
doLookupUser(username, ActionListener.wrap(user -> {
325-
final CachedResult result = new CachedResult(AuthenticationResult.notHandled(), credentialHasher, user, null);
323+
final CachedResult result = new CachedResult(AuthenticationResult.notHandled(), cacheHasher, user, null);
326324
if (user == null) {
327325
// user not found, invalidate cache so that subsequent requests are forwarded to
328326
// the user directory

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected void doLookupUser(String username, ActionListener<User> listener) {
102102
listener.onFailure(new UnsupportedOperationException("this method should not be called"));
103103
}
104104
};
105-
assertThat(realm.credentialHasher, sameInstance(Hasher.resolve(cachingHashAlgo)));
105+
assertThat(realm.cacheHasher, sameInstance(Hasher.resolve(cachingHashAlgo)));
106106
}
107107

108108
public void testCacheSizeWhenCacheDisabled() {

0 commit comments

Comments
 (0)