use of org.craftercms.profile.api.AccessToken in project profile by craftercms.
the class AccessTokenController method getAccessToken.
@RequestMapping(value = URL_GET_ACCESS_TOKEN, method = RequestMethod.GET)
@ResponseBody
public AccessToken getAccessToken(@PathVariable(PATH_VAR_ID) String id) throws ProfileException {
checkIfAllowed(id, Action.GET_PROFILE);
AccessToken token = accessTokenService.getToken(id);
if (token != null) {
return token;
} else {
throw new ResourceNotFoundException("No access token found with ID '" + id + "'");
}
}
use of org.craftercms.profile.api.AccessToken in project profile by craftercms.
the class AccessTokenServiceImplTest method testGetToken.
@Test
public void testGetToken() throws Exception {
AccessToken expected = getNormalToken();
AccessToken actual = accessTokenService.getToken(TOKEN_ID);
assertNotNull(actual);
assertEquals(expected.getId(), actual.getId());
assertEquals(expected.getApplication(), actual.getApplication());
assertEquals(expected.isMaster(), actual.isMaster());
assertEquals(expected.getTenantPermissions(), actual.getTenantPermissions());
assertEquals(expected.getExpiresOn(), actual.getExpiresOn());
verify(accessTokenRepository).findByStringId(TOKEN_ID);
}
use of org.craftercms.profile.api.AccessToken in project profile by craftercms.
the class AccessTokenServiceImplTest method getNormalToken.
private AccessToken getNormalToken() {
TenantPermission permission = new TenantPermission();
permission.allowAny();
AccessToken token = new AccessToken();
token.setId(TOKEN_ID);
token.setApplication(APPLICATION);
token.setMaster(true);
token.setTenantPermissions(Arrays.asList(permission));
token.setExpiresOn(EXPIRES_ON);
return token;
}
Aggregations