From 072dc7f19d631643bc19819f8de7ceb098274a12 Mon Sep 17 00:00:00 2001 From: Andy Witrisna Date: Tue, 18 Jun 2024 09:52:15 -0700 Subject: [PATCH] SDKS-3279 Support file base configuration for forgerock_oauth_sign_out_redirect_uri --- .../src/main/java/org/forgerock/android/auth/ConfigHelper.kt | 4 +++- forgerock-auth/src/main/res/values/strings.xml | 3 ++- .../test/java/org/forgerock/android/auth/ConfigHelperTest.kt | 2 +- .../test/java/org/forgerock/android/auth/FRUserMockTest.java | 1 + forgerock-auth/src/test/res/values/strings.xml | 3 ++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/forgerock-auth/src/main/java/org/forgerock/android/auth/ConfigHelper.kt b/forgerock-auth/src/main/java/org/forgerock/android/auth/ConfigHelper.kt index 4f5f8e86..bd123c76 100644 --- a/forgerock-auth/src/main/java/org/forgerock/android/auth/ConfigHelper.kt +++ b/forgerock-auth/src/main/java/org/forgerock/android/auth/ConfigHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 - 2023 ForgeRock. All rights reserved. + * Copyright (c) 2022 - 2024 ForgeRock. All rights reserved. * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -156,6 +156,8 @@ internal class ConfigHelper { oauthCacheSeconds = context.resources.getInteger(R.integer.forgerock_oauth_cache) .toLong() + oauthSignOutRedirectUri = + context.getString(R.string.forgerock_oauth_sign_out_redirect_uri) } sslPinning { pins = context.resources diff --git a/forgerock-auth/src/main/res/values/strings.xml b/forgerock-auth/src/main/res/values/strings.xml index f2c8dc4a..38d3b0cf 100644 --- a/forgerock-auth/src/main/res/values/strings.xml +++ b/forgerock-auth/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ 0 + place holder place holder diff --git a/forgerock-auth/src/test/java/org/forgerock/android/auth/ConfigHelperTest.kt b/forgerock-auth/src/test/java/org/forgerock/android/auth/ConfigHelperTest.kt index cdb0dc65..e0c756fc 100644 --- a/forgerock-auth/src/test/java/org/forgerock/android/auth/ConfigHelperTest.kt +++ b/forgerock-auth/src/test/java/org/forgerock/android/auth/ConfigHelperTest.kt @@ -214,7 +214,7 @@ class ConfigHelperTest { @Test fun loadDefaultFROptionWithNull() { val defaultOption = ConfigHelper.load(context, null) - val expectedResult = "FROptions(server=Server(url=https://openam.example.com:8081/openam, realm=root, timeout=30, cookieName=iPlanetDirectoryPro, cookieCacheSeconds=0), oauth=OAuth(oauthClientId=andy_app, oauthRedirectUri=https://www.example.com:8080/callback, oauthSignOutRedirectUri=, oauthScope=openid email address, oauthThresholdSeconds=30, oauthCacheSeconds=0), service=Service(authServiceName=Test, registrationServiceName=Registration), urlPath=UrlPath(authenticateEndpoint=, revokeEndpoint=, sessionEndpoint=, tokenEndpoint=, userinfoEndpoint=, authorizeEndpoint=, endSessionEndpoint=), sslPinning=SSLPinning(buildSteps=[], pins=[9hNxmEFgLKGJXqgp61hyb8yIyiT9u0vgDZh4y8TmY/M=]), logger=Log(logLevel=null, customLogger=null))" + val expectedResult = "FROptions(server=Server(url=https://openam.example.com:8081/openam, realm=root, timeout=30, cookieName=iPlanetDirectoryPro, cookieCacheSeconds=0), oauth=OAuth(oauthClientId=andy_app, oauthRedirectUri=https://www.example.com:8080/callback, oauthSignOutRedirectUri=https://www.example.com:8080/signout, oauthScope=openid email address, oauthThresholdSeconds=30, oauthCacheSeconds=0), service=Service(authServiceName=Test, registrationServiceName=Registration), urlPath=UrlPath(authenticateEndpoint=, revokeEndpoint=, sessionEndpoint=, tokenEndpoint=, userinfoEndpoint=, authorizeEndpoint=, endSessionEndpoint=), sslPinning=SSLPinning(buildSteps=[], pins=[9hNxmEFgLKGJXqgp61hyb8yIyiT9u0vgDZh4y8TmY/M=]), logger=Log(logLevel=null, customLogger=null))" assertTrue(defaultOption.toString() == expectedResult) } diff --git a/forgerock-auth/src/test/java/org/forgerock/android/auth/FRUserMockTest.java b/forgerock-auth/src/test/java/org/forgerock/android/auth/FRUserMockTest.java index 4868f103..e3082a42 100644 --- a/forgerock-auth/src/test/java/org/forgerock/android/auth/FRUserMockTest.java +++ b/forgerock-auth/src/test/java/org/forgerock/android/auth/FRUserMockTest.java @@ -940,6 +940,7 @@ public void testCustomEndpointAndCookieName() throws InterruptedException, Execu when(mockContext.getString(R.string.forgerock_endsession_endpoint)).thenReturn("dummy/endSession"); when(mockContext.getString(R.string.forgerock_cookie_name)).thenReturn("testCookieName"); when(mockContext.getString(R.string.forgerock_auth_service)).thenReturn("UsernamePassword"); + when(mockContext.getString(R.string.forgerock_oauth_sign_out_redirect_uri)).thenReturn(context.getString(R.string.forgerock_oauth_sign_out_redirect_uri)); enqueue("/authTreeMockTest_Authenticate_NameCallback.json", HttpURLConnection.HTTP_OK); enqueue("/authTreeMockTest_Authenticate_PasswordCallback.json", HttpURLConnection.HTTP_OK); diff --git a/forgerock-auth/src/test/res/values/strings.xml b/forgerock-auth/src/test/res/values/strings.xml index c404586b..0e146a53 100644 --- a/forgerock-auth/src/test/res/values/strings.xml +++ b/forgerock-auth/src/test/res/values/strings.xml @@ -1,5 +1,5 @@ andy_app https://www.example.com:8080/callback + https://www.example.com:8080/signout openid email address https://openam.example.com:8081/openam 30