Skip to content

Commit

Permalink
SDKS-3372 - ReCaptcha e2e test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
spetrov committed Sep 23, 2024
1 parent 56d157e commit 3276947
Show file tree
Hide file tree
Showing 6 changed files with 691 additions and 1 deletion.
6 changes: 6 additions & 0 deletions forgerock-integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,17 @@ dependencies {
androidTestImplementation(libs.androidx.biometric.ktx)
androidTestImplementation(libs.nimbus.jose.jwt)
androidTestImplementation(libs.okhttp)
androidTestImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.kotlinx.coroutines.test)

//For Application Pin
androidTestImplementation(libs.bcpkix.jdk15on)
androidTestImplementation(libs.androidx.security.crypto)

//App Integrity
androidTestImplementation(libs.integrity)

// Captcha
androidTestImplementation(libs.play.services.safetynet)
androidTestImplementation(libs.recaptchaEnterprise)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 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.
*/
package org.forgerock.android.auth.callback

import android.app.Application
import android.content.Context
import androidx.test.core.app.ApplicationProvider
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest
import org.assertj.core.api.Assertions
import org.forgerock.android.auth.FRAuth
import org.forgerock.android.auth.FROptionsBuilder
import org.forgerock.android.auth.FRSession
import org.forgerock.android.auth.Logger
import org.forgerock.android.auth.Logger.Companion.set
import org.forgerock.android.auth.Node
import org.forgerock.android.auth.NodeListener
import org.json.JSONObject
import org.junit.After
import org.junit.Assert
import org.junit.BeforeClass
import org.junit.Test
import java.util.concurrent.ExecutionException

/**
* e2e tests for [ReCaptchaEnterpriseCallback]
*/
open class ReCaptchaEnterpriseCallbackBaseTest {
@After
fun logoutSession() {
if (FRSession.getCurrentSession() != null) {
FRSession.getCurrentSession().logout()
}
}

companion object {
val context: Context = ApplicationProvider.getApplicationContext()
val application: Application = ApplicationProvider.getApplicationContext()

protected const val AM_URL: String = "https://localam.petrov.ca/openam"
protected const val REALM: String = "root"
protected const val OAUTH_CLIENT: String = "AndroidTest"
protected const val OAUTH_REDIRECT_URI: String = "org.forgerock.demo:/oauth2redirect"
protected const val SCOPE: String = "openid profile email address phone"
const val TREE: String = "TEST-e2e-recaptcha-enterprise"
const val USERNAME: String = "sdkuser"
const val RECAPTCHA_SITE_KEY: String = "6LfAykUqAAAAAE6aZOg9pNiS3XduyGZ5y-8U-z8B"

@JvmStatic
@BeforeClass
fun setUpSDK(): Unit {
set(Logger.Level.DEBUG)

val options = FROptionsBuilder.build {
server {
url = AM_URL
realm = REALM
}
oauth {
oauthClientId = OAUTH_CLIENT
oauthRedirectUri = OAUTH_REDIRECT_URI
oauthCacheSeconds = 0
oauthScope = SCOPE
}
service {
authServiceName = TREE
}
}

FRAuth.start(context, options)
}
}
}




Loading

0 comments on commit 3276947

Please sign in to comment.