Skip to content

Commit fe33a07

Browse files
spetrescu84Copilot
andcommitted
Add unit tests for flatUsername in Kotlin and Java test files
Adds enabled unit tests verifying the flatUsername builder method produces the correct map key and works alongside other attributes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 25d6152 commit fe33a07

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

msal/src/test/java/com/microsoft/identity/nativeauth/NativeAuthPublicClientApplicationJavaTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,6 +3192,26 @@ public void testSignUpInvalidEmailReturnsError() throws ExecutionException, Inte
31923192
assertTrue(signUpResult instanceof SignUpError);
31933193
assertTrue(((SignUpError) signUpResult).isInvalidUsername());
31943194
}
3195+
3196+
@Test
3197+
public void testUserAttributesFlatUsernameBuilder() {
3198+
UserAttributes attrs = new UserAttributes.Builder()
3199+
.flatUsername("testuser")
3200+
.build();
3201+
assertEquals("testuser", attrs.getUserAttributes().get("flatusername"));
3202+
}
3203+
3204+
@Test
3205+
public void testUserAttributesFlatUsernameWithOtherAttributes() {
3206+
UserAttributes attrs = new UserAttributes.Builder()
3207+
.flatUsername("testuser")
3208+
.displayName("Test User")
3209+
.city("Seattle")
3210+
.build();
3211+
assertEquals("testuser", attrs.getUserAttributes().get("flatusername"));
3212+
assertEquals("Test User", attrs.getUserAttributes().get("displayName"));
3213+
assertEquals("Seattle", attrs.getUserAttributes().get("city"));
3214+
}
31953215
}
31963216

31973217
abstract class TestCallback<T> {

msal/src/test/java/com/microsoft/identity/nativeauth/NativeAuthPublicClientApplicationKotlinTest.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3042,4 +3042,24 @@ class NativeAuthPublicClientApplicationKotlinTest(private val allowPII: Boolean)
30423042
val submitChallengeResult = nextState4.submitChallenge(code)
30433043
assertResult<SignInResult.Complete>(submitChallengeResult)
30443044
}
3045+
3046+
@Test
3047+
fun testUserAttributesFlatUsernameBuilder() {
3048+
val attrs = UserAttributes.Builder()
3049+
.flatUsername("testuser")
3050+
.build()
3051+
assertEquals("testuser", attrs.userAttributes["flatusername"])
3052+
}
3053+
3054+
@Test
3055+
fun testUserAttributesFlatUsernameWithOtherAttributes() {
3056+
val attrs = UserAttributes.Builder()
3057+
.flatUsername("testuser")
3058+
.displayName("Test User")
3059+
.city("Seattle")
3060+
.build()
3061+
assertEquals("testuser", attrs.userAttributes["flatusername"])
3062+
assertEquals("Test User", attrs.userAttributes["displayName"])
3063+
assertEquals("Seattle", attrs.userAttributes["city"])
3064+
}
30453065
}

0 commit comments

Comments
 (0)