From 5e0015777ea05550faccbce4e8f04ad34bdc8f80 Mon Sep 17 00:00:00 2001 From: aviadl Date: Wed, 18 Jun 2025 21:15:27 +0300 Subject: [PATCH] Load inbound app by client id + test fixes https://github.com/descope/etc/issues/11088 --- pom.xml | 2 +- .../com/descope/sdk/mgmt/InboundAppsService.java | 2 ++ .../sdk/mgmt/impl/InboundAppsServiceImpl.java | 10 ++++++++++ .../sdk/mgmt/impl/InboundAppsServiceImplTest.java | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 51c0e8b2..639c8dad 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.descope java-sdk 4.0.0 - 1.0.43 + 1.0.44 ${project.groupId}:${project.artifactId} Java library used to integrate with Descope. https://github.com/descope/descope-java diff --git a/src/main/java/com/descope/sdk/mgmt/InboundAppsService.java b/src/main/java/com/descope/sdk/mgmt/InboundAppsService.java index 95aa29ab..012e2aab 100644 --- a/src/main/java/com/descope/sdk/mgmt/InboundAppsService.java +++ b/src/main/java/com/descope/sdk/mgmt/InboundAppsService.java @@ -21,6 +21,8 @@ public interface InboundAppsService { InboundApp loadApplication(String id) throws DescopeException; + InboundApp loadApplicationByClientId(String id) throws DescopeException; + String getApplicationSecret(String id) throws DescopeException; String rotateApplicationSecret(String id) throws DescopeException; diff --git a/src/main/java/com/descope/sdk/mgmt/impl/InboundAppsServiceImpl.java b/src/main/java/com/descope/sdk/mgmt/impl/InboundAppsServiceImpl.java index 5c1e5f04..7658c682 100644 --- a/src/main/java/com/descope/sdk/mgmt/impl/InboundAppsServiceImpl.java +++ b/src/main/java/com/descope/sdk/mgmt/impl/InboundAppsServiceImpl.java @@ -99,6 +99,16 @@ public InboundApp loadApplication(String id) throws DescopeException { return apiProxy.get(getQueryParamUri(MANAGEMENT_INBOUND_LOAD_APP, mapOf("id", id)), InboundApp.class); } + @Override + public InboundApp loadApplicationByClientId(String id) throws DescopeException { + if (StringUtils.isBlank(id)) { + throw ServerCommonException.invalidArgument("id"); + } + + ApiProxy apiProxy = getApiProxy(); + return apiProxy.get(getQueryParamUri(MANAGEMENT_INBOUND_LOAD_APP, mapOf("clientId", id)), InboundApp.class); + } + @Override public String getApplicationSecret(String id) throws DescopeException { if (StringUtils.isBlank(id)) { diff --git a/src/test/java/com/descope/sdk/mgmt/impl/InboundAppsServiceImplTest.java b/src/test/java/com/descope/sdk/mgmt/impl/InboundAppsServiceImplTest.java index 5cc9afb9..3df4f5a2 100644 --- a/src/test/java/com/descope/sdk/mgmt/impl/InboundAppsServiceImplTest.java +++ b/src/test/java/com/descope/sdk/mgmt/impl/InboundAppsServiceImplTest.java @@ -81,6 +81,9 @@ void testMethodsForMissingRequestParts() { thrown = assertThrows(ServerCommonException.class, () -> inboundAppsService.loadApplication("")); assertNotNull(thrown); assertEquals("The id argument is invalid", thrown.getMessage()); + thrown = assertThrows(ServerCommonException.class, () -> inboundAppsService.loadApplicationByClientId("")); + assertNotNull(thrown); + assertEquals("The id argument is invalid", thrown.getMessage()); thrown = assertThrows(ServerCommonException.class, () -> inboundAppsService.getApplicationSecret("")); assertNotNull(thrown); assertEquals("The id argument is invalid", thrown.getMessage()); @@ -154,6 +157,18 @@ void testLoadApplicationSuccess() { } } + @Test + void testLoadApplicationByClientSuccess() { + ApiProxy apiProxy = mock(ApiProxy.class); + doReturn(mockInboundApp).when(apiProxy).get(any(), any()); + try (MockedStatic mockedApiProxyBuilder = mockStatic(ApiProxyBuilder.class)) { + mockedApiProxyBuilder.when(() -> ApiProxyBuilder.buildProxy(any(), any())).thenReturn(apiProxy); + InboundApp app = inboundAppsService.loadApplicationByClientId("a"); + assertNotNull(app); + assertEquals("someId", app.getId()); + } + } + @Test void testGetApplicationSecretSuccess() { ApiProxy apiProxy = mock(ApiProxy.class);