From a3de8cee21e653a06c7ec5efbb70c35990f23dd8 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Mon, 13 Nov 2017 11:53:40 +0000 Subject: [PATCH] Added alternative user tokens git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@158409 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../resourceregistry/ScopedTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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)); }