-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32771 from sberyozkin/oidc_userinfo_npe
Prevent NPE for UserInfo String and Boolean properties
- Loading branch information
Showing
2 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
extensions/oidc/runtime/src/test/java/io/quarkus/oidc/runtime/UserInfoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.quarkus.oidc.runtime; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.oidc.UserInfo; | ||
|
||
public class UserInfoTest { | ||
UserInfo userInfo = new UserInfo( | ||
"{" | ||
+ "\"name\": \"alice\"," | ||
+ "\"admin\": true" | ||
+ "}"); | ||
|
||
@Test | ||
public void testGetString() { | ||
assertEquals("alice", userInfo.getString("name")); | ||
assertNull(userInfo.getString("names")); | ||
} | ||
|
||
@Test | ||
public void testGetBoolean() { | ||
assertTrue(userInfo.getBoolean("admin")); | ||
assertNull(userInfo.getBoolean("admins")); | ||
} | ||
} |