Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -40,6 +40,7 @@ class UserAttributes(internal val userAttributes: Map<String, String>) {
private const val STATE = "state"
private const val STREET_ADDRESS = "streetAddress"
private const val SURNAME = "surname"
private const val FLAT_USERNAME = "flatusername"
}

private val userAttributes = mutableMapOf<String, String>()
Expand Down Expand Up @@ -125,6 +126,15 @@ class UserAttributes(internal val userAttributes: Map<String, String>) {
return this
}

/**
* Sets the flat username for the user
* @param flatUsername: Flat username for the user
*/
fun flatUsername(flatUsername: String): Builder {
userAttributes[FLAT_USERNAME] = flatUsername
return this
}

/**
* Sets any custom attribute for the use
* @param key: Name of the attribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SignUpEmailPasswordAttributesTest : NativeAuthPublicClientApplicationAbstr
retryOperation {
runBlocking {
val user = tempEmailApi.generateRandomEmailAddressLocally()
val attributes = UserAttributes.Builder().country("Ireland").city("Dublin").build()
val attributes = UserAttributes.Builder().country("Ireland").city("Dublin").flatUsername("flatusername").build()
Comment thread
spetrescu84 marked this conversation as resolved.

val param = NativeAuthSignUpParameters(username = user)
param.password = getSafePassword().toCharArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3192,6 +3192,8 @@ public void testSignUpInvalidEmailReturnsError() throws ExecutionException, Inte
assertTrue(signUpResult instanceof SignUpError);
assertTrue(((SignUpError) signUpResult).isInvalidUsername());
}


}

abstract class TestCallback<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3042,4 +3042,24 @@ class NativeAuthPublicClientApplicationKotlinTest(private val allowPII: Boolean)
val submitChallengeResult = nextState4.submitChallenge(code)
assertResult<SignInResult.Complete>(submitChallengeResult)
}

@Test
fun testUserAttributesFlatUsernameBuilder() {
val attrs = UserAttributes.Builder()
.flatUsername("testuser")
.build()
assertEquals("testuser", attrs.userAttributes["flatusername"])
}

@Test
fun testUserAttributesFlatUsernameWithOtherAttributes() {
val attrs = UserAttributes.Builder()
.flatUsername("testuser")
.displayName("Test User")
.city("Seattle")
.build()
assertEquals("testuser", attrs.userAttributes["flatusername"])
assertEquals("Test User", attrs.userAttributes["displayName"])
assertEquals("Seattle", attrs.userAttributes["city"])
}
}
Loading