Search in sources :

Example 1 with TenantPermission

use of org.craftercms.profile.api.TenantPermission 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 2 with TenantPermission

use of org.craftercms.profile.api.TenantPermission 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 3 with TenantPermission

use of org.craftercms.profile.api.TenantPermission 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)

Example 4 with TenantPermission

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

the class AccessTokenCheckingInterceptorTest method testPreHandle.

@Test
public void testPreHandle() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameter(ProfileConstants.PARAM_ACCESS_TOKEN_ID, NORMAL_TOKEN_ID);
    interceptor.preHandle(request, null, null);
    AccessToken token = AccessTokenUtils.getAccessToken(request);
    TenantPermission permission = new TenantPermission();
    permission.allow("*");
    assertNotNull(token);
    assertEquals(APPLICATION, token.getApplication());
    assertTrue(token.isMaster());
    assertEquals(Arrays.asList(permission), token.getTenantPermissions());
    verify(tokenRepository).findByStringId(NORMAL_TOKEN_ID);
}
Also used : TenantPermission(org.craftercms.profile.api.TenantPermission) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) AccessToken(org.craftercms.profile.api.AccessToken) Test(org.junit.Test)

Example 5 with TenantPermission

use of org.craftercms.profile.api.TenantPermission 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;
}
Also used : TenantPermission(org.craftercms.profile.api.TenantPermission) AccessToken(org.craftercms.profile.api.AccessToken)

Aggregations

AccessToken (org.craftercms.profile.api.AccessToken)5 TenantPermission (org.craftercms.profile.api.TenantPermission)5 Date (java.util.Date)2 Test (org.junit.Test)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1