authorization-client/src/test/java/org/gcube/common/authorizationservice/cl/CallTest.java

71 lines
2.1 KiB
Java
Raw Normal View History

package org.gcube.common.authorizationservice.cl;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.util.ArrayList;
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
import org.gcube.common.scope.api.ScopeProvider;
import org.junit.Test;
public class CallTest {
@Test
public void call() throws Exception{
try{
System.out.println(authorizationService().get("a00affeb-0b75-4152-a134-e5c432a9a70a"));
}catch(ObjectNotFound onf){
onf.printStackTrace();
}
}
@Test
public void requestToken() throws Exception {
ScopeProvider.instance.set("/gcube");
String token = authorizationService().generate("fabio.sinibaldi", new ArrayList<String>());
System.out.println("token is: "+token);
}
/*
@Test
public void denyService() throws Exception {
ScopeProvider.instance.set("/gcube/devsec");
authorizationService().deny("giancarlo.panichi", "WPS", "DataMiner");
}
@Test
public void allowService() throws Exception{
ScopeProvider.instance.set("/gcube/devsec");
authorizationService().allow("lucio.lelii", "Test", "AuthorizationTest");
}
@Test
public void getBannedServices() throws Exception{
ScopeProvider.instance.set("/gcube/devsec");
List<BannedService> bannedServices = authorizationService().getBannedServices("lucio.lelii");
for (BannedService banService : bannedServices)
System.out.println(banService);
}
@Test
public void retreiveTest() throws Exception{
ScopeProvider.instance.set("/gcube");
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Category/text() eq 'Database'")
.addCondition("$resource/Profile/Name/text() eq 'AuthorizationDB'")
.setResult("$resource/Profile//AccessPoint[./Interface/Endpoint/@EntryName eq 'authorization']");
DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class);
List<AccessPoint> results = client.submit(query);
for (AccessPoint ap : results){
System.out.println(ap.username()+" "+StringEncrypter.getEncrypter().decrypt(ap.password()));
}
}
*/
}