Skip to content

Commit 0ace746

Browse files
committed
Update api and fix tests
1 parent d3d2e4a commit 0ace746

File tree

11 files changed

+163
-41
lines changed

11 files changed

+163
-41
lines changed

.circleci/config.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ orbs:
77

88
jobs:
99
unit-test:
10-
executor:
10+
executor: &android_executor
1111
name: android/android_docker
12-
tag: 2025.04.1
13-
environment:
12+
tag: 2025.09.1
13+
resource_class: xlarge
14+
environment: &gradle_opts_environment
1415
GRADLE_OPTS: '
15-
-Dorg.gradle.jvmargs="-Xmx3g -XX:+HeapDumpOnOutOfMemoryError"
16+
-Dorg.gradle.jvmargs="-Xmx6g -XX:+HeapDumpOnOutOfMemoryError"
1617
-Dorg.gradle.daemon=false
1718
-Dorg.gradle.workers.max=3
1819
-Dkotlin.incremental=false'
@@ -33,9 +34,7 @@ jobs:
3334
- store_artifacts:
3435
path: ~/test-results/junit
3536
snyk-scan:
36-
executor:
37-
name: android/android_docker
38-
tag: 2025.04.1
37+
executor: *android_executor
3938
steps:
4039
- attach_workspace:
4140
at: ~/project
@@ -48,9 +47,8 @@ jobs:
4847
additional-arguments: "--configuration-matching=implementation"
4948

5049
build:
51-
executor:
52-
name: android/android_docker
53-
tag: 2025.04.1
50+
executor: *android_executor
51+
environment: *gradle_opts_environment
5452
steps:
5553
- checkout
5654
- android/restore_gradle_cache
@@ -71,9 +69,7 @@ jobs:
7169
destination: apks
7270

7371
spotless-check:
74-
executor:
75-
name: android/android_docker
76-
tag: 2025.04.1
72+
executor: *android_executor
7773
steps:
7874
- checkout
7975
- android/restore_gradle_cache
@@ -83,9 +79,7 @@ jobs:
8379
- android/save_gradle_cache
8480

8581
api-check:
86-
executor:
87-
name: android/android_docker
88-
tag: 2025.04.1
82+
executor: *android_executor
8983
steps:
9084
- checkout
9185
- android/restore_gradle_cache

auth-foundation/api/auth-foundation.api

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,70 @@ public final class com/okta/authfoundation/BiometricExceptionDetails$OnAuthentic
7272
public fun toString ()Ljava/lang/String;
7373
}
7474

75+
public abstract class com/okta/authfoundation/GrantType {
76+
public synthetic fun <init> (Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
77+
public final fun getValue ()Ljava/lang/String;
78+
}
79+
80+
public final class com/okta/authfoundation/GrantType$AuthorizationCode : com/okta/authfoundation/GrantType {
81+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$AuthorizationCode;
82+
}
83+
84+
public final class com/okta/authfoundation/GrantType$DeviceCode : com/okta/authfoundation/GrantType {
85+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$DeviceCode;
86+
}
87+
88+
public final class com/okta/authfoundation/GrantType$JwtBearer : com/okta/authfoundation/GrantType {
89+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$JwtBearer;
90+
}
91+
92+
public final class com/okta/authfoundation/GrantType$Oob : com/okta/authfoundation/GrantType {
93+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$Oob;
94+
}
95+
96+
public final class com/okta/authfoundation/GrantType$OobMfa : com/okta/authfoundation/GrantType {
97+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$OobMfa;
98+
}
99+
100+
public final class com/okta/authfoundation/GrantType$Other : com/okta/authfoundation/GrantType {
101+
public fun <init> (Ljava/lang/String;)V
102+
public final fun component1 ()Ljava/lang/String;
103+
public final fun copy (Ljava/lang/String;)Lcom/okta/authfoundation/GrantType$Other;
104+
public static synthetic fun copy$default (Lcom/okta/authfoundation/GrantType$Other;Ljava/lang/String;ILjava/lang/Object;)Lcom/okta/authfoundation/GrantType$Other;
105+
public fun equals (Ljava/lang/Object;)Z
106+
public final fun getType ()Ljava/lang/String;
107+
public fun hashCode ()I
108+
public fun toString ()Ljava/lang/String;
109+
}
110+
111+
public final class com/okta/authfoundation/GrantType$Otp : com/okta/authfoundation/GrantType {
112+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$Otp;
113+
}
114+
115+
public final class com/okta/authfoundation/GrantType$OtpMfa : com/okta/authfoundation/GrantType {
116+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$OtpMfa;
117+
}
118+
119+
public final class com/okta/authfoundation/GrantType$Password : com/okta/authfoundation/GrantType {
120+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$Password;
121+
}
122+
123+
public final class com/okta/authfoundation/GrantType$RefreshToken : com/okta/authfoundation/GrantType {
124+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$RefreshToken;
125+
}
126+
127+
public final class com/okta/authfoundation/GrantType$TokenExchange : com/okta/authfoundation/GrantType {
128+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$TokenExchange;
129+
}
130+
131+
public final class com/okta/authfoundation/GrantType$WebAuthn : com/okta/authfoundation/GrantType {
132+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$WebAuthn;
133+
}
134+
135+
public final class com/okta/authfoundation/GrantType$WebAuthnMfa : com/okta/authfoundation/GrantType {
136+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$WebAuthnMfa;
137+
}
138+
75139
public abstract interface annotation class com/okta/authfoundation/InternalAuthFoundationApi : java/lang/annotation/Annotation {
76140
}
77141

@@ -105,6 +169,65 @@ public final class com/okta/authfoundation/SdkDefaults {
105169
public final fun setGetTokenStorageFactory (Lkotlin/jvm/functions/Function0;)V
106170
}
107171

172+
public abstract interface class com/okta/authfoundation/api/http/AuthFoundationHttpEngine {
173+
public abstract fun execute-gIAlu-s (Lcom/okta/authfoundation/api/http/AuthFoundationHttpRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
174+
}
175+
176+
public final class com/okta/authfoundation/api/http/AuthFoundationHttpMethod : java/lang/Enum {
177+
public static final field DELETE Lcom/okta/authfoundation/api/http/AuthFoundationHttpMethod;
178+
public static final field GET Lcom/okta/authfoundation/api/http/AuthFoundationHttpMethod;
179+
public static final field PATCH Lcom/okta/authfoundation/api/http/AuthFoundationHttpMethod;
180+
public static final field POST Lcom/okta/authfoundation/api/http/AuthFoundationHttpMethod;
181+
public static final field PUT Lcom/okta/authfoundation/api/http/AuthFoundationHttpMethod;
182+
public static fun getEntries ()Lkotlin/enums/EnumEntries;
183+
public static fun valueOf (Ljava/lang/String;)Lcom/okta/authfoundation/api/http/AuthFoundationHttpMethod;
184+
public static fun values ()[Lcom/okta/authfoundation/api/http/AuthFoundationHttpMethod;
185+
}
186+
187+
public abstract interface class com/okta/authfoundation/api/http/AuthFoundationHttpRequest {
188+
public fun getBody ()[B
189+
public abstract fun getConnectTimeoutMs ()I
190+
public fun getFormParameters ()Ljava/util/Map;
191+
public abstract fun getHeaders ()Ljava/util/Map;
192+
public abstract fun getMethod ()Lcom/okta/authfoundation/api/http/AuthFoundationHttpMethod;
193+
public fun getParameters ()Ljava/util/Map;
194+
public abstract fun getReadTimeOutMs ()I
195+
public abstract fun getUri ()Ljava/lang/String;
196+
}
197+
198+
public final class com/okta/authfoundation/api/http/AuthFoundationHttpRequest$DefaultImpls {
199+
public static fun getBody (Lcom/okta/authfoundation/api/http/AuthFoundationHttpRequest;)[B
200+
public static fun getFormParameters (Lcom/okta/authfoundation/api/http/AuthFoundationHttpRequest;)Ljava/util/Map;
201+
public static fun getParameters (Lcom/okta/authfoundation/api/http/AuthFoundationHttpRequest;)Ljava/util/Map;
202+
}
203+
204+
public abstract interface class com/okta/authfoundation/api/http/AuthFoundationHttpResponse {
205+
public abstract fun getBody ()[B
206+
public abstract fun getContentLength ()I
207+
public abstract fun getContentType ()Ljava/lang/String;
208+
public abstract fun getHeaders ()Ljava/util/Map;
209+
public abstract fun getStatusCode ()I
210+
}
211+
212+
public abstract interface class com/okta/authfoundation/api/http/log/AuthFoundationLogger {
213+
public abstract fun write (Ljava/lang/String;Ljava/lang/Throwable;Lcom/okta/authfoundation/api/http/log/LogLevel;)V
214+
public static synthetic fun write$default (Lcom/okta/authfoundation/api/http/log/AuthFoundationLogger;Ljava/lang/String;Ljava/lang/Throwable;Lcom/okta/authfoundation/api/http/log/LogLevel;ILjava/lang/Object;)V
215+
}
216+
217+
public final class com/okta/authfoundation/api/http/log/AuthFoundationLogger$DefaultImpls {
218+
public static synthetic fun write$default (Lcom/okta/authfoundation/api/http/log/AuthFoundationLogger;Ljava/lang/String;Ljava/lang/Throwable;Lcom/okta/authfoundation/api/http/log/LogLevel;ILjava/lang/Object;)V
219+
}
220+
221+
public final class com/okta/authfoundation/api/http/log/LogLevel : java/lang/Enum {
222+
public static final field DEBUG Lcom/okta/authfoundation/api/http/log/LogLevel;
223+
public static final field ERROR Lcom/okta/authfoundation/api/http/log/LogLevel;
224+
public static final field INFO Lcom/okta/authfoundation/api/http/log/LogLevel;
225+
public static final field WARN Lcom/okta/authfoundation/api/http/log/LogLevel;
226+
public static fun getEntries ()Lkotlin/enums/EnumEntries;
227+
public static fun valueOf (Ljava/lang/String;)Lcom/okta/authfoundation/api/http/log/LogLevel;
228+
public static fun values ()[Lcom/okta/authfoundation/api/http/log/LogLevel;
229+
}
230+
108231
public abstract interface class com/okta/authfoundation/claims/ClaimsProvider {
109232
public abstract fun availableClaims ()Ljava/util/Set;
110233
public abstract fun deserializeClaim (Ljava/lang/String;Lkotlinx/serialization/DeserializationStrategy;)Ljava/lang/Object;

auth-foundation/src/test/java/com/okta/authfoundation/client/internal/SdkVersionsRegistryTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import org.robolectric.RobolectricTestRunner
2323

2424
@RunWith(RobolectricTestRunner::class)
2525
class SdkVersionsRegistryTest {
26-
private val defaultAndroidVersion = 21
26+
private val defaultAndroidVersion = 23
2727

2828
@Before fun reset() {
2929
SdkVersionsRegistry.reset()

oauth2/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,5 @@ dependencies {
7171
testImplementation(libs.robolectric)
7272
testImplementation(libs.bcprov.jdk18on)
7373
testImplementation(project(":test-helpers"))
74+
testImplementation(libs.androidx.test.ext.junit)
7475
}

oauth2/src/test/java/com/okta/oauth2/DeviceAuthorizationFlowTest.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.okta.oauth2
1717

18+
import androidx.test.ext.junit.runners.AndroidJUnit4
1819
import com.google.common.truth.Truth.assertThat
1920
import com.okta.authfoundation.client.OAuth2ClientResult
2021
import com.okta.authfoundation.client.OidcEndpoints
@@ -29,9 +30,11 @@ import kotlinx.coroutines.runBlocking
2930
import okhttp3.HttpUrl
3031
import org.junit.Rule
3132
import org.junit.Test
33+
import org.junit.runner.RunWith
3234
import org.mockito.kotlin.mock
3335
import java.util.concurrent.atomic.AtomicInteger
3436

37+
@RunWith(AndroidJUnit4::class)
3538
class DeviceAuthorizationFlowTest {
3639
private val mockPrefix = "test_responses"
3740
private val successBody =
@@ -63,7 +66,7 @@ class DeviceAuthorizationFlowTest {
6366
method("POST"),
6467
path("/oauth2/default/v1/device/authorize"),
6568
bodyPart("client_id", "unit_test_client_id"),
66-
bodyPart("scope", "openid%20email%20profile%20offline_access")
69+
bodyPart("scope", "openid+email+profile+offline_access")
6770
) { response ->
6871
response.setBody(minimalBody)
6972
}
@@ -106,7 +109,7 @@ class DeviceAuthorizationFlowTest {
106109
method("POST"),
107110
path("/oauth2/default/v1/device/authorize"),
108111
bodyPart("client_id", "unit_test_client_id"),
109-
bodyPart("scope", "openid%20email%20profile%20offline_access")
112+
bodyPart("scope", "openid+email+profile+offline_access")
110113
) { response ->
111114
response.setBody(successBody)
112115
}
@@ -128,7 +131,7 @@ class DeviceAuthorizationFlowTest {
128131
method("POST"),
129132
path("/oauth2/default/v1/device/authorize"),
130133
bodyPart("client_id", "unit_test_client_id"),
131-
bodyPart("scope", "openid%20email%20profile%20offline_access%20custom%3Aread"),
134+
bodyPart("scope", "openid+email+profile+offline_access+custom%3Aread"),
132135
bodyPart("foo", "bar")
133136
) { response ->
134137
response.setBody(successBody)
@@ -151,7 +154,7 @@ class DeviceAuthorizationFlowTest {
151154
oktaRule.enqueue(
152155
method("POST"),
153156
path("/oauth2/default/v1/device/authorize"),
154-
body("client_id=unit_test_client_id&scope=openid%20email%20profile%20offline_access")
157+
body("client_id=unit_test_client_id&scope=openid+email+profile+offline_access")
155158
) { response ->
156159
response.setResponseCode(500)
157160
}

oauth2/src/test/java/com/okta/oauth2/ResourceOwnerFlowTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ResourceOwnerFlowTest {
3737
oktaRule.enqueue(
3838
method("POST"),
3939
path("/oauth2/default/v1/token"),
40-
body("username=foo&password=bar&client_id=unit_test_client_id&grant_type=password&scope=openid%20email%20profile%20offline_access")
40+
body("username=foo&password=bar&client_id=unit_test_client_id&grant_type=password&scope=openid+email+profile+offline_access")
4141
) { response ->
4242
response.testBodyFromFile("$mockPrefix/token.json")
4343
}
@@ -61,7 +61,7 @@ class ResourceOwnerFlowTest {
6161
oktaRule.enqueue(
6262
method("POST"),
6363
path("/oauth2/default/v1/token"),
64-
body("username=foo&password=bar&client_id=unit_test_client_id&grant_type=password&scope=openid%20custom")
64+
body("username=foo&password=bar&client_id=unit_test_client_id&grant_type=password&scope=openid+custom")
6565
) { response ->
6666
response.testBodyFromFile("$mockPrefix/token.json")
6767
}

oauth2/src/test/java/com/okta/oauth2/SessionTokenFlowTest.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.okta.oauth2
1717

18+
import androidx.test.ext.junit.runners.AndroidJUnit4
1819
import com.google.common.truth.Truth.assertThat
1920
import com.okta.authfoundation.client.OAuth2ClientResult
2021
import com.okta.authfoundation.credential.Token
@@ -25,13 +26,11 @@ import com.okta.testhelpers.RequestMatchers.path
2526
import com.okta.testhelpers.RequestMatchers.query
2627
import com.okta.testhelpers.testBodyFromFile
2728
import kotlinx.coroutines.runBlocking
28-
import okhttp3.mockwebserver.SocketPolicy
2929
import org.junit.Rule
3030
import org.junit.Test
3131
import org.junit.runner.RunWith
32-
import org.robolectric.RobolectricTestRunner
3332

34-
@RunWith(RobolectricTestRunner::class)
33+
@RunWith(AndroidJUnit4::class)
3534
internal class SessionTokenFlowTest {
3635
private val mockPrefix = "test_responses"
3736

@@ -92,12 +91,7 @@ internal class SessionTokenFlowTest {
9291

9392
@Test fun testAuthorizationRequestFailure(): Unit =
9493
runBlocking {
95-
oktaRule.enqueue(
96-
method("GET"),
97-
path("/oauth2/default/v1/authorize")
98-
) { response ->
99-
response.socketPolicy = SocketPolicy.DISCONNECT_AFTER_REQUEST
100-
}
94+
oktaRule.mockWebServer.close()
10195
val sessionTokenFlow = SessionTokenFlow()
10296
val result = sessionTokenFlow.start("exampleSessionToken", "exampleRedirect:/callback")
10397

oauth2/src/test/java/com/okta/oauth2/TokenExchangeFlowTest.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.okta.oauth2
1717

18+
import androidx.test.ext.junit.runners.AndroidJUnit4
1819
import com.google.common.truth.Truth.assertThat
1920
import com.okta.authfoundation.client.OAuth2ClientResult
2021
import com.okta.authfoundation.credential.Token
@@ -25,7 +26,9 @@ import com.okta.testhelpers.RequestMatchers.path
2526
import kotlinx.coroutines.runBlocking
2627
import org.junit.Rule
2728
import org.junit.Test
29+
import org.junit.runner.RunWith
2830

31+
@RunWith(AndroidJUnit4::class)
2932
class TokenExchangeFlowTest {
3033
@get:Rule val oktaRule = OktaRule()
3134

@@ -48,7 +51,7 @@ class TokenExchangeFlowTest {
4851
method("POST"),
4952
path("/oauth2/default/v1/token"),
5053
body(
51-
"audience=api%3A%2F%2Fdefault&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aid_token&subject_token=foo&actor_token_type=urn%3Ax-oath%3Aparams%3Aoauth%3Atoken-type%3Adevice-secret&actor_token=bar&client_id=unit_test_client_id&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&scope=openid%20email%20profile%20offline_access"
54+
"audience=api%3A%2F%2Fdefault&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aid_token&subject_token=foo&actor_token_type=urn%3Ax-oath%3Aparams%3Aoauth%3Atoken-type%3Adevice-secret&actor_token=bar&client_id=unit_test_client_id&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&scope=openid+email+profile+offline_access"
5255
)
5356
) { response ->
5457
response.setResponseCode(503)
@@ -66,7 +69,7 @@ class TokenExchangeFlowTest {
6669
method("POST"),
6770
path("/oauth2/default/v1/token"),
6871
body(
69-
"audience=api%3A%2F%2Fdefault&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aid_token&subject_token=foo&actor_token_type=urn%3Ax-oath%3Aparams%3Aoauth%3Atoken-type%3Adevice-secret&actor_token=bar&client_id=unit_test_client_id&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&scope=openid%20email%20profile%20offline_access"
72+
"audience=api%3A%2F%2Fdefault&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aid_token&subject_token=foo&actor_token_type=urn%3Ax-oath%3Aparams%3Aoauth%3Atoken-type%3Adevice-secret&actor_token=bar&client_id=unit_test_client_id&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&scope=openid+email+profile+offline_access"
7073
)
7174
) { response ->
7275
val body =
@@ -96,7 +99,7 @@ class TokenExchangeFlowTest {
9699
method("POST"),
97100
path("/oauth2/default/v1/token"),
98101
body(
99-
"audience=non_default_audience&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aid_token&subject_token=foo&actor_token_type=urn%3Ax-oath%3Aparams%3Aoauth%3Atoken-type%3Adevice-secret&actor_token=bar&client_id=unit_test_client_id&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&scope=openid%20profile%20custom_for_test"
102+
"audience=non_default_audience&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aid_token&subject_token=foo&actor_token_type=urn%3Ax-oath%3Aparams%3Aoauth%3Atoken-type%3Adevice-secret&actor_token=bar&client_id=unit_test_client_id&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&scope=openid+profile+custom_for_test"
100103
)
101104
) { response ->
102105
val body =

0 commit comments

Comments
 (0)