diff --git a/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java b/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java index 33ea0d4aa..fb902fe69 100644 --- a/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java +++ b/src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java @@ -63,11 +63,6 @@ public class ClientDevicesAuthService extends PluginService { // TODO: Move configuration related constants to appropriate configuration class public static final String DEVICE_GROUPS_TOPICS = "deviceGroups"; - public static final String PERFORMANCE_TOPIC = "performance"; - public static final String MAX_ACTIVE_AUTH_TOKENS_TOPIC = "maxActiveAuthTokens"; - public static final String CLOUD_REQUEST_QUEUE_SIZE_TOPIC = "cloudRequestQueueSize"; - public static final String MAX_CONCURRENT_CLOUD_REQUESTS_TOPIC = "maxConcurrentCloudRequests"; - public static final int DEFAULT_MAX_ACTIVE_AUTH_TOKENS = 2500; /** diff --git a/src/main/java/com/aws/greengrass/clientdevices/auth/session/SessionConfig.java b/src/main/java/com/aws/greengrass/clientdevices/auth/session/SessionConfig.java index 2db1dad0f..a4111d620 100644 --- a/src/main/java/com/aws/greengrass/clientdevices/auth/session/SessionConfig.java +++ b/src/main/java/com/aws/greengrass/clientdevices/auth/session/SessionConfig.java @@ -12,19 +12,18 @@ import java.util.concurrent.atomic.AtomicInteger; -import static com.aws.greengrass.clientdevices.auth.ClientDevicesAuthService.DEFAULT_MAX_ACTIVE_AUTH_TOKENS; -import static com.aws.greengrass.clientdevices.auth.ClientDevicesAuthService.MAX_ACTIVE_AUTH_TOKENS_TOPIC; -import static com.aws.greengrass.clientdevices.auth.ClientDevicesAuthService.PERFORMANCE_TOPIC; - @SuppressWarnings("PMD.DataClass") public class SessionConfig { private static final Logger LOGGER = LogManager.getLogger(SessionConfig.class); - public static final int DEFAULT_SESSION_CAPACITY = DEFAULT_MAX_ACTIVE_AUTH_TOKENS; + public static final int DEFAULT_SESSION_CAPACITY = 2500; // valid session capacity should be within range [1, Integer.MAX_VALUE) // to be able to initialize and perform appropriate eviction check in LRU session cache public static final int MIN_SESSION_CAPACITY = 1; public static final int MAX_SESSION_CAPACITY = Integer.MAX_VALUE - 1; + public static final String PERFORMANCE_TOPIC = "performance"; + public static final String MAX_ACTIVE_AUTH_TOKENS_TOPIC = "maxActiveAuthTokens"; + private final AtomicInteger sessionCapacity = new AtomicInteger(DEFAULT_SESSION_CAPACITY); private final Topics configuration; diff --git a/src/test/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthServiceTest.java b/src/test/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthServiceTest.java index 51fa0268b..62e250662 100644 --- a/src/test/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthServiceTest.java +++ b/src/test/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthServiceTest.java @@ -69,8 +69,6 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import static com.aws.greengrass.clientdevices.auth.ClientDevicesAuthService.MAX_ACTIVE_AUTH_TOKENS_TOPIC; -import static com.aws.greengrass.clientdevices.auth.ClientDevicesAuthService.PERFORMANCE_TOPIC; import static com.aws.greengrass.lifecyclemanager.GreengrassService.RUNTIME_STORE_NAMESPACE_TOPIC; import static com.aws.greengrass.testcommons.testutilities.ExceptionLogProtector.ignoreExceptionOfType; import static org.hamcrest.MatcherAssert.assertThat; @@ -393,13 +391,6 @@ void GIVEN_certificateAuthorityConfiguration_WHEN_itChanges_THEN_CAisConfigured( kernel.getContext().waitForPublishQueueToClear(); verify(managedCAUseCase, times(1)).apply(configurationCaptor.capture()); verify(customCAUseCase, times(2)).apply(configurationCaptor.capture()); - - topics.lookup(KernelConfigResolver.CONFIGURATION_CONFIG_KEY,PERFORMANCE_TOPIC, MAX_ACTIVE_AUTH_TOKENS_TOPIC) - .withValue(2); - - kernel.getContext().waitForPublishQueueToClear(); - verify(managedCAUseCase, times(1)).apply(configurationCaptor.capture()); - verify(customCAUseCase, times(2)).apply(configurationCaptor.capture()); } @Test diff --git a/src/test/java/com/aws/greengrass/clientdevices/auth/session/SessionConfigTest.java b/src/test/java/com/aws/greengrass/clientdevices/auth/session/SessionConfigTest.java index b46116951..aaf6b7cb8 100644 --- a/src/test/java/com/aws/greengrass/clientdevices/auth/session/SessionConfigTest.java +++ b/src/test/java/com/aws/greengrass/clientdevices/auth/session/SessionConfigTest.java @@ -17,9 +17,9 @@ import java.io.IOException; import static com.aws.greengrass.componentmanager.KernelConfigResolver.CONFIGURATION_CONFIG_KEY; -import static com.aws.greengrass.clientdevices.auth.ClientDevicesAuthService.DEFAULT_MAX_ACTIVE_AUTH_TOKENS; -import static com.aws.greengrass.clientdevices.auth.ClientDevicesAuthService.MAX_ACTIVE_AUTH_TOKENS_TOPIC; -import static com.aws.greengrass.clientdevices.auth.ClientDevicesAuthService.PERFORMANCE_TOPIC; +import static com.aws.greengrass.clientdevices.auth.session.SessionConfig.DEFAULT_SESSION_CAPACITY; +import static com.aws.greengrass.clientdevices.auth.session.SessionConfig.PERFORMANCE_TOPIC; +import static com.aws.greengrass.clientdevices.auth.session.SessionConfig.MAX_ACTIVE_AUTH_TOKENS_TOPIC; import static com.aws.greengrass.clientdevices.auth.session.SessionConfig.MAX_SESSION_CAPACITY; import static com.aws.greengrass.clientdevices.auth.session.SessionConfig.MIN_SESSION_CAPACITY; import static org.hamcrest.MatcherAssert.assertThat; @@ -44,12 +44,12 @@ void afterEach() throws IOException { @Test public void GIVEN_no_configured_capacity_WHEN_getSessionCapacity_THEN_returns_default_capacity() { - assertThat(sessionConfig.getSessionCapacity(), is(equalTo(DEFAULT_MAX_ACTIVE_AUTH_TOKENS))); + assertThat(sessionConfig.getSessionCapacity(), is(equalTo(DEFAULT_SESSION_CAPACITY))); } @Test public void GIVEN_default_session_capacity_WHEN_update_configuration_THEN_returns_updated_capacity() { - assertThat(sessionConfig.getSessionCapacity(), is(equalTo(DEFAULT_MAX_ACTIVE_AUTH_TOKENS))); + assertThat(sessionConfig.getSessionCapacity(), is(equalTo(DEFAULT_SESSION_CAPACITY))); int newCapacity = 1; configurationTopics.lookup(PERFORMANCE_TOPIC, MAX_ACTIVE_AUTH_TOKENS_TOPIC) .withValue(newCapacity);