Search in sources :

Example 1 with AccessToken

use of org.craftercms.profile.api.AccessToken in project profile by craftercms.

the class AccessTokenServiceImplTest method testCreateToken.

@Test
public void testCreateToken() throws Exception {
    AccessToken expected = getNormalToken();
    AccessToken actual = accessTokenService.createToken(getNormalToken());
    assertNotNull(actual);
    assertNotNull(actual.getId());
    assertEquals(expected.getApplication(), actual.getApplication());
    assertEquals(expected.isMaster(), actual.isMaster());
    assertEquals(expected.getTenantPermissions(), actual.getTenantPermissions());
    assertEquals(expected.getExpiresOn(), actual.getExpiresOn());
    verify(accessTokenRepository).insert(actual);
}
Also used : AccessToken(org.craftercms.profile.api.AccessToken) Test(org.junit.Test)

Example 2 with AccessToken

use of org.craftercms.profile.api.AccessToken in project profile by craftercms.

the class AccessTokenServiceImplTest method getCurrentToken.

private AccessToken getCurrentToken() {
    AccessToken token = new AccessToken();
    token.setId(CURRENT_TOKEN_ID);
    token.setMaster(true);
    return token;
}
Also used : AccessToken(org.craftercms.profile.api.AccessToken)

Example 3 with AccessToken

use of org.craftercms.profile.api.AccessToken in project profile by craftercms.

the class AccessTokenCheckingInterceptorTest method getNormalToken.

private AccessToken getNormalToken() {
    TenantPermission permission = new TenantPermission();
    permission.allowAny();
    AccessToken token = new AccessToken();
    token.setId(NORMAL_TOKEN_ID);
    token.setApplication(APPLICATION);
    token.setMaster(true);
    token.setTenantPermissions(Arrays.asList(permission));
    token.setExpiresOn(new Date(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(24)));
    return token;
}
Also used : TenantPermission(org.craftercms.profile.api.TenantPermission) AccessToken(org.craftercms.profile.api.AccessToken) Date(java.util.Date)

Example 4 with AccessToken

use of org.craftercms.profile.api.AccessToken in project profile by craftercms.

the class AccessTokenCheckingInterceptorTest method getExpiredToken.

private AccessToken getExpiredToken() {
    TenantPermission permission = new TenantPermission();
    permission.allowAny();
    AccessToken token = new AccessToken();
    token.setId(EXPIRED_TOKEN_ID);
    token.setApplication(APPLICATION);
    token.setMaster(true);
    token.setTenantPermissions(Arrays.asList(permission));
    token.setExpiresOn(new Date());
    return token;
}
Also used : TenantPermission(org.craftercms.profile.api.TenantPermission) AccessToken(org.craftercms.profile.api.AccessToken) Date(java.util.Date)

Example 5 with AccessToken

use of org.craftercms.profile.api.AccessToken in project profile by craftercms.

the class AccessTokenServiceIT method getCrafterStudioAccessToken.

private AccessToken getCrafterStudioAccessToken() {
    TenantPermission permission = new TenantPermission();
    permission.allowAny();
    AccessToken token = new AccessToken();
    token.setApplication(CRAFTER_STUDIO_APPLICATION);
    token.setMaster(true);
    token.setTenantPermissions(Arrays.asList(permission));
    token.setExpiresOn(EXPIRES_ON);
    return token;
}
Also used : TenantPermission(org.craftercms.profile.api.TenantPermission) AccessToken(org.craftercms.profile.api.AccessToken)

Aggregations

AccessToken (org.craftercms.profile.api.AccessToken)13 Test (org.junit.Test)6 TenantPermission (org.craftercms.profile.api.TenantPermission)5 Date (java.util.Date)4 SimpleDateFormat (java.text.SimpleDateFormat)1 ResourceNotFoundException (org.craftercms.profile.management.exceptions.ResourceNotFoundException)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1