Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ abstract class NativeAuthPublicClientApplicationAbstractTest : IPublicClientAppl
const val SHARED_PREFERENCES_NAME = "com.microsoft.identity.client.account_credential_cache"
const val INVALID_EMAIL = "email"
const val INVALID_PASSWORD = "password"
const val INCORRECT_CODE = "00000000"
}

private lateinit var context: Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.microsoft.identity.nativeauth.statemachine.results.ResetPasswordSubmi
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest
import org.junit.Assert
import org.junit.Ignore
import org.junit.Test

class SSPRTest : NativeAuthPublicClientApplicationAbstractTest() {
Expand Down Expand Up @@ -67,6 +68,7 @@ class SSPRTest : NativeAuthPublicClientApplicationAbstractTest() {
* Verify email with email OTP first and then reset password.
* (hero scenario 8 & 17, use case 3.1.1)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testSSPRSuccess() = runBlocking {
var result: ResetPasswordStartResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.microsoft.identity.nativeauth.statemachine.results.SignInResult
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest
import org.junit.Assert
import org.junit.Ignore
import org.junit.Test

class SignInEmailOTPTest : NativeAuthPublicClientApplicationAbstractTest() {
Expand All @@ -56,6 +57,7 @@ class SignInEmailOTPTest : NativeAuthPublicClientApplicationAbstractTest() {
* Use valid email and OTP to get token and sign in.
* (hero scenario 6, use case 2.2.1)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testSuccess() {
retryOperation {
Expand All @@ -76,10 +78,7 @@ class SignInEmailOTPTest : NativeAuthPublicClientApplicationAbstractTest() {
*/
@Test
fun testErrorIsUserNotFound() = runTest {
val user = config.email
// Turn correct username into an incorrect one
val invalidUser = user + "x"
val signInResult = application.signIn(invalidUser)
val signInResult = application.signIn(INVALID_EMAIL)
Assert.assertTrue(signInResult is SignInError)
Assert.assertTrue((signInResult as SignInError).isUserNotFound())
}
Expand All @@ -88,19 +87,15 @@ class SignInEmailOTPTest : NativeAuthPublicClientApplicationAbstractTest() {
* Use valid email address, but invalid OTP to receive "invalid code" error.
* (use case 2.2.7)
*/
@Ignore("The account has been locked. Ignoring test for now.")
@Test
fun testErrorIsInvalidCode() {
retryOperation {
runBlocking {// Running with runBlocking to avoid default 10 second execution timeout.
val user = config.email
val signInResult = application.signIn(user)
assertResult<SignInResult.CodeRequired>(signInResult)
fun testErrorIsInvalidCode() = runTest {
val user = config.email
val signInResult = application.signIn(user)
assertResult<SignInResult.CodeRequired>(signInResult)

val incorrectOtp = "1234"
val submitCodeResult = (signInResult as SignInResult.CodeRequired).nextState.submitCode(incorrectOtp)
Assert.assertTrue(submitCodeResult is SubmitCodeError)
Assert.assertTrue((submitCodeResult as SubmitCodeError).isInvalidCode())
}
}
val submitCodeResult = (signInResult as SignInResult.CodeRequired).nextState.submitCode(INCORRECT_CODE)
Assert.assertTrue(submitCodeResult is SubmitCodeError)
Assert.assertTrue((submitCodeResult as SubmitCodeError).isInvalidCode())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class SignInMFATest : NativeAuthPublicClientApplicationAbstractTest() {
*
* Note: this test also asserts whether the scopes requested at sign in are present in the token that's received at the end of the flow
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun `test submit invalid challenge, request new challenge, submit correct challenge and complete MFA flow`() {
config = getConfig(defaultConfigType)
Expand Down Expand Up @@ -133,6 +134,7 @@ class SignInMFATest : NativeAuthPublicClientApplicationAbstractTest() {
*
* Note: this test also asserts whether the scopes requested at sign in are present in the token that's received at the end of the flow
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun `test get other auth methods, request challenge on specific auth method and complete MFA flow`() {
config = getConfig(defaultConfigType)
Expand Down Expand Up @@ -204,6 +206,7 @@ class SignInMFATest : NativeAuthPublicClientApplicationAbstractTest() {
*
* Note: this test also asserts whether the scopes requested at sign in are present in the token that's received at the end of the flow
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun `test selection required, request challenge on specific auth method and complete MFA flow`() {
config = getConfig(ConfigType.SIGN_IN_MFA_MULTI_AUTH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.microsoft.identity.nativeauth.UserAttributes
import com.microsoft.identity.nativeauth.statemachine.results.SignUpResult
import kotlinx.coroutines.runBlocking
import org.junit.Assert
import org.junit.Ignore
import org.junit.Test

class SignUpEmailOTPAttributesTest : NativeAuthPublicClientApplicationAbstractTest() {
Expand All @@ -54,6 +55,7 @@ class SignUpEmailOTPAttributesTest : NativeAuthPublicClientApplicationAbstractTe
* Signup user with custom attributes with verify OTP as last step.
* (hero scenario 2, use case 2.1.2)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testSuccessAttributesFirst() {
retryOperation {
Expand All @@ -75,6 +77,7 @@ class SignUpEmailOTPAttributesTest : NativeAuthPublicClientApplicationAbstractTe
* Verify email OTP first and then collect custom attributes.
* (hero scenario 3, use case 2.1.3)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testSuccessAttributesLastSameScreen() {
retryOperation {
Expand Down Expand Up @@ -103,6 +106,7 @@ class SignUpEmailOTPAttributesTest : NativeAuthPublicClientApplicationAbstractTe
* Verify email OTP first and then collect custom attributes in multiple steps (mimicking a multi-screen UX).
* (hero scenario 4, use case 2.1.4)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testSuccessAttributesLastMultipleScreens() {
retryOperation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ class SignUpEmailOTPTest : NativeAuthPublicClientApplicationAbstractTest() {
* Sign up with email + OTP. Verify email address using email OTP and sign up.
* (hero scenario 1, use case 2.1.1)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@Test
fun testSuccess() {
config = getConfig(defaultConfigType)
application = setupPCA(config, defaultChallengeTypes)

retryOperation {
runBlocking { // Running with runBlocking to avoid default 10 second execution timeout.
val user = tempEmailApi.generateRandomEmailAddress()
val user = tempEmailApi.generateRandomEmailAddressLocally()
val signUpResult = application.signUp(user)
assertResult<SignUpResult.CodeRequired>(signUpResult)

Expand All @@ -73,14 +74,15 @@ class SignUpEmailOTPTest : NativeAuthPublicClientApplicationAbstractTest() {
* Sign up with email + OTP. Resend email OTP.
* (hero scenario 1, use case 2.1.5)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to ignore this test after you made the change around random email generation?

@Test
fun testResendCode() {
config = getConfig(defaultConfigType)
application = setupPCA(config, defaultChallengeTypes)

retryOperation {
runBlocking { // Running with runBlocking to avoid default 10 second execution timeout.
val user = tempEmailApi.generateRandomEmailAddress()
val user = tempEmailApi.generateRandomEmailAddressLocally()
val signUpResult = application.signUp(user)
assertResult<SignUpResult.CodeRequired>(signUpResult)
val otp1 = tempEmailApi.retrieveCodeFromInbox(user)
Expand Down Expand Up @@ -172,7 +174,7 @@ class SignUpEmailOTPTest : NativeAuthPublicClientApplicationAbstractTest() {

retryOperation {
runBlocking { // Running with runBlocking to avoid default 10 second execution timeout.
val user = tempEmailApi.generateRandomEmailAddress()
val user = tempEmailApi.generateRandomEmailAddressLocally()
val signUpResult = application.signUp(user)
assertResult<SignUpResult.CodeRequired>(signUpResult)
val otp = tempEmailApi.retrieveCodeFromInbox(user)
Expand All @@ -193,8 +195,8 @@ class SignUpEmailOTPTest : NativeAuthPublicClientApplicationAbstractTest() {
config = getConfig(ConfigType.SIGN_UP_PASSWORD)
application = setupPCA(config, listOf("oob"))

runBlocking { // Running with runBlocking to avoid default 10 second execution timeout.
val user = tempEmailApi.generateRandomEmailAddress()
runBlocking {
val user = tempEmailApi.generateRandomEmailAddressLocally()
val signUpResult = application.signUp(user)
Assert.assertTrue(signUpResult is SignUpError)
Assert.assertTrue((signUpResult as SignUpError).isBrowserRequired())
Expand All @@ -212,7 +214,7 @@ class SignUpEmailOTPTest : NativeAuthPublicClientApplicationAbstractTest() {

retryOperation {
runBlocking { // Running with runBlocking to avoid default 10 second execution timeout.
val user = tempEmailApi.generateRandomEmailAddress()
val user = tempEmailApi.generateRandomEmailAddressLocally()
val signUpResult = application.signUp(user)
assertResult<SignUpResult.CodeRequired>(signUpResult)
val otp = tempEmailApi.retrieveCodeFromInbox(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.microsoft.identity.nativeauth.UserAttributes
import com.microsoft.identity.nativeauth.statemachine.results.SignUpResult
import kotlinx.coroutines.runBlocking
import org.junit.Assert
import org.junit.Ignore
import org.junit.Test

class SignUpEmailPasswordAttributesTest : NativeAuthPublicClientApplicationAbstractTest() {
Expand All @@ -57,6 +58,7 @@ class SignUpEmailPasswordAttributesTest : NativeAuthPublicClientApplicationAbstr
* 2. Validate OTP.
* (hero scenario 10, use case 1.1.3)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testEmailPasswordAttributesOnSameScreen() {
retryOperation {
Expand Down Expand Up @@ -86,6 +88,7 @@ class SignUpEmailPasswordAttributesTest : NativeAuthPublicClientApplicationAbstr
* 3. Set custom attributes.
* (hero scenario 12, use case 1.1.6)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testSeparateEmailPasswordAndAttributesOnSameScreen() {
retryOperation {
Expand Down Expand Up @@ -122,6 +125,7 @@ class SignUpEmailPasswordAttributesTest : NativeAuthPublicClientApplicationAbstr
* 5. etc.
* ((hero scenario 13)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testSeparateEmailPasswordAndAttributesOnMultipleScreens() {
retryOperation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class SignUpEmailPasswordTest : NativeAuthPublicClientApplicationAbstractTest()
private val defaultChallengeTypes = listOf("password", "oob")


@Ignore("1secmail service is down. Ignoring test for now.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this test we don't retrieve an OTP code from the email inbox, so it should not be ignored

@Test
fun testSignUpErrorSimple() {
config = getConfig(defaultConfigType)
Expand All @@ -67,6 +68,7 @@ class SignUpEmailPasswordTest : NativeAuthPublicClientApplicationAbstractTest()
* Sign up with email + password. Set email and password (mimicking one combined screen for email & password collection), and then verify email OTP as last step
* (hero scenario 9, use case 1.1.1)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testSuccessOTPLast() {
config = getConfig(defaultConfigType)
Expand All @@ -90,6 +92,7 @@ class SignUpEmailPasswordTest : NativeAuthPublicClientApplicationAbstractTest()
* Sign up with email + password. Resend email OOB.
* (use case 1.1.2)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testResendEmailOOB() {
config = getConfig(defaultConfigType)
Expand All @@ -115,6 +118,7 @@ class SignUpEmailPasswordTest : NativeAuthPublicClientApplicationAbstractTest()
* Sign up with email + password. Verify email address using email OTP and then set password (mimicking email and password collection on separate screens).
* (use case 1.1.4)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testSuccessOTPFirst() {
config = getConfig(defaultConfigType)
Expand All @@ -140,6 +144,7 @@ class SignUpEmailPasswordTest : NativeAuthPublicClientApplicationAbstractTest()
* Sign up with email + password. Verify email address using email OTP, resend OTP and then set password.
* (use case 1.1.5)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testSuccessOTPResend() {
config = getConfig(defaultConfigType)
Expand Down Expand Up @@ -223,6 +228,7 @@ class SignUpEmailPasswordTest : NativeAuthPublicClientApplicationAbstractTest()
* Sign up with email + password. Developer makes a request with password that does not match password complexity requirements set on portal.
* (use case 1.1.13)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this test we don't retrieve an OTP code from the email inbox, so it should not be ignored

@Test
fun testErrorInvalidPasswordFormat() {
config = getConfig(defaultConfigType)
Expand All @@ -241,6 +247,7 @@ class SignUpEmailPasswordTest : NativeAuthPublicClientApplicationAbstractTest()
* Sign up with email + password. Developer can opt to get AT and/or ID token (aka sign in after signup).
* (use case 1.1.14)
*/
@Ignore("1secmail service is down. Ignoring test for now.")
@Test
fun testSignInAfterSignUp() {
config = getConfig(defaultConfigType)
Expand Down
Loading