Added token based instead of scope

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@133896 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-11-04 11:55:33 +00:00
parent a6ac22291f
commit cd225edb42
3 changed files with 51 additions and 8 deletions

View File

@ -6,7 +6,6 @@ package org.gcube.informationsystem.resourceregistry.publisher;
import java.util.List;
import java.util.UUID;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.NetworkingFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.SoftwareFacetImpl;
@ -35,7 +34,7 @@ import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class EntityManagementTest {
public class EntityManagementTest extends ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(EntityManagementTest.class);
@ -43,8 +42,8 @@ public class EntityManagementTest {
protected ResourceRegistryPublisher resourceRegistryPublisher;
@Before
public void before(){
ScopeProvider.instance.set("/gcube/devNext/NextNext");
public void before() throws Exception {
super.before();
resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
}

View File

@ -6,7 +6,6 @@ package org.gcube.informationsystem.resourceregistry.publisher;
import java.util.List;
import java.util.UUID;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.SoftwareFacetImpl;
import org.gcube.informationsystem.impl.entity.resource.EServiceImpl;
@ -34,7 +33,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class RRClientTest {
public class RRClientTest extends ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(EntityManagementTest.class);
@ -42,8 +41,8 @@ public class RRClientTest {
protected ResourceRegistryClient resourceRegistryClient;
@Before
public void before() {
ScopeProvider.instance.set("/gcube/devNext/NextNext");
public void before() throws Exception {
super.before();
resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
resourceRegistryClient = ResourceRegistryClientFactory.create();
logger.trace("{} and {} created",

View File

@ -0,0 +1,45 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.publisher;
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.scope.api.ScopeProvider;
import org.junit.After;
import org.junit.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*
*/
public class ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(ScopedTest.class);
private static final String TOKEN = "";
private static String getCurrentScope() throws ObjectNotFound, Exception{
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(TOKEN);
String context = authorizationEntry.getContext();
logger.info("Context of token {} is {}", TOKEN, context);
return context;
}
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TOKEN);
ScopeProvider.instance.set(getCurrentScope());
}
@After
public void after() throws Exception{
SecurityTokenProvider.instance.reset();
ScopeProvider.instance.reset();
}
}