2015-05-18 19:15:58 +02:00
|
|
|
package org.gcube.common.authorizationservice.cl;
|
|
|
|
|
|
|
|
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
|
|
|
|
2015-06-04 18:49:59 +02:00
|
|
|
import java.util.Arrays;
|
2015-05-29 18:32:43 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2015-06-04 18:49:59 +02:00
|
|
|
import org.gcube.common.authorization.library.BannedService;
|
|
|
|
import org.gcube.common.authorization.library.provider.Service;
|
2015-05-18 19:15:58 +02:00
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
import org.junit.Test;
|
|
|
|
public class CallTest {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void call(){
|
|
|
|
ScopeProvider.instance.set("/gcube/devsec");
|
2015-06-04 18:49:59 +02:00
|
|
|
System.out.println(authorizationService().build().get("d7a4076c-e8c1-42fe-81e0-bdecb1e8074a"));
|
2015-05-18 19:15:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void requestToken(){
|
|
|
|
|
|
|
|
ScopeProvider.instance.set("/gcube/devsec");
|
2015-06-04 18:49:59 +02:00
|
|
|
String token = authorizationService().build().generate("lucio.lelii", Arrays.asList("User"));
|
2015-05-18 19:15:58 +02:00
|
|
|
System.out.println("token is: "+token);
|
|
|
|
|
|
|
|
}
|
2015-05-21 16:19:37 +02:00
|
|
|
|
2015-06-04 18:49:59 +02:00
|
|
|
@Test
|
|
|
|
public void denyService(){
|
|
|
|
|
|
|
|
ScopeProvider.instance.set("/gcube/devsec");
|
|
|
|
authorizationService().build().deny("gianpaolo.coro", new Service("Test", "AuthorizationTest"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void allowService(){
|
|
|
|
|
|
|
|
ScopeProvider.instance.set("/gcube/devsec");
|
|
|
|
authorizationService().build().allow("gianpaolo.coro", new Service("Test", "AuthorizationTest"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getBannedServices(){
|
|
|
|
|
|
|
|
ScopeProvider.instance.set("/gcube/devsec");
|
|
|
|
List<BannedService> bannedServices = authorizationService().build().getBannedServices("lucio.lelii");
|
|
|
|
for (BannedService banService : bannedServices)
|
|
|
|
System.out.println(banService.getService());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-05-18 19:15:58 +02:00
|
|
|
}
|