keycloak-service
公開メンバ関数 | 非公開メンバ関数 | 静的非公開変数類 | 全メンバ一覧
org.keycloak.test.broker.oidc.mappers.AbstractJsonUserAttributeMapperTest クラス
org.keycloak.test.broker.oidc.mappers.AbstractJsonUserAttributeMapperTest 連携図
Collaboration graph

公開メンバ関数

void getJsonValue_invalidPath () throws IOException
 
void getJsonValue_simpleValues () throws JsonProcessingException, IOException
 
void getJsonValue_nestedSimpleValues () throws JsonProcessingException, IOException
 
void getJsonValue_simpleArray () throws JsonProcessingException, IOException
 
void getJsonValue_nestedArrayWithObjects () throws JsonProcessingException, IOException
 

非公開メンバ関数

JsonNode getJsonNode () throws IOException
 

静的非公開変数類

static ObjectMapper mapper = new ObjectMapper()
 
static JsonNode baseNode
 

詳解

Unit test for org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper

著者
Vlastimil Elias (velias at redhat dot com)

関数詳解

◆ getJsonNode()

JsonNode org.keycloak.test.broker.oidc.mappers.AbstractJsonUserAttributeMapperTest.getJsonNode ( ) throws IOException
inlineprivate
40  {
41  if (baseNode == null)
42  baseNode = mapper.readTree("{ \"value1\" : \"v1 \",\"value_null\" : null,\"value_empty\" : \"\", \"value_b\" : true, \"value_i\" : 454, " + " \"value_array\":[\"a1\",\"a2\"], " +" \"nest1\": {\"value1\": \" fgh \",\"value_null\" : null,\"value_empty\" : \"\", \"nest2\":{\"value_b\" : false, \"value_i\" : 43}}, "+ " \"nesta\": { \"a\":[{\"av1\": \"vala1\"},{\"av1\": \"vala2\"}]}"+" }");
43  return baseNode;
44  }
static ObjectMapper mapper
Definition: AbstractJsonUserAttributeMapperTest.java:36
static JsonNode baseNode
Definition: AbstractJsonUserAttributeMapperTest.java:38

◆ getJsonValue_invalidPath()

void org.keycloak.test.broker.oidc.mappers.AbstractJsonUserAttributeMapperTest.getJsonValue_invalidPath ( ) throws IOException
inline
47  {
48  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "."));
49  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), ".."));
50  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "...value1"));
51  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), ".value1"));
52  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value1."));
53  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "[]"));
54  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "[value1"));
55  }
JsonNode getJsonNode()
Definition: AbstractJsonUserAttributeMapperTest.java:40

◆ getJsonValue_nestedArrayWithObjects()

void org.keycloak.test.broker.oidc.mappers.AbstractJsonUserAttributeMapperTest.getJsonValue_nestedArrayWithObjects ( ) throws JsonProcessingException, IOException
inline
120  {
121  Assert.assertEquals("vala1", AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nesta.a[0].av1"));
122  Assert.assertEquals("vala2", AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nesta.a[1].av1"));
123 
124  //different path erros or nonexisting indexes or fields return null
125  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nesta.a[2].av1"));
126  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nesta.a[0]"));
127  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nesta.a[0].av_unknown"));
128  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nesta.a[].av1"));
129  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nesta.a"));
130  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nesta.a.av1"));
131  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nesta.a].av1"));
132  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nesta.a[.av1"));
133 
134  }
JsonNode getJsonNode()
Definition: AbstractJsonUserAttributeMapperTest.java:40

◆ getJsonValue_nestedSimpleValues()

void org.keycloak.test.broker.oidc.mappers.AbstractJsonUserAttributeMapperTest.getJsonValue_nestedSimpleValues ( ) throws JsonProcessingException, IOException
inline
75  {
76 
77  // null if path points to JSON object
78  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nest1"));
79  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nest1.nest2"));
80 
81  //unknown field returns null
82  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nest1.value_unknown"));
83  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nest1.nest2.value_unknown"));
84 
85  // we check value is trimmed also!
86  Assert.assertEquals("fgh", AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nest1.value1"));
87  // test for KEYCLOAK-4202 bug (null value handling)
88  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nest1.value_null"));
89  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nest1.value_empty"));
90 
91  Assert.assertEquals("false", AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nest1.nest2.value_b"));
92  Assert.assertEquals("43", AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nest1.nest2.value_i"));
93 
94  // null if invalid nested path
95  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nest1."));
96  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "nest1.nest2."));
97  }
JsonNode getJsonNode()
Definition: AbstractJsonUserAttributeMapperTest.java:40

◆ getJsonValue_simpleArray()

void org.keycloak.test.broker.oidc.mappers.AbstractJsonUserAttributeMapperTest.getJsonValue_simpleArray ( ) throws JsonProcessingException, IOException
inline
100  {
101 
102  // array field itself returns null if no index is provided
103  Assert.assertEquals(Arrays.asList("a1", "a2"), AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_array"));
104  // outside index returns null
105  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_array[2]"));
106 
107  //corect index
108  Assert.assertEquals("a1", AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_array[0]"));
109  Assert.assertEquals("a2", AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_array[1]"));
110 
111  //incorrect array constructs
112  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_array[]"));
113  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_array]"));
114  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_array["));
115  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_array[a]"));
116  Assert.assertNull(AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_array[-2]"));
117  }
JsonNode getJsonNode()
Definition: AbstractJsonUserAttributeMapperTest.java:40

◆ getJsonValue_simpleValues()

void org.keycloak.test.broker.oidc.mappers.AbstractJsonUserAttributeMapperTest.getJsonValue_simpleValues ( ) throws JsonProcessingException, IOException
inline
58  {
59 
60  //unknown field returns null
61  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_unknown"));
62 
63  // we check value is trimmed also!
64  Assert.assertEquals("v1", AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value1"));
65  // test for KEYCLOAK-4202 bug (null value handling)
66  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_null"));
67  Assert.assertEquals(null, AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_empty"));
68 
69  Assert.assertEquals("true", AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_b"));
70  Assert.assertEquals("454", AbstractJsonUserAttributeMapper.getJsonValue(getJsonNode(), "value_i"));
71 
72  }
JsonNode getJsonNode()
Definition: AbstractJsonUserAttributeMapperTest.java:40

メンバ詳解

◆ baseNode

JsonNode org.keycloak.test.broker.oidc.mappers.AbstractJsonUserAttributeMapperTest.baseNode
staticprivate

◆ mapper

ObjectMapper org.keycloak.test.broker.oidc.mappers.AbstractJsonUserAttributeMapperTest.mapper = new ObjectMapper()
staticprivate

このクラス詳解は次のファイルから抽出されました: