Skip to content

Commit c47d97f

Browse files
authored
Load inbound app by client id (#204)
+ test fixes descope/etc#11088
1 parent 90c3080 commit c47d97f

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>com.descope</groupId>
66
<artifactId>java-sdk</artifactId>
77
<modelVersion>4.0.0</modelVersion>
8-
<version>1.0.43</version>
8+
<version>1.0.44</version>
99
<name>${project.groupId}:${project.artifactId}</name>
1010
<description>Java library used to integrate with Descope.</description>
1111
<url>https://github.com/descope/descope-java</url>

src/main/java/com/descope/sdk/mgmt/InboundAppsService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public interface InboundAppsService {
2121

2222
InboundApp loadApplication(String id) throws DescopeException;
2323

24+
InboundApp loadApplicationByClientId(String id) throws DescopeException;
25+
2426
String getApplicationSecret(String id) throws DescopeException;
2527

2628
String rotateApplicationSecret(String id) throws DescopeException;

src/main/java/com/descope/sdk/mgmt/impl/InboundAppsServiceImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ public InboundApp loadApplication(String id) throws DescopeException {
9999
return apiProxy.get(getQueryParamUri(MANAGEMENT_INBOUND_LOAD_APP, mapOf("id", id)), InboundApp.class);
100100
}
101101

102+
@Override
103+
public InboundApp loadApplicationByClientId(String id) throws DescopeException {
104+
if (StringUtils.isBlank(id)) {
105+
throw ServerCommonException.invalidArgument("id");
106+
}
107+
108+
ApiProxy apiProxy = getApiProxy();
109+
return apiProxy.get(getQueryParamUri(MANAGEMENT_INBOUND_LOAD_APP, mapOf("clientId", id)), InboundApp.class);
110+
}
111+
102112
@Override
103113
public String getApplicationSecret(String id) throws DescopeException {
104114
if (StringUtils.isBlank(id)) {

src/test/java/com/descope/sdk/mgmt/impl/InboundAppsServiceImplTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ void testMethodsForMissingRequestParts() {
8181
thrown = assertThrows(ServerCommonException.class, () -> inboundAppsService.loadApplication(""));
8282
assertNotNull(thrown);
8383
assertEquals("The id argument is invalid", thrown.getMessage());
84+
thrown = assertThrows(ServerCommonException.class, () -> inboundAppsService.loadApplicationByClientId(""));
85+
assertNotNull(thrown);
86+
assertEquals("The id argument is invalid", thrown.getMessage());
8487
thrown = assertThrows(ServerCommonException.class, () -> inboundAppsService.getApplicationSecret(""));
8588
assertNotNull(thrown);
8689
assertEquals("The id argument is invalid", thrown.getMessage());
@@ -154,6 +157,18 @@ void testLoadApplicationSuccess() {
154157
}
155158
}
156159

160+
@Test
161+
void testLoadApplicationByClientSuccess() {
162+
ApiProxy apiProxy = mock(ApiProxy.class);
163+
doReturn(mockInboundApp).when(apiProxy).get(any(), any());
164+
try (MockedStatic<ApiProxyBuilder> mockedApiProxyBuilder = mockStatic(ApiProxyBuilder.class)) {
165+
mockedApiProxyBuilder.when(() -> ApiProxyBuilder.buildProxy(any(), any())).thenReturn(apiProxy);
166+
InboundApp app = inboundAppsService.loadApplicationByClientId("a");
167+
assertNotNull(app);
168+
assertEquals("someId", app.getId());
169+
}
170+
}
171+
157172
@Test
158173
void testGetApplicationSecretSuccess() {
159174
ApiProxy apiProxy = mock(ApiProxy.class);

0 commit comments

Comments
 (0)