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 @@ -29,11 +29,11 @@ public AbstractJsonObjectResponse(JsonObject json) {
}

public String getString(String name) {
return json.getString(name);
return contains(name) ? json.getString(name) : null;
}

public Boolean getBoolean(String name) {
return json.getBoolean(name);
return contains(name) ? json.getBoolean(name) : null;
}

public Long getLong(String name) {
Expand Down
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"));
}
}