52 lines
1.4 KiB
Java
52 lines
1.4 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.dataharvest.utils;
|
|
|
|
import java.util.Properties;
|
|
|
|
import org.gcube.common.authorization.utils.manager.SecretManager;
|
|
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
|
import org.gcube.common.authorization.utils.secret.Secret;
|
|
import org.junit.AfterClass;
|
|
import org.junit.BeforeClass;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
*/
|
|
public class ContextTest {
|
|
|
|
protected static Properties properties;
|
|
protected static final String PROPERTIES_FILENAME = "token.properties";
|
|
|
|
protected static ContextAuthorization contextAuthorization;
|
|
|
|
private static void set(Secret secret) throws Exception {
|
|
SecretManagerProvider.instance.reset();
|
|
SecretManager secretManager = new SecretManager();
|
|
SecretManagerProvider.instance.set(secretManager);
|
|
secretManager.addSecret(secret);
|
|
secretManager.set();
|
|
}
|
|
|
|
public static void set(String fullContextName) throws Exception {
|
|
Secret secret = getSecretByContextName(fullContextName);
|
|
set(secret);
|
|
}
|
|
|
|
private static Secret getSecretByContextName(String fullContextName) throws Exception {
|
|
return contextAuthorization.getSecretForContext(fullContextName);
|
|
}
|
|
|
|
@BeforeClass
|
|
public static void beforeClass() throws Exception {
|
|
contextAuthorization = new ContextAuthorization();
|
|
}
|
|
|
|
@AfterClass
|
|
public static void afterClass() throws Exception {
|
|
SecretManagerProvider.instance.reset();
|
|
}
|
|
|
|
}
|