mitreid-connect
公開メンバ関数 | 全メンバ一覧
org.mitre.openid.connect.ClientDetailsEntityJsonProcessorTest クラス
org.mitre.openid.connect.ClientDetailsEntityJsonProcessorTest 連携図
Collaboration graph

公開メンバ関数

void testParse ()
 
void testParseRegistered ()
 
void testSerialize ()
 

詳解

著者
jricher

関数詳解

◆ testParse()

void org.mitre.openid.connect.ClientDetailsEntityJsonProcessorTest.testParse ( )
inline

Test method for org.mitre.openid.connect.ClientDetailsEntityJsonProcessor#parse(java.lang.String).

48  {
49  String json = " {\n" +
50  " \"application_type\": \"web\",\n" +
51  " \"redirect_uris\":\n" +
52  " [\"https://client.example.org/callback\",\n" +
53  " \"https://client.example.org/callback2\"],\n" +
54  " \"client_name\": \"My Example\",\n" +
55  " \"client_name#ja-Jpan-JP\":\n" +
56  " \"クライアント名\",\n" +
57  " \"response_types\": [\"code\", \"token\"],\n" +
58  " \"grant_types\": [\"authorization_code\", \"implicit\"],\n" +
59  " \"logo_uri\": \"https://client.example.org/logo.png\",\n" +
60  " \"subject_type\": \"pairwise\",\n" +
61  " \"sector_identifier_uri\":\n" +
62  " \"https://other.example.net/file_of_redirect_uris.json\",\n" +
63  " \"token_endpoint_auth_method\": \"client_secret_basic\",\n" +
64  " \"jwks_uri\": \"https://client.example.org/my_public_keys.jwks\",\n" +
65  " \"userinfo_encrypted_response_alg\": \"RSA1_5\",\n" +
66  " \"userinfo_encrypted_response_enc\": \"A128CBC-HS256\",\n" +
67  " \"contacts\": [\"ve7jtb@example.org\", \"mary@example.org\"],\n" +
68  " \"request_uris\":\n" +
69  " [\"https://client.example.org/rf.txt#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA\"]\n" +
70  " }";
71  ClientDetailsEntity c = ClientDetailsEntityJsonProcessor.parse(json);
72 
73  assertEquals(ClientDetailsEntity.AppType.WEB, c.getApplicationType());
74  assertEquals(ImmutableSet.of("https://client.example.org/callback", "https://client.example.org/callback2"), c.getRedirectUris());
75  assertEquals("My Example", c.getClientName());
76  assertEquals(ImmutableSet.of("code", "token"), c.getResponseTypes());
77  assertEquals(ImmutableSet.of("authorization_code", "implicit"), c.getGrantTypes());
78  assertEquals("https://client.example.org/logo.png", c.getLogoUri());
79  assertEquals(ClientDetailsEntity.SubjectType.PAIRWISE, c.getSubjectType());
80  assertEquals("https://other.example.net/file_of_redirect_uris.json", c.getSectorIdentifierUri());
81  assertEquals(ClientDetailsEntity.AuthMethod.SECRET_BASIC, c.getTokenEndpointAuthMethod());
82  assertEquals("https://client.example.org/my_public_keys.jwks", c.getJwksUri());
83  assertEquals(JWEAlgorithm.RSA1_5, c.getUserInfoEncryptedResponseAlg());
84  assertEquals(EncryptionMethod.A128CBC_HS256, c.getUserInfoEncryptedResponseEnc());
85  assertEquals(ImmutableSet.of("ve7jtb@example.org", "mary@example.org"), c.getContacts());
86  assertEquals(ImmutableSet.of("https://client.example.org/rf.txt#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA"), c.getRequestUris());
87 
88  }

◆ testParseRegistered()

void org.mitre.openid.connect.ClientDetailsEntityJsonProcessorTest.testParseRegistered ( )
inline

Test method for org.mitre.openid.connect.ClientDetailsEntityJsonProcessor#parseRegistered(java.lang.String).

94  {
95  String json = " {\n" +
96  " \"client_id\": \"s6BhdRkqt3\",\n" +
97  " \"client_secret\":\n" +
98  " \"ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk\",\n" +
99  " \"client_secret_expires_at\": 1577858400,\n" +
100  " \"registration_access_token\":\n" +
101  " \"this.is.an.access.token.value.ffx83\",\n" +
102  " \"registration_client_uri\":\n" +
103  " \"https://server.example.com/connect/register?client_id=s6BhdRkqt3\",\n" +
104  " \"token_endpoint_auth_method\":\n" +
105  " \"client_secret_basic\",\n" +
106  " \"application_type\": \"web\",\n" +
107  " \"redirect_uris\":\n" +
108  " [\"https://client.example.org/callback\",\n" +
109  " \"https://client.example.org/callback2\"],\n" +
110  " \"client_name\": \"My Example\",\n" +
111  " \"client_name#ja-Jpan-JP\":\n" +
112  " \"クライアント名\",\n" +
113  " \"response_types\": [\"code\", \"token\"],\n" +
114  " \"grant_types\": [\"authorization_code\", \"implicit\"],\n" +
115  " \"logo_uri\": \"https://client.example.org/logo.png\",\n" +
116  " \"subject_type\": \"pairwise\",\n" +
117  " \"sector_identifier_uri\":\n" +
118  " \"https://other.example.net/file_of_redirect_uris.json\",\n" +
119  " \"jwks_uri\": \"https://client.example.org/my_public_keys.jwks\",\n" +
120  " \"userinfo_encrypted_response_alg\": \"RSA1_5\",\n" +
121  " \"userinfo_encrypted_response_enc\": \"A128CBC-HS256\",\n" +
122  " \"contacts\": [\"ve7jtb@example.org\", \"mary@example.org\"],\n" +
123  " \"request_uris\":\n" +
124  " [\"https://client.example.org/rf.txt#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA\"]\n" +
125  " }";
126 
127  RegisteredClient c = ClientDetailsEntityJsonProcessor.parseRegistered(json);
128 
129 
130  assertEquals("s6BhdRkqt3", c.getClientId());
131  assertEquals("ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk", c.getClientSecret());
132  assertEquals(new Date(1577858400L * 1000L), c.getClientSecretExpiresAt());
133  assertEquals("this.is.an.access.token.value.ffx83", c.getRegistrationAccessToken());
134  assertEquals("https://server.example.com/connect/register?client_id=s6BhdRkqt3", c.getRegistrationClientUri());
135  assertEquals(ClientDetailsEntity.AppType.WEB, c.getApplicationType());
136  assertEquals(ImmutableSet.of("https://client.example.org/callback", "https://client.example.org/callback2"), c.getRedirectUris());
137  assertEquals("My Example", c.getClientName());
138  assertEquals(ImmutableSet.of("code", "token"), c.getResponseTypes());
139  assertEquals(ImmutableSet.of("authorization_code", "implicit"), c.getGrantTypes());
140  assertEquals("https://client.example.org/logo.png", c.getLogoUri());
141  assertEquals(ClientDetailsEntity.SubjectType.PAIRWISE, c.getSubjectType());
142  assertEquals("https://other.example.net/file_of_redirect_uris.json", c.getSectorIdentifierUri());
143  assertEquals(ClientDetailsEntity.AuthMethod.SECRET_BASIC, c.getTokenEndpointAuthMethod());
144  assertEquals("https://client.example.org/my_public_keys.jwks", c.getJwksUri());
145  assertEquals(JWEAlgorithm.RSA1_5, c.getUserInfoEncryptedResponseAlg());
146  assertEquals(EncryptionMethod.A128CBC_HS256, c.getUserInfoEncryptedResponseEnc());
147  assertEquals(ImmutableSet.of("ve7jtb@example.org", "mary@example.org"), c.getContacts());
148  assertEquals(ImmutableSet.of("https://client.example.org/rf.txt#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA"), c.getRequestUris());
149 
150  }

◆ testSerialize()

void org.mitre.openid.connect.ClientDetailsEntityJsonProcessorTest.testSerialize ( )
inline

Test method for org.mitre.openid.connect.ClientDetailsEntityJsonProcessor#serialize(org.mitre.oauth2.model.RegisteredClient).

156  {
157  RegisteredClient c = new RegisteredClient();
158 
159  c.setClientId("s6BhdRkqt3");
160  c.setClientSecret("ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk");
161  c.setClientSecretExpiresAt(new Date(1577858400L * 1000L));
162  c.setRegistrationAccessToken("this.is.an.access.token.value.ffx83");
163  c.setRegistrationClientUri("https://server.example.com/connect/register?client_id=s6BhdRkqt3");
164  c.setApplicationType(ClientDetailsEntity.AppType.WEB);
165  c.setRedirectUris(ImmutableSet.of("https://client.example.org/callback", "https://client.example.org/callback2"));
166  c.setClientName("My Example");
167  c.setResponseTypes(ImmutableSet.of("code", "token"));
168  c.setGrantTypes(ImmutableSet.of("authorization_code", "implicit"));
169  c.setLogoUri("https://client.example.org/logo.png");
170  c.setSubjectType(ClientDetailsEntity.SubjectType.PAIRWISE);
171  c.setSectorIdentifierUri("https://other.example.net/file_of_redirect_uris.json");
172  c.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.SECRET_BASIC);
173  c.setJwksUri("https://client.example.org/my_public_keys.jwks");
174  c.setUserInfoEncryptedResponseAlg(JWEAlgorithm.RSA1_5);
175  c.setUserInfoEncryptedResponseEnc(EncryptionMethod.A128CBC_HS256);
176  c.setContacts(ImmutableSet.of("ve7jtb@example.org", "mary@example.org"));
177  c.setRequestUris(ImmutableSet.of("https://client.example.org/rf.txt#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA"));
178 
179  JsonObject j = ClientDetailsEntityJsonProcessor.serialize(c);
180 
181  assertEquals("s6BhdRkqt3", j.get("client_id").getAsString());
182  assertEquals("ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk", j.get("client_secret").getAsString());
183  assertEquals(1577858400L, j.get("client_secret_expires_at").getAsNumber());
184  assertEquals("this.is.an.access.token.value.ffx83", j.get("registration_access_token").getAsString());
185  assertEquals("https://server.example.com/connect/register?client_id=s6BhdRkqt3", j.get("registration_client_uri").getAsString());
186  assertEquals(ClientDetailsEntity.AppType.WEB.getValue(), j.get("application_type").getAsString());
187  for (JsonElement e : j.get("redirect_uris").getAsJsonArray()) {
188  assertTrue(ImmutableSet.of("https://client.example.org/callback", "https://client.example.org/callback2").contains(e.getAsString()));
189  }
190  assertEquals("My Example", j.get("client_name").getAsString());
191  for (JsonElement e : j.get("response_types").getAsJsonArray()) {
192  assertTrue(ImmutableSet.of("code", "token").contains(e.getAsString()));
193  }
194  for (JsonElement e : j.get("grant_types").getAsJsonArray()) {
195  assertTrue(ImmutableSet.of("authorization_code", "implicit").contains(e.getAsString()));
196  }
197  assertEquals("https://client.example.org/logo.png", j.get("logo_uri").getAsString());
198  assertEquals(ClientDetailsEntity.SubjectType.PAIRWISE.getValue(), j.get("subject_type").getAsString());
199  assertEquals("https://other.example.net/file_of_redirect_uris.json", j.get("sector_identifier_uri").getAsString());
200  assertEquals(ClientDetailsEntity.AuthMethod.SECRET_BASIC.getValue(), j.get("token_endpoint_auth_method").getAsString());
201  assertEquals("https://client.example.org/my_public_keys.jwks", j.get("jwks_uri").getAsString());
202  assertEquals(JWEAlgorithm.RSA1_5.getName(), j.get("userinfo_encrypted_response_alg").getAsString());
203  assertEquals(EncryptionMethod.A128CBC_HS256.getName(), j.get("userinfo_encrypted_response_enc").getAsString());
204  for (JsonElement e : j.get("contacts").getAsJsonArray()) {
205  assertTrue(ImmutableSet.of("ve7jtb@example.org", "mary@example.org").contains(e.getAsString()));
206  }
207  for (JsonElement e : j.get("request_uris").getAsJsonArray()) {
208  assertTrue(ImmutableSet.of("https://client.example.org/rf.txt#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA").contains(e.getAsString()));
209  }
210 
211  }

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