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

EUREKA-79: skip retrieving token if system user is disabled #266

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* [MODPUBSUB-283](https://folio-org.atlassian.net/browse/MODPUBSUB-283) Upgrade to RMB 35.1.1, folio-di-support 2.0.1, kafka-clients 3.6.0
* [MODPUBSUB-282](https://folio-org.atlassian.net/browse/MODPUBSUB-282) Allow disabling system user
* [MODPUBSUB-278](https://folio-org.atlassian.net/browse/MODPUBSUB-278) Remove default user password
*
* [EUREKA-79](https://folio-org.atlassian.net/browse/EUREKA-79) Skip retrieving token if system user is disabled

## 2023-10-13 v2.11.0
* [FOLIO-3678](https://issues.folio.org/browse/FOLIO-3678) Use API-related Workflows
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package org.folio.services.impl;

import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
Expand Down Expand Up @@ -167,7 +166,7 @@ protected Future<Void> deliverEvent(Event event, OkapiConnectionParams params) {
protected Handler<AsyncResult<RestUtil.WrappedResponse>> getEventDeliveredHandler(Event event, String tenantId, MessagingModule subscriber, OkapiConnectionParams params, Map<MessagingModule, AtomicInteger> retry) {
retry.get(subscriber).incrementAndGet();
return ar -> {
LOGGER.info("Delivering was complete. Checking for response...");
LOGGER.info("Delivering for event with ID {} was complete. Checking for response...", event.getId());
if (ar.failed()) {
String errorMessage = format("%s event with id '%s' was not delivered to %s", event.getEventType(), event.getId(), subscriber.getSubscriberCallback());
LOGGER.error(errorMessage, ar.cause());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public Future<String> getAccessToken(OkapiConnectionParams params) {
params.setToken(EMPTY);
final String tenantId = params.getTenantId();

if (!systemUserConfig.isCreateUser()) {
LOGGER.info("getAccessToken:: System user is disabled. Using empty token for tenant {}", tenantId);
return Future.succeededFuture(EMPTY);
}

String cachedAccessToken = cache.getAccessToken(tenantId);
if (!StringUtils.isEmpty(cachedAccessToken)) {
LOGGER.debug("getAccessToken:: Using cached access token for tenant {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,18 @@ public void shoulReturnFailedFutureWhenTokenCacheIsEmptyAndPubSubUserLoginFailed
});
}

@Test
public void shouldReturnSuccessFutureWithEmptyTokenIfSystemUserCreationDisabled(TestContext context) {
OkapiConnectionParams params = new OkapiConnectionParams(headers, vertx);

Future<String> future = securityManagerNoSystemUser.getAccessToken(params);

future.onComplete(ar -> {
context.assertTrue(ar.succeeded());
context.assertEquals("", ar.result());
});
}

@Test
public void shouldUpdateExistingUser(TestContext context) {
final String userId = UUID.randomUUID().toString();
Expand Down