Fixed configuration issues
This commit is contained in:
parent
ef2cb362f3
commit
8b43f00fb2
|
@ -520,9 +520,7 @@ public class GCoreISConfigurationProxy {
|
||||||
protected Property addProperty(Group<Property> properties, String name, String value, boolean encrypted) {
|
protected Property addProperty(Group<Property> properties, String name, String value, boolean encrypted) {
|
||||||
Property property = new Property();
|
Property property = new Property();
|
||||||
property.nameAndValue(name, value);
|
property.nameAndValue(name, value);
|
||||||
if(encrypted) {
|
property.encrypted(encrypted);
|
||||||
property.encrypted(encrypted);
|
|
||||||
}
|
|
||||||
properties.add(property);
|
properties.add(property);
|
||||||
return property;
|
return property;
|
||||||
}
|
}
|
||||||
|
@ -538,10 +536,25 @@ public class GCoreISConfigurationProxy {
|
||||||
Iterator<String> iterator = jsonNode.fieldNames();
|
Iterator<String> iterator = jsonNode.fieldNames();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
String key = iterator.next();
|
String key = iterator.next();
|
||||||
|
|
||||||
|
if(key.compareTo(CatalogueConfiguration.ID_KEY)==0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(key.compareTo(CatalogueConfiguration.SYS_ADMIN_TOKEN_KEY)==0) {
|
||||||
|
addProperty(properties, key, catalogueConfiguration.getEncryptedSysAdminToken(), true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
JsonNode valueJsonNode = jsonNode.get(key);
|
JsonNode valueJsonNode = jsonNode.get(key);
|
||||||
|
|
||||||
String value = valueJsonNode.toString();
|
String value = valueJsonNode.toString();
|
||||||
|
if(valueJsonNode.isTextual()) {
|
||||||
|
value = valueJsonNode.asText();
|
||||||
|
}
|
||||||
|
|
||||||
addProperty(properties, key, value);
|
addProperty(properties, key, value);
|
||||||
|
|
||||||
}
|
}
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class ServiceCatalogueConfiguration extends CatalogueConfiguration {
|
||||||
public ObjectNode toObjetcNode(boolean decryptedValues) throws JsonProcessingException {
|
public ObjectNode toObjetcNode(boolean decryptedValues) throws JsonProcessingException {
|
||||||
ObjectNode configuration = mapper.valueToTree(this);
|
ObjectNode configuration = mapper.valueToTree(this);
|
||||||
CKANUser ckanUser = CKANUserCache.getCurrrentCKANUser();
|
CKANUser ckanUser = CKANUserCache.getCurrrentCKANUser();
|
||||||
if(ckanUser.getRole() != Role.MANAGER) {
|
if(ckanUser.getRole().ordinal() < Role.MANAGER.ordinal()) {
|
||||||
configuration.remove(ServiceCatalogueConfiguration.SYS_ADMIN_TOKEN_KEY);
|
configuration.remove(ServiceCatalogueConfiguration.SYS_ADMIN_TOKEN_KEY);
|
||||||
configuration.remove(ServiceCatalogueConfiguration.CKAN_DB_KEY);
|
configuration.remove(ServiceCatalogueConfiguration.CKAN_DB_KEY);
|
||||||
}else {
|
}else {
|
||||||
|
|
|
@ -8,16 +8,14 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||||
import org.gcube.gcat.ContextTest;
|
import org.gcube.gcat.ContextTest;
|
||||||
import org.gcube.smartgears.ContextProvider;
|
|
||||||
import org.gcube.smartgears.configuration.application.ApplicationConfiguration;
|
|
||||||
import org.gcube.smartgears.configuration.application.DefaultApplicationConfiguration;
|
|
||||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
|
||||||
import org.gcube.smartgears.context.application.DefaultApplicationContext;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*/
|
||||||
public class GCoreISConfigurationProxyTest extends ContextTest {
|
public class GCoreISConfigurationProxyTest extends ContextTest {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GCoreISConfigurationProxyTest.class);
|
private static final Logger logger = LoggerFactory.getLogger(GCoreISConfigurationProxyTest.class);
|
||||||
|
@ -27,18 +25,20 @@ public class GCoreISConfigurationProxyTest extends ContextTest {
|
||||||
ContextTest.setContextByName("/gcube/devNext/NextNext");
|
ContextTest.setContextByName("/gcube/devNext/NextNext");
|
||||||
String context = SecretManager.instance.get().getContext();
|
String context = SecretManager.instance.get().getContext();
|
||||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
Set<String> organizations = gCoreISConfigurationProxy.getSupportedOrganizationsFromGenericResource();
|
Set<String> organizations = gCoreISConfigurationProxy.getSupportedOrganizationsFromGenericResource();
|
||||||
Assert.assertTrue(organizations.size()>0);
|
Assert.assertTrue(organizations.size()>0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCatalogueConfiguration() throws Exception {
|
public void testCatalogueConfiguration() throws Exception {
|
||||||
ContextTest.setContextByName("/gcube/devNext");
|
ContextTest.setContextByName("/gcube/devsec/devVRE");
|
||||||
String context = SecretManager.instance.get().getContext();
|
String context = SecretManager.instance.get().getContext();
|
||||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
||||||
ServiceCatalogueConfiguration catalogueConfiguration = gCoreISConfigurationProxy.getOLDCatalogueConfigurationFromIS();
|
ServiceCatalogueConfiguration catalogueConfiguration = gCoreISConfigurationProxy.getCatalogueConfigurationFromIS();
|
||||||
String json = catalogueConfiguration.toJsonString();
|
String json = catalogueConfiguration.toJsonString();
|
||||||
logger.info("Configuration in context {} is {}", context, json);
|
logger.info("Configuration in context {} is {}", context, json);
|
||||||
|
/*
|
||||||
ServiceCatalogueConfiguration secondCatalogueConfiguration = ServiceCatalogueConfiguration.getServiceCatalogueConfiguration(json);
|
ServiceCatalogueConfiguration secondCatalogueConfiguration = ServiceCatalogueConfiguration.getServiceCatalogueConfiguration(json);
|
||||||
String secondJson = secondCatalogueConfiguration.toJsonString();
|
String secondJson = secondCatalogueConfiguration.toJsonString();
|
||||||
logger.info("After marshalling and unmarshalling configuration in context {} is {}", context, secondJson);
|
logger.info("After marshalling and unmarshalling configuration in context {} is {}", context, secondJson);
|
||||||
|
@ -48,6 +48,7 @@ public class GCoreISConfigurationProxyTest extends ContextTest {
|
||||||
String thirdJson = thirdCatalogueConfiguration.toJsonString();
|
String thirdJson = thirdCatalogueConfiguration.toJsonString();
|
||||||
logger.info("After marshalling and unmarshalling decrypted configuration in context {} is {}", context, thirdJson);
|
logger.info("After marshalling and unmarshalling decrypted configuration in context {} is {}", context, thirdJson);
|
||||||
logger.info("All as JsonArray [{},{},{},{}]", json, secondJson, decryptedJson, thirdJson);
|
logger.info("All as JsonArray [{},{},{},{}]", json, secondJson, decryptedJson, thirdJson);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
|
@ -55,6 +56,7 @@ public class GCoreISConfigurationProxyTest extends ContextTest {
|
||||||
ContextTest.setContextByName("/gcube/devsec/devVRE");
|
ContextTest.setContextByName("/gcube/devsec/devVRE");
|
||||||
String context = SecretManager.instance.get().getContext();
|
String context = SecretManager.instance.get().getContext();
|
||||||
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
ServiceCatalogueConfiguration catalogueConfiguration = gCoreISConfigurationProxy.getOLDCatalogueConfigurationFromIS();
|
ServiceCatalogueConfiguration catalogueConfiguration = gCoreISConfigurationProxy.getOLDCatalogueConfigurationFromIS();
|
||||||
String json = catalogueConfiguration.toJsonString();
|
String json = catalogueConfiguration.toJsonString();
|
||||||
logger.debug("Read configuration {}", json);
|
logger.debug("Read configuration {}", json);
|
||||||
|
@ -65,7 +67,7 @@ public class GCoreISConfigurationProxyTest extends ContextTest {
|
||||||
|
|
||||||
public static String DEVVRE_CONFIG_JSON = "devvre.conf.json";
|
public static String DEVVRE_CONFIG_JSON = "devvre.conf.json";
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
public void createConfiguration() throws Exception {
|
public void createConfiguration() throws Exception {
|
||||||
ContextTest.setContextByName("/gcube/devsec/devVRE");
|
ContextTest.setContextByName("/gcube/devsec/devVRE");
|
||||||
String context = SecretManager.instance.get().getContext();
|
String context = SecretManager.instance.get().getContext();
|
||||||
|
|
Loading…
Reference in New Issue