diff --git a/README.md b/README.md index 11e06798..34533eb3 100644 --- a/README.md +++ b/README.md @@ -885,10 +885,10 @@ String idpUrl = "https://idp.com"; String entityId = "my-idp-entity-id"; String idpCert = ""; String redirectUrl = "https://my-app.com/handle-saml"; // Global redirect URL for SSO/SAML -String domain = "domain.com"; // Users logging in from this domain will be logged in to this tenant +List domains = Arrays.asList("domain.com"); // Users logging in from this domain will be logged in to this tenant try { - ss.configureSettings(tenantId, idpUrl, idpCert, entityId, redirectUrl, domain); + ss.configureSettings(tenantId, idpUrl, idpCert, entityId, redirectUrl, domains); } catch (DescopeException de) { // Handle the error } @@ -1204,6 +1204,7 @@ export DESCOPE_MANAGEMENT_KEY= ``` Alternatively, you can create a `.env` file in the working folder with your project ID and management key. + ``` DESCOPE_PROJECT_ID= DESCOPE_MANAGEMENT_KEY= @@ -1241,6 +1242,7 @@ To run Run and Debug using Visual Studio Code open the examples folder and run t Java provides a very simple way to mock services and objects using the Mockito package. Here is a simple example of how you can mock a magic link verify response. + ```java User user = new User("someUserName", MOCK_EMAIL, "+1-555-555-5555"); ApiProxy apiProxy = mock(ApiProxy.class); // Mock the proxy that actually sends the HTTP requests diff --git a/src/main/java/com/descope/model/sso/SSOSettingsResponse.java b/src/main/java/com/descope/model/sso/SSOSettingsResponse.java index 73d49fdf..a32f3404 100644 --- a/src/main/java/com/descope/model/sso/SSOSettingsResponse.java +++ b/src/main/java/com/descope/model/sso/SSOSettingsResponse.java @@ -22,5 +22,7 @@ public class SSOSettingsResponse { private UserMapping userMapping; private List groupsMapping; private String redirectURL; + private List domains; + // Deprecated - use domains instead private String domain; } diff --git a/src/main/java/com/descope/sdk/mgmt/SsoService.java b/src/main/java/com/descope/sdk/mgmt/SsoService.java index 06f1d635..de167559 100644 --- a/src/main/java/com/descope/sdk/mgmt/SsoService.java +++ b/src/main/java/com/descope/sdk/mgmt/SsoService.java @@ -12,7 +12,7 @@ public interface SsoService { void deleteSettings(String tenantID) throws DescopeException; void configureSettings(String tenantID, String idpURL, String idpCert, String entityID, - String redirectURL, String domain) throws DescopeException; + String redirectURL, List domains) throws DescopeException; void configureMetadata(String tenantID, String idpMetadataURL) throws DescopeException; diff --git a/src/main/java/com/descope/sdk/mgmt/impl/SsoServiceImpl.java b/src/main/java/com/descope/sdk/mgmt/impl/SsoServiceImpl.java index e55e0b10..170250a2 100644 --- a/src/main/java/com/descope/sdk/mgmt/impl/SsoServiceImpl.java +++ b/src/main/java/com/descope/sdk/mgmt/impl/SsoServiceImpl.java @@ -52,7 +52,7 @@ public void configureSettings( String idpCert, String entityID, String redirectURL, - String domain) + List domains) throws DescopeException { if (StringUtils.isBlank(tenantID)) { throw ServerCommonException.invalidArgument("TenantID"); @@ -69,7 +69,7 @@ public void configureSettings( if (StringUtils.isBlank(redirectURL)) { throw ServerCommonException.invalidArgument("RedirectURL"); } - Map request = + Map request = mapOf( "tenantId", tenantID, @@ -81,8 +81,8 @@ public void configureSettings( entityID, "redirectURL", redirectURL, - "domain", - domain); + "domains", + domains); ApiProxy apiProxy = getApiProxy(); apiProxy.post(getUri(SSO_CONFIGURE_SETTINGS_LINK), request, Void.class); } diff --git a/src/test/java/com/descope/sdk/mgmt/impl/SsoServiceImplTest.java b/src/test/java/com/descope/sdk/mgmt/impl/SsoServiceImplTest.java index 4b40276e..fe1241f9 100644 --- a/src/test/java/com/descope/sdk/mgmt/impl/SsoServiceImplTest.java +++ b/src/test/java/com/descope/sdk/mgmt/impl/SsoServiceImplTest.java @@ -86,7 +86,7 @@ void testConfigureSettingsForEmptyTenantId() { ServerCommonException.class, () -> ssoService.configureSettings( - "", "idpUrl", "idpCert", "entryId", "redirectUrl", "domain")); + "", "idpUrl", "idpCert", "entryId", "redirectUrl", Arrays.asList("domain.com"))); assertNotNull(thrown); assertEquals("The TenantID argument is invalid", thrown.getMessage()); } @@ -98,7 +98,7 @@ void testConfigureSettingsForEmptyIdpURL() { ServerCommonException.class, () -> ssoService.configureSettings( - "someTenantID", "", "idpCert", "entryId", "redirectUrl", "domain")); + "someTenantID", "", "idpCert", "entryId", "redirectUrl", Arrays.asList("domain.com"))); assertNotNull(thrown); assertEquals("The IdpURL argument is invalid", thrown.getMessage()); } @@ -110,7 +110,7 @@ void testConfigureSettingsForEmptyIdpCert() { ServerCommonException.class, () -> ssoService.configureSettings( - "someTenantID", "idpUrl", "", "entryId", "redirectUrl", "domain")); + "someTenantID", "idpUrl", "", "entryId", "redirectUrl", Arrays.asList("domain.com"))); assertNotNull(thrown); assertEquals("The IdpCert argument is invalid", thrown.getMessage()); } @@ -122,7 +122,7 @@ void testConfigureSettingsForEmptyEntityID() { ServerCommonException.class, () -> ssoService.configureSettings( - "someTenantID", "idpUrl", "idpCert", "", "redirectUrl", "domain")); + "someTenantID", "idpUrl", "idpCert", "", "redirectUrl", Arrays.asList("domain.com"))); assertNotNull(thrown); assertEquals("The EntityID argument is invalid", thrown.getMessage()); } @@ -134,7 +134,7 @@ void testConfigureSettingsForEmptyRedirectURL() { ServerCommonException.class, () -> ssoService.configureSettings( - "someTenantID", "idpUrl", "idpCert", "entryId", "", "domain")); + "someTenantID", "idpUrl", "idpCert", "entryId", "", Arrays.asList("domain.com"))); assertNotNull(thrown); assertEquals("The RedirectURL argument is invalid", thrown.getMessage()); } @@ -147,7 +147,7 @@ void testConfigureSettingsForSuccess() { mockedApiProxyBuilder.when( () -> ApiProxyBuilder.buildProxy(any(), any())).thenReturn(apiProxy); ssoService.configureSettings( - "someTenantID", "idpUrl", "idpCert", "entryId", "redirectUrl", "domain"); + "someTenantID", "idpUrl", "idpCert", "entryId", "redirectUrl", Arrays.asList("domain.com")); verify(apiProxy, times(1)).post(any(), any(), any()); } }