diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/ScopedTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/ScopedTest.java index 8537adc..1ac216c 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/ScopedTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/ScopedTest.java @@ -10,7 +10,10 @@ import java.util.Properties; 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.AuthorizationProvider; +import org.gcube.common.authorization.library.provider.ClientInfo; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; +import org.gcube.common.authorization.library.utils.Caller; import org.gcube.common.scope.api.ScopeProvider; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -39,7 +42,12 @@ public class ScopedTest { public static final String GCUBE_DEVSEC_DEVVRE_VARNAME = "GCUBE_DEVSEC_DEVVRE"; public static final String GCUBE_DEVSEC_DEVVRE; + + private static final String GCUBE_DEVNEXT_ANOTHER_USER_VARNAME = "GCUBE_DEVNEXT_ANOTHER_USER"; + public static final String GCUBE_DEVNEXT_ANOTHER_USER; + public static final String DEFAULT_TEST_SCOPE; + public static final String DEFAULT_TEST_SCOPE_ANOTHER_USER; public static final String ALTERNATIVE_TEST_SCOPE; static { @@ -59,7 +67,11 @@ public class ScopedTest { GCUBE_DEVSEC = properties.getProperty(GCUBE_DEVSEC_VARNAME); GCUBE_DEVSEC_DEVVRE = properties.getProperty(GCUBE_DEVSEC_DEVVRE_VARNAME); + GCUBE_DEVNEXT_ANOTHER_USER = properties.getProperty(GCUBE_DEVNEXT_ANOTHER_USER_VARNAME); + + DEFAULT_TEST_SCOPE = GCUBE_DEVNEXT; + DEFAULT_TEST_SCOPE_ANOTHER_USER = GCUBE_DEVNEXT_ANOTHER_USER; ALTERNATIVE_TEST_SCOPE = GCUBE_DEVNEXT_NEXTNEXT; } @@ -73,6 +85,11 @@ public class ScopedTest { public static void setContext(String token) throws ObjectNotFound, Exception{ SecurityTokenProvider.instance.set(token); + AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token); + ClientInfo clientInfo = authorizationEntry.getClientInfo(); + String qualifier = authorizationEntry.getQualifier(); + Caller caller = new Caller(clientInfo, qualifier); + AuthorizationProvider.instance.set(caller); ScopeProvider.instance.set(getCurrentScope(token)); }