changed the way to get the token in ScopedTest
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@141762 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
59f9fb2e98
commit
184cb662cb
|
@ -30,9 +30,6 @@ public class ISSweeperPluginSmartExecutorSchedulerTest extends ScopedTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() throws Exception{
|
public void before() throws Exception{
|
||||||
super.before();
|
|
||||||
//ScopeProvider.instance.reset(); // Comment this to run the test. this line has been added to avoid unwanted launch
|
|
||||||
//ScopeProvider.instance.set("/gcube/devsec");
|
|
||||||
proxy = ExecutorPlugin.getExecutorProxy(ISSweeperPluginDeclaration.NAME).build();
|
proxy = ExecutorPlugin.getExecutorProxy(ISSweeperPluginDeclaration.NAME).build();
|
||||||
Assert.assertNotNull(proxy);
|
Assert.assertNotNull(proxy);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +41,9 @@ public class ISSweeperPluginSmartExecutorSchedulerTest extends ScopedTest {
|
||||||
inputs.put(ISSweeperPlugin.DEAD_DAYS_TIMEOUT, 3);
|
inputs.put(ISSweeperPlugin.DEAD_DAYS_TIMEOUT, 3);
|
||||||
|
|
||||||
LaunchParameter parameter = new LaunchParameter(ISSweeperPluginDeclaration.NAME, inputs);
|
LaunchParameter parameter = new LaunchParameter(ISSweeperPluginDeclaration.NAME, inputs);
|
||||||
parameter.setScheduling(scheduling);
|
if(scheduling!=null){
|
||||||
|
parameter.setScheduling(scheduling);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String uuidString = proxy.launch(parameter);
|
String uuidString = proxy.launch(parameter);
|
||||||
|
@ -56,11 +55,12 @@ public class ISSweeperPluginSmartExecutorSchedulerTest extends ScopedTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
public void cronExpPreviousMustBeTerminated() throws Exception {
|
public void cronExpPreviousMustBeTerminated() throws Exception {
|
||||||
CronExpression cronExpression = new CronExpression("0 */10 * * * ?"); // every 10 minutes starting from now
|
CronExpression cronExpression = new CronExpression("0 */10 * * * ?"); // every 10 minutes starting from now
|
||||||
Scheduling scheduling = new Scheduling(cronExpression, true);
|
Scheduling scheduling = new Scheduling(cronExpression, true);
|
||||||
scheduling.setGlobal(true);
|
scheduling.setGlobal(true);
|
||||||
|
|
||||||
UUID uuid = scheduleTest(scheduling);
|
UUID uuid = scheduleTest(scheduling);
|
||||||
logger.debug("Launched with UUID : {}", uuid);
|
logger.debug("Launched with UUID : {}", uuid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,19 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.testutility;
|
package org.gcube.testutility;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
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.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.junit.After;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.BeforeClass;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
@ -14,14 +23,66 @@ import org.junit.Before;
|
||||||
*/
|
*/
|
||||||
public class ScopedTest {
|
public class ScopedTest {
|
||||||
|
|
||||||
@Before
|
private static final Logger logger = LoggerFactory.getLogger(ScopedTest.class);
|
||||||
public void before() throws Exception{
|
|
||||||
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
|
protected static final String PROPERTIES_FILENAME = "token.properties";
|
||||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
|
||||||
|
private static final String GCUBE_DEVNEXT_VARNAME = "GCUBE_DEVNEXT";
|
||||||
|
public static final String GCUBE_DEVNEXT;
|
||||||
|
|
||||||
|
private static final String GCUBE_DEVNEXT_NEXTNEXT_VARNAME = "GCUBE_DEVNEXT_NEXTNEXT";
|
||||||
|
public static final String GCUBE_DEVNEXT_NEXTNEXT;
|
||||||
|
|
||||||
|
public static final String GCUBE_DEVSEC_VARNAME = "GCUBE_DEVSEC";
|
||||||
|
public static final String GCUBE_DEVSEC;
|
||||||
|
|
||||||
|
public static final String GCUBE_DEVSEC_DEVVRE_VARNAME = "GCUBE_DEVSEC_DEVVRE";
|
||||||
|
public static final String GCUBE_DEVSEC_DEVVRE;
|
||||||
|
|
||||||
|
public static final String DEFAULT_TEST_SCOPE;
|
||||||
|
public static final String ALTERNATIVE_TEST_SCOPE;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Properties properties = new Properties();
|
||||||
|
InputStream input = ScopedTest.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// load the properties file
|
||||||
|
properties.load(input);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
GCUBE_DEVNEXT = properties.getProperty(GCUBE_DEVNEXT_VARNAME);
|
||||||
|
GCUBE_DEVNEXT_NEXTNEXT = properties.getProperty(GCUBE_DEVNEXT_NEXTNEXT_VARNAME);
|
||||||
|
|
||||||
|
GCUBE_DEVSEC = properties.getProperty(GCUBE_DEVSEC_VARNAME);
|
||||||
|
GCUBE_DEVSEC_DEVVRE = properties.getProperty(GCUBE_DEVSEC_DEVVRE_VARNAME);
|
||||||
|
|
||||||
|
DEFAULT_TEST_SCOPE = GCUBE_DEVNEXT;
|
||||||
|
ALTERNATIVE_TEST_SCOPE = GCUBE_DEVSEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
public static String getCurrentScope(String token) throws ObjectNotFound, Exception{
|
||||||
public void after() throws 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void beforeClass() throws Exception{
|
||||||
|
setContext(DEFAULT_TEST_SCOPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void afterClass() throws Exception{
|
||||||
SecurityTokenProvider.instance.reset();
|
SecurityTokenProvider.instance.reset();
|
||||||
ScopeProvider.instance.reset();
|
ScopeProvider.instance.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
GCUBE_DEVNEXT=
|
||||||
|
GCUBE_DEVNEXT_NEXTNEXT=
|
||||||
|
|
||||||
|
GCUBE_DEVSEC=
|
||||||
|
GCUBE_DEVSEC_DEVVRE=
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue