Fixed properties retrieving
This commit is contained in:
parent
43328f5cfe
commit
9a282c4a7f
|
@ -50,7 +50,22 @@ public class ContextTest {
|
|||
DEFAULT_TEST_SCOPE_NAME = "/gcube/devNext/NextNext";
|
||||
}
|
||||
|
||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {
|
||||
public static String getCurrentContext(){
|
||||
String token = SecurityTokenProvider.instance.get();
|
||||
AuthorizationEntry authorizationEntry;
|
||||
try {
|
||||
authorizationEntry = Constants.authorizationService().get(token);
|
||||
} catch (Exception e) {
|
||||
logger.trace("Context was not retrieved from token. Going to get it from {}", ScopeProvider.class.getSimpleName());
|
||||
return ScopeProvider.instance.get();
|
||||
}
|
||||
String context = authorizationEntry.getContext();
|
||||
logger.trace("Context retrieved from token is {}. Context in {} is {}",
|
||||
context, ScopeProvider.class.getSimpleName(), ScopeProvider.instance.get());
|
||||
return context;
|
||||
}
|
||||
|
||||
public static String getContext(String token) throws ObjectNotFound, Exception {
|
||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||
String context = authorizationEntry.getContext();
|
||||
logger.info("Context of token {} is {}", token, context);
|
||||
|
@ -70,7 +85,7 @@ public class ContextTest {
|
|||
String qualifier = authorizationEntry.getQualifier();
|
||||
Caller caller = new Caller(clientInfo, qualifier);
|
||||
AuthorizationProvider.instance.set(caller);
|
||||
ScopeProvider.instance.set(getCurrentScope(token));
|
||||
ScopeProvider.instance.set(getContext(token));
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -5,19 +5,18 @@ package org.gcube.vremanagement.executor;
|
|||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.authorization.client.Constants;
|
||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.resources.gcore.Resource;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.gcube.resources.discovery.icclient.ICFactory;
|
||||
import org.gcube.vremanagement.executor.plugin.Plugin;
|
||||
import org.gcube.vremanagement.executor.pluginmanager.PluginManager;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -29,33 +28,12 @@ public class SmartExecutorInizializatorTest {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(SmartExecutorInizializatorTest.class);
|
||||
|
||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception{
|
||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||
String context = authorizationEntry.getContext();
|
||||
logger.info("Context of token {} is {}", token, context);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
public static void setContext(String token) throws ObjectNotFound, Exception{
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
ScopeProvider.instance.set(getCurrentScope(token));
|
||||
}
|
||||
|
||||
|
||||
public static String getCurrentScope(){
|
||||
String token = SecurityTokenProvider.instance.get();
|
||||
AuthorizationEntry authorizationEntry;
|
||||
try {
|
||||
authorizationEntry = Constants.authorizationService().get(token);
|
||||
} catch (Exception e) {
|
||||
logger.trace("Context was not retrieved from token. Going to get it from {}", ScopeProvider.class.getSimpleName());
|
||||
return ScopeProvider.instance.get();
|
||||
@Test
|
||||
public void getAvailablePlugin() {
|
||||
Map<String, Class<? extends Plugin>> availablePlugins = PluginManager.getAvailablePlugins();
|
||||
for(String pluginName : availablePlugins.keySet()) {
|
||||
logger.debug("Plugin {}, Class {}", pluginName, availablePlugins.get(pluginName).getSimpleName());
|
||||
}
|
||||
String context = authorizationEntry.getContext();
|
||||
logger.trace("Context retrieved from token is {}. Context in {} is {}",
|
||||
context, ScopeProvider.class.getSimpleName(), ScopeProvider.instance.get());
|
||||
return context;
|
||||
}
|
||||
|
||||
protected static void unPublishResource(Resource resource) throws Exception {
|
||||
|
@ -65,7 +43,7 @@ public class SmartExecutorInizializatorTest {
|
|||
RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
|
||||
|
||||
String id = resource.id();
|
||||
logger.debug("Trying to remove {} with ID {} from {}", resource.getClass().getSimpleName(), id, getCurrentScope());
|
||||
logger.debug("Trying to remove {} with ID {} from {}", resource.getClass().getSimpleName(), id, ContextTest.getCurrentContext());
|
||||
|
||||
registryPublisher.remove(resource);
|
||||
|
||||
|
|
Loading…
Reference in New Issue