mitreid-connect
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler クラス
org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler 連携図
Collaboration graph

公開メンバ関数

void shouldAssembleExpectedResultForAccessToken () throws ParseException
 
void shouldAssembleExpectedResultForAccessToken_withPermissions () throws ParseException
 
void shouldAssembleExpectedResultForAccessTokenWithoutUserInfo () throws ParseException
 
void shouldAssembleExpectedResultForAccessTokenWithoutExpiry ()
 
void shouldAssembleExpectedResultForAccessTokenWithoutUserAuthentication () throws ParseException
 
void shouldAssembleExpectedResultForRefreshToken () throws ParseException
 
void shouldAssembleExpectedResultForRefreshTokenWithoutUserInfo () throws ParseException
 
void shouldAssembleExpectedResultForRefreshTokenWithoutExpiry ()
 
void shouldAssembleExpectedResultForRefreshTokenWithoutUserAuthentication () throws ParseException
 

非公開メンバ関数

UserInfo userInfo (String sub)
 
OAuth2AccessTokenEntity accessToken (Date exp, Set< String > scopes, Set< Permission > permissions, String tokenType, OAuth2Authentication authentication)
 
OAuth2RefreshTokenEntity refreshToken (Date exp, OAuth2Authentication authentication)
 
OAuth2Authentication oauth2AuthenticationWithUser (OAuth2Request request, String username)
 
OAuth2Authentication oauth2Authentication (OAuth2Request request, Authentication userAuthentication)
 
OAuth2Request oauth2Request (String clientId)
 
OAuth2Request oauth2Request (String clientId, Set< String > scopes)
 
Set< String > scopes (String... scopes)
 
Set< Permissionpermissions (Permission... permissions)
 
Permission permission (Long resourceSetId, String... scopes)
 

非公開変数類

IntrospectionResultAssembler assembler = new DefaultIntrospectionResultAssembler()
 

静的非公開変数類

static DateFormatter dateFormat = new DateFormatter(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"))
 

詳解

関数詳解

◆ accessToken()

OAuth2AccessTokenEntity org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.accessToken ( Date  exp,
Set< String >  scopes,
Set< Permission permissions,
String  tokenType,
OAuth2Authentication  authentication 
)
inlineprivate
314  {
315  OAuth2AccessTokenEntity accessToken = mock(OAuth2AccessTokenEntity.class, RETURNS_DEEP_STUBS);
316  given(accessToken.getExpiration()).willReturn(exp);
317  given(accessToken.getScope()).willReturn(scopes);
318  given(accessToken.getPermissions()).willReturn(permissions);
319  given(accessToken.getTokenType()).willReturn(tokenType);
320  given(accessToken.getAuthenticationHolder().getAuthentication()).willReturn(authentication);
321  return accessToken;
322  }
OAuth2AccessTokenEntity accessToken(Date exp, Set< String > scopes, Set< Permission > permissions, String tokenType, OAuth2Authentication authentication)
Definition: TestDefaultIntrospectionResultAssembler.java:314
Set< Permission > permissions(Permission... permissions)
Definition: TestDefaultIntrospectionResultAssembler.java:352
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348

◆ oauth2Authentication()

OAuth2Authentication org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.oauth2Authentication ( OAuth2Request  request,
Authentication  userAuthentication 
)
inlineprivate
336  {
337  return new OAuth2Authentication(request, userAuthentication);
338  }

◆ oauth2AuthenticationWithUser()

OAuth2Authentication org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.oauth2AuthenticationWithUser ( OAuth2Request  request,
String  username 
)
inlineprivate
331  {
332  UsernamePasswordAuthenticationToken userAuthentication = new UsernamePasswordAuthenticationToken(username, "somepassword");
333  return oauth2Authentication(request, userAuthentication);
334  }
OAuth2Authentication oauth2Authentication(OAuth2Request request, Authentication userAuthentication)
Definition: TestDefaultIntrospectionResultAssembler.java:336

◆ oauth2Request() [1/2]

OAuth2Request org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.oauth2Request ( String  clientId)
inlineprivate
340  {
341  return oauth2Request(clientId, null);
342  }
OAuth2Request oauth2Request(String clientId)
Definition: TestDefaultIntrospectionResultAssembler.java:340

◆ oauth2Request() [2/2]

OAuth2Request org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.oauth2Request ( String  clientId,
Set< String >  scopes 
)
inlineprivate
344  {
345  return new OAuth2Request(null, clientId, null, true, scopes, null, null, null, null);
346  }
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348

◆ permission()

Permission org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.permission ( Long  resourceSetId,
String...  scopes 
)
inlineprivate
356  {
357  Permission permission = mock(Permission.class, RETURNS_DEEP_STUBS);
358  given(permission.getResourceSet().getId()).willReturn(resourceSetId);
359  given(permission.getScopes()).willReturn(scopes(scopes));
360  return permission;
361  }
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348
Permission permission(Long resourceSetId, String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:356

◆ permissions()

Set<Permission> org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.permissions ( Permission...  permissions)
inlineprivate
352  {
353  return newHashSet(permissions);
354  }
Set< Permission > permissions(Permission... permissions)
Definition: TestDefaultIntrospectionResultAssembler.java:352

◆ refreshToken()

OAuth2RefreshTokenEntity org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.refreshToken ( Date  exp,
OAuth2Authentication  authentication 
)
inlineprivate
324  {
325  OAuth2RefreshTokenEntity refreshToken = mock(OAuth2RefreshTokenEntity.class, RETURNS_DEEP_STUBS);
326  given(refreshToken.getExpiration()).willReturn(exp);
327  given(refreshToken.getAuthenticationHolder().getAuthentication()).willReturn(authentication);
328  return refreshToken;
329  }
OAuth2RefreshTokenEntity refreshToken(Date exp, OAuth2Authentication authentication)
Definition: TestDefaultIntrospectionResultAssembler.java:324

◆ scopes()

Set<String> org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.scopes ( String...  scopes)
inlineprivate
348  {
349  return newHashSet(scopes);
350  }
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348

◆ shouldAssembleExpectedResultForAccessToken()

void org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.shouldAssembleExpectedResultForAccessToken ( ) throws ParseException
inline
58  {
59 
60  // given
61  OAuth2AccessTokenEntity accessToken = accessToken(new Date(123 * 1000L), scopes("foo", "bar"), null, "Bearer",
62  oauth2AuthenticationWithUser(oauth2Request("clientId"), "name"));
63 
64  UserInfo userInfo = userInfo("sub");
65 
66  Set<String> authScopes = scopes("foo", "bar", "baz");
67 
68  // when
69  Map<String, Object> result = assembler.assembleFrom(accessToken, userInfo, authScopes);
70 
71 
72  // then
73  Map<String, Object> expected = new ImmutableMap.Builder<String, Object>()
74  .put("sub", "sub")
75  .put("exp", 123L)
76  .put("expires_at", dateFormat.valueToString(new Date(123 * 1000L)))
77  .put("scope", "bar foo")
78  .put("active", Boolean.TRUE)
79  .put("user_id", "name")
80  .put("client_id", "clientId")
81  .put("token_type", "Bearer")
82  .build();
83  assertThat(result, is(equalTo(expected)));
84  }
OAuth2AccessTokenEntity accessToken(Date exp, Set< String > scopes, Set< Permission > permissions, String tokenType, OAuth2Authentication authentication)
Definition: TestDefaultIntrospectionResultAssembler.java:314
IntrospectionResultAssembler assembler
Definition: TestDefaultIntrospectionResultAssembler.java:53
static DateFormatter dateFormat
Definition: TestDefaultIntrospectionResultAssembler.java:55
OAuth2Request oauth2Request(String clientId)
Definition: TestDefaultIntrospectionResultAssembler.java:340
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348
UserInfo userInfo(String sub)
Definition: TestDefaultIntrospectionResultAssembler.java:308
Map< String, Object > assembleFrom(OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set< String > authScopes)
OAuth2Authentication oauth2AuthenticationWithUser(OAuth2Request request, String username)
Definition: TestDefaultIntrospectionResultAssembler.java:331

◆ shouldAssembleExpectedResultForAccessToken_withPermissions()

void org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.shouldAssembleExpectedResultForAccessToken_withPermissions ( ) throws ParseException
inline
87  {
88 
89  // given
90  OAuth2AccessTokenEntity accessToken = accessToken(new Date(123 * 1000L), scopes("foo", "bar"),
91  permissions(permission(1L, "foo", "bar")),
92  "Bearer", oauth2AuthenticationWithUser(oauth2Request("clientId"), "name"));
93 
94  UserInfo userInfo = userInfo("sub");
95 
96  Set<String> authScopes = scopes("foo", "bar", "baz");
97 
98  // when
99  Map<String, Object> result = assembler.assembleFrom(accessToken, userInfo, authScopes);
100 
101 
102  // then
103  Map<String, Object> expected = new ImmutableMap.Builder<String, Object>()
104  .put("sub", "sub")
105  .put("exp", 123L)
106  .put("expires_at", dateFormat.valueToString(new Date(123 * 1000L)))
107  .put("permissions", new ImmutableSet.Builder<>()
108  .add(new ImmutableMap.Builder<String, Object>()
109  .put("resource_set_id", "1") // note that the resource ID comes out as a string
110  .put("scopes", new ImmutableSet.Builder<>()
111  .add("bar")
112  .add("foo")
113  .build())
114  .build())
115  .build())
116  // note that scopes are not included if permissions are included
117  .put("active", Boolean.TRUE)
118  .put("user_id", "name")
119  .put("client_id", "clientId")
120  .put("token_type", "Bearer")
121  .build();
122  assertThat(result, is(equalTo(expected)));
123  }
OAuth2AccessTokenEntity accessToken(Date exp, Set< String > scopes, Set< Permission > permissions, String tokenType, OAuth2Authentication authentication)
Definition: TestDefaultIntrospectionResultAssembler.java:314
IntrospectionResultAssembler assembler
Definition: TestDefaultIntrospectionResultAssembler.java:53
static DateFormatter dateFormat
Definition: TestDefaultIntrospectionResultAssembler.java:55
Set< Permission > permissions(Permission... permissions)
Definition: TestDefaultIntrospectionResultAssembler.java:352
OAuth2Request oauth2Request(String clientId)
Definition: TestDefaultIntrospectionResultAssembler.java:340
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348
UserInfo userInfo(String sub)
Definition: TestDefaultIntrospectionResultAssembler.java:308
Permission permission(Long resourceSetId, String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:356
Map< String, Object > assembleFrom(OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set< String > authScopes)
OAuth2Authentication oauth2AuthenticationWithUser(OAuth2Request request, String username)
Definition: TestDefaultIntrospectionResultAssembler.java:331

◆ shouldAssembleExpectedResultForAccessTokenWithoutExpiry()

void org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.shouldAssembleExpectedResultForAccessTokenWithoutExpiry ( )
inline
153  {
154 
155  // given
156  OAuth2AccessTokenEntity accessToken = accessToken(null, scopes("foo", "bar"), null, "Bearer",
157  oauth2AuthenticationWithUser(oauth2Request("clientId"), "name"));
158 
159  UserInfo userInfo = userInfo("sub");
160 
161  Set<String> authScopes = scopes("foo", "bar", "baz");
162 
163  // when
164  Map<String, Object> result = assembler.assembleFrom(accessToken, userInfo, authScopes);
165 
166 
167  // then
168  Map<String, Object> expected = new ImmutableMap.Builder<String, Object>()
169  .put("sub", "sub")
170  .put("scope", "bar foo")
171  .put("active", Boolean.TRUE)
172  .put("user_id", "name")
173  .put("client_id", "clientId")
174  .put("token_type", "Bearer")
175  .build();
176  assertThat(result, is(equalTo(expected)));
177  }
OAuth2AccessTokenEntity accessToken(Date exp, Set< String > scopes, Set< Permission > permissions, String tokenType, OAuth2Authentication authentication)
Definition: TestDefaultIntrospectionResultAssembler.java:314
IntrospectionResultAssembler assembler
Definition: TestDefaultIntrospectionResultAssembler.java:53
OAuth2Request oauth2Request(String clientId)
Definition: TestDefaultIntrospectionResultAssembler.java:340
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348
UserInfo userInfo(String sub)
Definition: TestDefaultIntrospectionResultAssembler.java:308
Map< String, Object > assembleFrom(OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set< String > authScopes)
OAuth2Authentication oauth2AuthenticationWithUser(OAuth2Request request, String username)
Definition: TestDefaultIntrospectionResultAssembler.java:331

◆ shouldAssembleExpectedResultForAccessTokenWithoutUserAuthentication()

void org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.shouldAssembleExpectedResultForAccessTokenWithoutUserAuthentication ( ) throws ParseException
inline
180  {
181  // given
182  OAuth2AccessTokenEntity accessToken = accessToken(new Date(123 * 1000L), scopes("foo", "bar"), null, "Bearer",
183  oauth2Authentication(oauth2Request("clientId"), null));
184 
185  Set<String> authScopes = scopes("foo", "bar", "baz");
186 
187  // when
188  Map<String, Object> result = assembler.assembleFrom(accessToken, null, authScopes);
189 
190 
191  // then `user_id` should not be present
192  Map<String, Object> expected = new ImmutableMap.Builder<String, Object>()
193  .put("sub", "clientId")
194  .put("exp", 123L)
195  .put("expires_at", dateFormat.valueToString(new Date(123 * 1000L)))
196  .put("scope", "bar foo")
197  .put("active", Boolean.TRUE)
198  .put("client_id", "clientId")
199  .put("token_type", "Bearer")
200  .build();
201  assertThat(result, is(equalTo(expected)));
202  }
OAuth2Authentication oauth2Authentication(OAuth2Request request, Authentication userAuthentication)
Definition: TestDefaultIntrospectionResultAssembler.java:336
OAuth2AccessTokenEntity accessToken(Date exp, Set< String > scopes, Set< Permission > permissions, String tokenType, OAuth2Authentication authentication)
Definition: TestDefaultIntrospectionResultAssembler.java:314
IntrospectionResultAssembler assembler
Definition: TestDefaultIntrospectionResultAssembler.java:53
static DateFormatter dateFormat
Definition: TestDefaultIntrospectionResultAssembler.java:55
OAuth2Request oauth2Request(String clientId)
Definition: TestDefaultIntrospectionResultAssembler.java:340
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348
Map< String, Object > assembleFrom(OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set< String > authScopes)

◆ shouldAssembleExpectedResultForAccessTokenWithoutUserInfo()

void org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.shouldAssembleExpectedResultForAccessTokenWithoutUserInfo ( ) throws ParseException
inline
126  {
127 
128  // given
129  OAuth2AccessTokenEntity accessToken = accessToken(new Date(123 * 1000L), scopes("foo", "bar"), null, "Bearer",
130  oauth2AuthenticationWithUser(oauth2Request("clientId"), "name"));
131 
132  Set<String> authScopes = scopes("foo", "bar", "baz");
133 
134  // when
135  Map<String, Object> result = assembler.assembleFrom(accessToken, null, authScopes);
136 
137 
138  // then
139  Map<String, Object> expected = new ImmutableMap.Builder<String, Object>()
140  .put("sub", "name")
141  .put("exp", 123L)
142  .put("expires_at", dateFormat.valueToString(new Date(123 * 1000L)))
143  .put("scope", "bar foo")
144  .put("active", Boolean.TRUE)
145  .put("user_id", "name")
146  .put("client_id", "clientId")
147  .put("token_type", "Bearer")
148  .build();
149  assertThat(result, is(equalTo(expected)));
150  }
OAuth2AccessTokenEntity accessToken(Date exp, Set< String > scopes, Set< Permission > permissions, String tokenType, OAuth2Authentication authentication)
Definition: TestDefaultIntrospectionResultAssembler.java:314
IntrospectionResultAssembler assembler
Definition: TestDefaultIntrospectionResultAssembler.java:53
static DateFormatter dateFormat
Definition: TestDefaultIntrospectionResultAssembler.java:55
OAuth2Request oauth2Request(String clientId)
Definition: TestDefaultIntrospectionResultAssembler.java:340
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348
Map< String, Object > assembleFrom(OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set< String > authScopes)
OAuth2Authentication oauth2AuthenticationWithUser(OAuth2Request request, String username)
Definition: TestDefaultIntrospectionResultAssembler.java:331

◆ shouldAssembleExpectedResultForRefreshToken()

void org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.shouldAssembleExpectedResultForRefreshToken ( ) throws ParseException
inline
205  {
206 
207  // given
208  OAuth2RefreshTokenEntity refreshToken = refreshToken(new Date(123 * 1000L),
209  oauth2AuthenticationWithUser(oauth2Request("clientId", scopes("foo", "bar")), "name"));
210 
211  UserInfo userInfo = userInfo("sub");
212 
213  Set<String> authScopes = scopes("foo", "bar", "baz");
214 
215  // when
216  Map<String, Object> result = assembler.assembleFrom(refreshToken, userInfo, authScopes);
217 
218 
219  // then
220  Map<String, Object> expected = new ImmutableMap.Builder<String, Object>()
221  .put("sub", "sub")
222  .put("exp", 123L)
223  .put("expires_at", dateFormat.valueToString(new Date(123 * 1000L)))
224  .put("scope", "bar foo")
225  .put("active", Boolean.TRUE)
226  .put("user_id", "name")
227  .put("client_id", "clientId")
228  .build();
229  assertThat(result, is(equalTo(expected)));
230  }
IntrospectionResultAssembler assembler
Definition: TestDefaultIntrospectionResultAssembler.java:53
static DateFormatter dateFormat
Definition: TestDefaultIntrospectionResultAssembler.java:55
OAuth2Request oauth2Request(String clientId)
Definition: TestDefaultIntrospectionResultAssembler.java:340
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348
UserInfo userInfo(String sub)
Definition: TestDefaultIntrospectionResultAssembler.java:308
Map< String, Object > assembleFrom(OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set< String > authScopes)
OAuth2RefreshTokenEntity refreshToken(Date exp, OAuth2Authentication authentication)
Definition: TestDefaultIntrospectionResultAssembler.java:324
OAuth2Authentication oauth2AuthenticationWithUser(OAuth2Request request, String username)
Definition: TestDefaultIntrospectionResultAssembler.java:331

◆ shouldAssembleExpectedResultForRefreshTokenWithoutExpiry()

void org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.shouldAssembleExpectedResultForRefreshTokenWithoutExpiry ( )
inline
259  {
260 
261  // given
262  OAuth2RefreshTokenEntity refreshToken = refreshToken(null,
263  oauth2AuthenticationWithUser(oauth2Request("clientId", scopes("foo", "bar")), "name"));
264 
265  UserInfo userInfo = userInfo("sub");
266 
267  Set<String> authScopes = scopes("foo", "bar", "baz");
268 
269  // when
270  Map<String, Object> result = assembler.assembleFrom(refreshToken, userInfo, authScopes);
271 
272 
273  // then
274  Map<String, Object> expected = new ImmutableMap.Builder<String, Object>()
275  .put("sub", "sub")
276  .put("scope", "bar foo")
277  .put("active", Boolean.TRUE)
278  .put("user_id", "name")
279  .put("client_id", "clientId")
280  .build();
281  assertThat(result, is(equalTo(expected)));
282  }
IntrospectionResultAssembler assembler
Definition: TestDefaultIntrospectionResultAssembler.java:53
OAuth2Request oauth2Request(String clientId)
Definition: TestDefaultIntrospectionResultAssembler.java:340
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348
UserInfo userInfo(String sub)
Definition: TestDefaultIntrospectionResultAssembler.java:308
Map< String, Object > assembleFrom(OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set< String > authScopes)
OAuth2RefreshTokenEntity refreshToken(Date exp, OAuth2Authentication authentication)
Definition: TestDefaultIntrospectionResultAssembler.java:324
OAuth2Authentication oauth2AuthenticationWithUser(OAuth2Request request, String username)
Definition: TestDefaultIntrospectionResultAssembler.java:331

◆ shouldAssembleExpectedResultForRefreshTokenWithoutUserAuthentication()

void org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.shouldAssembleExpectedResultForRefreshTokenWithoutUserAuthentication ( ) throws ParseException
inline
285  {
286  // given
287  OAuth2RefreshTokenEntity refreshToken = refreshToken(null,
288  oauth2Authentication(oauth2Request("clientId", scopes("foo", "bar")), null));
289 
290  Set<String> authScopes = scopes("foo", "bar", "baz");
291 
292  // when
293  Map<String, Object> result = assembler.assembleFrom(refreshToken, null, authScopes);
294 
295 
296  // then `user_id` should not be present
297  Map<String, Object> expected = new ImmutableMap.Builder<String, Object>()
298  .put("sub", "clientId")
299  .put("scope", "bar foo")
300  .put("active", Boolean.TRUE)
301  .put("client_id", "clientId")
302  .build();
303  assertThat(result, is(equalTo(expected)));
304  }
OAuth2Authentication oauth2Authentication(OAuth2Request request, Authentication userAuthentication)
Definition: TestDefaultIntrospectionResultAssembler.java:336
IntrospectionResultAssembler assembler
Definition: TestDefaultIntrospectionResultAssembler.java:53
OAuth2Request oauth2Request(String clientId)
Definition: TestDefaultIntrospectionResultAssembler.java:340
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348
Map< String, Object > assembleFrom(OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set< String > authScopes)
OAuth2RefreshTokenEntity refreshToken(Date exp, OAuth2Authentication authentication)
Definition: TestDefaultIntrospectionResultAssembler.java:324

◆ shouldAssembleExpectedResultForRefreshTokenWithoutUserInfo()

void org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.shouldAssembleExpectedResultForRefreshTokenWithoutUserInfo ( ) throws ParseException
inline
233  {
234 
235  // given
236  OAuth2RefreshTokenEntity refreshToken = refreshToken(new Date(123 * 1000L),
237  oauth2AuthenticationWithUser(oauth2Request("clientId", scopes("foo", "bar")), "name"));
238 
239  Set<String> authScopes = scopes("foo", "bar", "baz");
240 
241  // when
242  Map<String, Object> result = assembler.assembleFrom(refreshToken, null, authScopes);
243 
244 
245  // then
246  Map<String, Object> expected = new ImmutableMap.Builder<String, Object>()
247  .put("sub", "name")
248  .put("exp", 123L)
249  .put("expires_at", dateFormat.valueToString(new Date(123 * 1000L)))
250  .put("scope", "bar foo")
251  .put("active", Boolean.TRUE)
252  .put("user_id", "name")
253  .put("client_id", "clientId")
254  .build();
255  assertThat(result, is(equalTo(expected)));
256  }
IntrospectionResultAssembler assembler
Definition: TestDefaultIntrospectionResultAssembler.java:53
static DateFormatter dateFormat
Definition: TestDefaultIntrospectionResultAssembler.java:55
OAuth2Request oauth2Request(String clientId)
Definition: TestDefaultIntrospectionResultAssembler.java:340
Set< String > scopes(String... scopes)
Definition: TestDefaultIntrospectionResultAssembler.java:348
Map< String, Object > assembleFrom(OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set< String > authScopes)
OAuth2RefreshTokenEntity refreshToken(Date exp, OAuth2Authentication authentication)
Definition: TestDefaultIntrospectionResultAssembler.java:324
OAuth2Authentication oauth2AuthenticationWithUser(OAuth2Request request, String username)
Definition: TestDefaultIntrospectionResultAssembler.java:331

◆ userInfo()

UserInfo org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.userInfo ( String  sub)
inlineprivate
308  {
309  UserInfo userInfo = mock(UserInfo.class);
310  given(userInfo.getSub()).willReturn(sub);
311  return userInfo;
312  }
UserInfo userInfo(String sub)
Definition: TestDefaultIntrospectionResultAssembler.java:308

メンバ詳解

◆ assembler

IntrospectionResultAssembler org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.assembler = new DefaultIntrospectionResultAssembler()
private

◆ dateFormat

DateFormatter org.mitre.oauth2.service.impl.TestDefaultIntrospectionResultAssembler.dateFormat = new DateFormatter(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"))
staticprivate

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