diff --git a/Jenkinsfile b/Jenkinsfile
index 4361987c36a..7e7e31da477 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,9 +1,15 @@
node {
- properties([disableConcurrentBuilds(abortPrevious: true), buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')), gitLabConnection('gitlab.eclipse.org'), [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false], [$class: 'JobLocalConfiguration', changeReasonComment: '']])
+ properties([
+ disableConcurrentBuilds(abortPrevious: true),
+ buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')),
+ gitLabConnection('gitlab.eclipse.org'),
+ [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
+ [$class: 'JobLocalConfiguration', changeReasonComment: '']
+ ])
deleteDir()
- stage('Preparation') {
+ stage('Preparation') {
dir("kura") {
checkout scm
}
@@ -14,7 +20,7 @@ node {
dir("kura") {
withMaven(jdk: 'adoptopenjdk-hotspot-jdk8-latest', maven: 'apache-maven-3.6.3') {
sh "touch /tmp/isJenkins.txt"
- sh "mvn -f target-platform/pom.xml clean install -Pno-mirror -Pcheck-exists-plugin"
+ sh "mvn -f target-platform/pom.xml clean install -Pno-mirror -Pcheck-exists-plugin"
sh "mvn -f kura/pom.xml clean install -Pcheck-exists-plugin"
sh "mvn -f kura/distrib/pom.xml clean install -DbuildAll"
sh "mvn -f kura/examples/pom.xml clean install -Pcheck-exists-plugin"
@@ -41,17 +47,20 @@ node {
withMaven(jdk: 'temurin-jdk17-latest', maven: 'apache-maven-3.6.3') {
withCredentials([string(credentialsId: 'sonarcloud-token', variable: 'SONARCLOUD_TOKEN')]) {
withSonarQubeEnv {
- sh '''mvn -f kura/pom.xml sonar:sonar \
- -Dmaven.test.failure.ignore=true \
- -Dsonar.organization=eclipse \
- -Dsonar.host.url=${SONAR_HOST_URL} \
- -Dsonar.login=${SONARCLOUD_TOKEN} \
- -Dsonar.branch.name=${BRANCH_NAME} \
- -Dsonar.branch.target=${CHANGE_TARGET} \
- -Dsonar.java.binaries='target/' \
- -Dsonar.core.codeCoveragePlugin=jacoco \
- -Dsonar.projectKey=org.eclipse.kura:kura \
- -Dsonar.exclusions=test/**/*.java,test-util/**/*.java,org.eclipse.kura.web2/**/*.java,org.eclipse.kura.nm/src/main/java/org/freedesktop/**/*,org.eclipse.kura.nm/src/main/java/fi/w1/**/*'''
+ sh '''
+ mvn -f kura/pom.xml sonar:sonar \
+ -Dmaven.test.failure.ignore=true \
+ -Dsonar.organization=eclipse \
+ -Dsonar.host.url=${SONAR_HOST_URL} \
+ -Dsonar.login=${SONARCLOUD_TOKEN} \
+ -Dsonar.branch.name=${BRANCH_NAME} \
+ -Dsonar.branch.target=${CHANGE_TARGET} \
+ -Dsonar.java.source=8 \
+ -Dsonar.java.binaries='target/' \
+ -Dsonar.core.codeCoveragePlugin=jacoco \
+ -Dsonar.projectKey=org.eclipse.kura:kura \
+ -Dsonar.exclusions=test/**/*.java,test-util/**/*.java,org.eclipse.kura.web2/**/*.java,org.eclipse.kura.nm/src/main/java/org/freedesktop/**/*,org.eclipse.kura.nm/src/main/java/fi/w1/**/*
+ '''
}
}
}
diff --git a/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.dbus.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.dbus.test/pom.xml
index 0908a0cee2b..580361383f4 100644
--- a/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.dbus.test/pom.xml
+++ b/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.dbus.test/pom.xml
@@ -28,6 +28,7 @@
${project.basedir}/../../..
+ ${project.build.directory}/site/jacoco-aggregate/jacoco.xml
diff --git a/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.test/pom.xml
index b08c05ce32a..dda673a6f6f 100644
--- a/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.test/pom.xml
+++ b/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.test/pom.xml
@@ -28,6 +28,7 @@
${project.basedir}/../../..
+ ${project.build.directory}/site/jacoco-aggregate/jacoco.xml
diff --git a/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml
index 5d0d16e9ef0..2af604726e8 100644
--- a/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml
+++ b/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml
@@ -24,6 +24,7 @@
${project.basedir}/../../..
+ ${project.build.directory}/site/jacoco-aggregate/jacoco.xml
diff --git a/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml
index 3805e00d88b..5a8f89bdaa9 100644
--- a/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml
+++ b/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml
@@ -28,6 +28,7 @@
${project.basedir}/../../..
+ ${project.build.directory}/site/jacoco-aggregate/jacoco.xml
diff --git a/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml
index 681c82f2c9b..52819964da0 100644
--- a/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml
+++ b/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml
@@ -28,6 +28,7 @@
${project.basedir}/../../..
+ ${project.build.directory}/site/jacoco-aggregate/jacoco.xml
diff --git a/kura/examples/test/pom.xml b/kura/examples/test/pom.xml
index 50ee93e7609..8c8cc69d97c 100644
--- a/kura/examples/test/pom.xml
+++ b/kura/examples/test/pom.xml
@@ -273,9 +273,6 @@
${project.basedir}/../..
${jacocoArgs} -Dlog4j.configurationFile=file:${kura.basedir}/emulator/org.eclipse.kura.emulator/src/main/resources/log4j.xml
- target/jacoco/
-
- ${project.basedir}/../../test/*/target/site/jacoco-aggregate/jacoco.xml
diff --git a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceImpl.java b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceImpl.java
index e0c3317cef2..3e300ac1dad 100644
--- a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceImpl.java
+++ b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceImpl.java
@@ -712,9 +712,7 @@ private boolean isValidMessage(KuraApplicationTopic kuraTopic, KuraPayload kuraP
public void onMessagePublished(int messageId, String topic) {
synchronized (this.messageId) {
if (this.messageId.get() != -1 && this.messageId.get() == messageId) {
- if (CloudServiceOptions.getLifeCycleMessageQos() == 0) {
- this.messageId.set(-1);
- }
+ this.messageId.set(-1);
this.messageId.notifyAll();
return;
}
@@ -885,7 +883,7 @@ private void publishLifeCycleMessage(LifecycleMessage message) throws KuraExcept
payload.setTimestamp(new Date());
byte[] encodedPayload = encodePayload(payload);
int id = this.dataService.publish(message.getTopic(), encodedPayload,
- CloudServiceOptions.getLifeCycleMessageQos(), CloudServiceOptions.getLifeCycleMessageRetain(),
+ message.getQos(), CloudServiceOptions.getLifeCycleMessageRetain(),
CloudServiceOptions.getLifeCycleMessagePriority());
this.messageId.set(id);
try {
diff --git a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceOptions.java b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceOptions.java
index 95f9626e4e9..9bc4716f8b3 100644
--- a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceOptions.java
+++ b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceOptions.java
@@ -42,7 +42,6 @@ public class CloudServiceOptions {
private static final String ENABLE_DFLT_SUBSCRIPTIONS = "enable.default.subscriptions";
private static final String PAYLOAD_ENCODING = "payload.encoding";
- private static final int LIFECYCLE_QOS = 0;
private static final int LIFECYCLE_PRIORITY = 0;
private static final boolean LIFECYCLE_RETAIN = false;
@@ -217,10 +216,6 @@ public static String getTopicWildCard() {
return TOPIC_WILD_CARD;
}
- public static int getLifeCycleMessageQos() {
- return LIFECYCLE_QOS;
- }
-
public static int getLifeCycleMessagePriority() {
return LIFECYCLE_PRIORITY;
}
diff --git a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/LifecycleMessage.java b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/LifecycleMessage.java
index 40e9d04f3e6..7a97df4ea9f 100644
--- a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/LifecycleMessage.java
+++ b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/LifecycleMessage.java
@@ -21,6 +21,7 @@ public class LifecycleMessage {
private KuraPayload payload;
private boolean isAppCertificateMessage = false;
private boolean isBirthCertificateMessage = false;
+ private int qos = 0;
public LifecycleMessage(CloudServiceOptions options, CloudServiceImpl cloudServiceImpl) {
this.topicBuilder = new StringBuilder(options.getTopicControlPrefix());
@@ -37,6 +38,7 @@ public LifecycleMessage asBirthCertificateMessage() {
this.topicBuilder.append(CloudServiceOptions.getTopicBirthSuffix());
this.payload = this.payloadBuilder.buildBirthPayload();
this.isBirthCertificateMessage = true;
+ this.qos = 1;
return this;
}
@@ -44,6 +46,7 @@ public LifecycleMessage asAppCertificateMessage() {
this.topicBuilder.append(CloudServiceOptions.getTopicAppsSuffix());
this.payload = this.payloadBuilder.buildBirthPayload();
this.isAppCertificateMessage = true;
+ this.qos = 1;
return this;
}
@@ -68,5 +71,9 @@ public boolean isAppCertificateMessage() {
public boolean isBirthCertificateMessage() {
return this.isBirthCertificateMessage;
}
+
+ public int getQos() {
+ return this.qos;
+ }
}
diff --git a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java
index f1b254a6f7d..043d264f108 100644
--- a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java
+++ b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java
@@ -342,7 +342,7 @@ private void findAndDecodeCertificatesForInterface(String interfaceName, Map keyCertStrings = Arrays.asList(clientCertString, caCertString, privateKeyString);
@@ -367,7 +367,7 @@ private void findAndDecodeCertificatesForInterface(String interfaceName, Map getProperties() {
return this.properties;
}
+ public ComponentConfigurationDTO replacePasswordsWithPlaceholder() {
+
+ if (properties == null) {
+ return this;
+ }
+
+ final Map result = new HashMap<>(this.properties);
+
+ for (final Entry e : result.entrySet()) {
+ e.setValue(replacePasswordsWithPlaceholder(e.getValue()));
+ }
+
+ return new ComponentConfigurationDTO(pid, definition, result);
+ }
+
+ public PropertyDTO replacePasswordsWithPlaceholder(final PropertyDTO property) {
+
+ if (property == null || property.getType() != Scalar.PASSWORD) {
+ return property;
+ }
+
+ if (property.getValue() instanceof String[]) {
+ final String[] asStringArray = (String[]) property.getValue();
+ final String[] result = new String[asStringArray.length];
+
+ for (int i = 0; i < asStringArray.length; i++) {
+ if (asStringArray[i] != null) {
+ result[i] = "placeholder";
+ }
+ }
+
+ return new PropertyDTO(result, Scalar.PASSWORD);
+ } else {
+ return new PropertyDTO("placeholder", Scalar.PASSWORD);
+ }
+ }
+
@Override
public void validate() {
FailureHandler.requireParameter(this.pid, "pid");
diff --git a/kura/org.eclipse.kura.rest.configuration.provider/src/main/java/org/eclipse/kura/rest/configuration/api/ComponentConfigurationList.java b/kura/org.eclipse.kura.rest.configuration.provider/src/main/java/org/eclipse/kura/rest/configuration/api/ComponentConfigurationList.java
index bc92aed3e39..c20b40f715f 100644
--- a/kura/org.eclipse.kura.rest.configuration.provider/src/main/java/org/eclipse/kura/rest/configuration/api/ComponentConfigurationList.java
+++ b/kura/org.eclipse.kura.rest.configuration.provider/src/main/java/org/eclipse/kura/rest/configuration/api/ComponentConfigurationList.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2021, 2022 Eurotech and/or its affiliates and others
+ * Copyright (c) 2021, 2023 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -13,6 +13,7 @@
package org.eclipse.kura.rest.configuration.api;
import java.util.List;
+import java.util.stream.Collectors;
public class ComponentConfigurationList implements Validable {
@@ -30,4 +31,14 @@ public List getConfigs() {
public void validate() {
FailureHandler.requireParameter(this.configs, "configs");
}
+
+ public ComponentConfigurationList replacePasswordsWithPlaceholder() {
+ if (configs == null) {
+ return this;
+ }
+
+ return new ComponentConfigurationList(
+ configs.stream().map(ComponentConfigurationDTO::replacePasswordsWithPlaceholder)
+ .collect(Collectors.toList()));
+ }
}
diff --git a/kura/org.eclipse.kura.rest.wire.provider/META-INF/MANIFEST.MF b/kura/org.eclipse.kura.rest.wire.provider/META-INF/MANIFEST.MF
index 9828d8607b5..1c459eacd09 100644
--- a/kura/org.eclipse.kura.rest.wire.provider/META-INF/MANIFEST.MF
+++ b/kura/org.eclipse.kura.rest.wire.provider/META-INF/MANIFEST.MF
@@ -24,7 +24,7 @@ Import-Package: com.google.gson;version="2.7.0",
org.eclipse.kura.internal.wire.asset;version="[1.0,2.0)",
org.eclipse.kura.marshalling;version="[1.0,2.0)",
org.eclipse.kura.request.handler.jaxrs;version="[1.0,2.0)",
- org.eclipse.kura.rest.configuration.api;version="[1.0,2.0)",
+ org.eclipse.kura.rest.configuration.api;version="[1.1,2.0)",
org.eclipse.kura.util.service;version="[1.0,2.0)",
org.eclipse.kura.wire;version="[2.0,3.0)",
org.eclipse.kura.wire.graph;version="[1.0,2.0)",
diff --git a/kura/org.eclipse.kura.rest.wire.provider/src/main/java/org/eclipse/kura/internal/rest/wire/WireRestService.java b/kura/org.eclipse.kura.rest.wire.provider/src/main/java/org/eclipse/kura/internal/rest/wire/WireRestService.java
index bcb127ad286..674d883a00e 100644
--- a/kura/org.eclipse.kura.rest.wire.provider/src/main/java/org/eclipse/kura/internal/rest/wire/WireRestService.java
+++ b/kura/org.eclipse.kura.rest.wire.provider/src/main/java/org/eclipse/kura/internal/rest/wire/WireRestService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2022 Eurotech and/or its affiliates and others
+ * Copyright (c) 2023 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -362,7 +362,7 @@ public ComponentConfigurationList getWireConfigsByPid(final PidSet pidSet) {
}
}
- return DTOUtil.toComponentConfigurationList(result, cryptoService, true);
+ return DTOUtil.toComponentConfigurationList(result, cryptoService, false).replacePasswordsWithPlaceholder();
} catch (final Exception e) {
throw DefaultExceptionHandler.toWebApplicationException(e);
diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java
index b7ca7a9f8e3..e175415585d 100644
--- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java
+++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java
@@ -145,12 +145,16 @@ interface AssetConfigurationUiBinder extends UiBinder {
@@ -680,6 +686,12 @@ private void uploadAndApply() {
this.appendCheckField.setName("doReplace");
this.appendCheckField.setValue("");
+ this.emptyStringCheck.setName("emptyStringCheck");
+ this.emptyStringCheck.setValue(false);
+ this.emptyStringCheckField.setID("doEmptyStringConversion");
+ this.emptyStringCheckField.setName("doEmptyStringConversion");
+ this.emptyStringCheckField.setValue("");
+
}
@Override
diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.ui.xml b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.ui.xml
index dccdb4f9970..c886c775bbc 100644
--- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.ui.xml
+++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.ui.xml
@@ -104,6 +104,8 @@
File
+
+
@@ -115,6 +117,7 @@
+
diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/servlet/FileServlet.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/servlet/FileServlet.java
index 4713e6343a9..8c1ee7c0dec 100644
--- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/servlet/FileServlet.java
+++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/servlet/FileServlet.java
@@ -450,9 +450,10 @@ private void doPostAsset(HttpServletRequest req, HttpServletResponse resp) throw
String csvString = new String(data, StandardCharsets.UTF_8);
String assetPid = formFields.get("assetPid");
String driverPid = formFields.get("driverPid");
+ Boolean nullValueAsEmptyString = Boolean.parseBoolean(formFields.get("doEmptyStringConversion"));
List parametersFromCsv = AssetConfigValidator.get().validateCsv(csvString, driverPid,
- errors);
+ errors, nullValueAsEmptyString);
final GwtConfigComponent config = new GwtConfigComponent();
config.setParameters(parametersFromCsv);
diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/util/AssetConfigValidator.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/util/AssetConfigValidator.java
index 87028f9e824..478483d9483 100644
--- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/util/AssetConfigValidator.java
+++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/util/AssetConfigValidator.java
@@ -34,6 +34,7 @@
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
import org.eclipse.kura.configuration.metatype.Option;
+import org.eclipse.kura.configuration.metatype.Scalar;
import org.eclipse.kura.core.configuration.metatype.Tad;
import org.eclipse.kura.driver.Driver;
import org.eclipse.kura.internal.wire.asset.WireAssetChannelDescriptor;
@@ -87,10 +88,10 @@ private class LineScanner {
private final List adsByIndex;
private final List defaultValues;
- public LineScanner(final List fullChannelMetatype, final List columnHeaders)
- throws ValidationException {
+ public LineScanner(final List fullChannelMetatype, final List columnHeaders,
+ Boolean nullValueAsEmptyString) throws ValidationException {
this.adsByIndex = probeAdsByIndex(fullChannelMetatype, columnHeaders);
- this.defaultValues = probeDefaultValues(fullChannelMetatype, this.adsByIndex);
+ this.defaultValues = probeDefaultValues(fullChannelMetatype, this.adsByIndex, nullValueAsEmptyString);
}
private Optional findLast(final Collection collection, final Predicate predicate) {
@@ -169,7 +170,7 @@ private List probeAdsByIndex(final List fullChannelMetatype, final Lis
}
private List probeDefaultValues(final List fullChannelMetatype,
- final List boundAds) {
+ final List boundAds, Boolean nullValueAsEmptyString) {
final List missing = fullChannelMetatype.stream()
.filter(c -> boundAds.stream().noneMatch(b -> b.getId().equals(c.getId())))
.collect(Collectors.toList());
@@ -183,7 +184,8 @@ private List probeDefaultValues(final List fullChannelM
}
try {
- final Object defaultValue = validate(ad, ad.getDefault(), new ArrayList<>(), 0);
+ final Object defaultValue = validate(ad, ad.getDefault(), new ArrayList<>(), 0,
+ nullValueAsEmptyString);
result.add(GwtServerUtil.toGwtConfigParameter(ad, defaultValue));
} catch (final Exception e) {
logger.warn("Ad default value is probably not valid", e);
@@ -194,7 +196,7 @@ private List probeDefaultValues(final List fullChannelM
}
public String scan(final CSVRecord line, final Consumer parameterConsumer,
- List errors) {
+ List errors, Boolean nullValueAsEmptyString) {
String channelName = "";
boolean errorInChannel = false;
if (line.size() != adsByIndex.size()) {
@@ -212,7 +214,7 @@ public String scan(final CSVRecord line, final Consumer para
channelName = token;
}
final Tad ad = adsByIndex.get(i);
- final Object value = validate(ad, token, errors, lineNumber);
+ final Object value = validate(ad, token, errors, lineNumber, nullValueAsEmptyString);
parameterConsumer.accept(GwtServerUtil.toGwtConfigParameter(ad, value));
} catch (Exception ex) {
@@ -230,8 +232,8 @@ public String scan(final CSVRecord line, final Consumer para
}
}
- public List validateCsv(String csv, String driverPid, List errors)
- throws ServletException {
+ public List validateCsv(String csv, String driverPid, List errors,
+ Boolean nullValueAsEmptyString) throws ServletException {
try (CSVParser parser = CSVParser.parse(csv, CSVFormat.RFC4180)) {
errors.clear();
@@ -249,11 +251,11 @@ public List validateCsv(String csv, String driverPid, List header = StreamSupport.stream(lines.remove(0).spliterator(), false)
.collect(Collectors.toList());
- final LineScanner scanner = new LineScanner(fullChannelMetatype, header);
+ final LineScanner scanner = new LineScanner(fullChannelMetatype, header, nullValueAsEmptyString);
lines.forEach(record -> {
final List params = new ArrayList<>();
- String channelName = scanner.scan(record, params::add, errors);
+ String channelName = scanner.scan(record, params::add, errors, nullValueAsEmptyString);
if (!channelName.isEmpty() && !channels.contains(channelName)) {
channels.add(channelName);
for (final GwtConfigParameter param : params) {
@@ -301,16 +303,18 @@ private String errorString(int lineNumber, Tad field, String value) {
}
// Validates all the entered values
- protected Object validate(Tad field, String value, List errors, int lineNumber) throws ValidationException {
+ protected Object validate(Tad field, String value, List errors, int lineNumber,
+ Boolean nullValueAsEmptyString) throws ValidationException {
String trimmedValue = value.trim();
final boolean isEmpty = trimmedValue.isEmpty();
+ final boolean convertNullToEmptyString = nullToEmptyStringValueManagement(field, nullValueAsEmptyString);
if (field.isRequired() && isEmpty) {
throw new ValidationException();
}
- if (!isEmpty) {
+ if (validateTrimmedValue(isEmpty, convertNullToEmptyString)) {
// Validate "Options" field first. Data type will be taken care of next.
if (!field.getOption().isEmpty()) {
boolean foundEqual = false;
@@ -361,6 +365,20 @@ protected Object validate(Tad field, String value, List errors, int line
return null;
}
+ private boolean nullToEmptyStringValueManagement(Tad field, Boolean nullValueAsEmptyString) {
+
+ boolean returnValue = false;
+
+ if (nullValueAsEmptyString.booleanValue()) {
+ returnValue = field.getType().equals(Scalar.STRING);
+ }
+ return returnValue;
+ }
+
+ private boolean validateTrimmedValue(boolean isEmpty, boolean convertNullToEmptyString) {
+ return !isEmpty || convertNullToEmptyString;
+ }
+
protected interface ValidationErrorConsumer {
public void addError(String errorMsg);
diff --git a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties
index a8c22cd99b7..bb5d62316cc 100644
--- a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties
+++ b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties
@@ -777,8 +777,10 @@ wiresDownloadChannels=Download Channels
wiresUploadChannels=Upload Channels
wiresNewChannel=New Channel
wiresDeleteChannel=Delete Channel
+wiresEmptyStringCheck=Force import empty string policy.
+wiresEmptyStringCheckHelpText=If checked, empty values contained in the csv will be parsed as empty strings, for all those fields whose type is .
wiresAppendChannelsCheck=Replace current channels.
-wiresAppendChannelsHelpText=If checked, channels will be replaced by the imported ones. Otherwise, existing Asset configuration will be merged with the imported one, parameters values of imported channels will override the existing ones. The change will not be applied until Asset configuration is saved.
+wiresAppendChannelsHelpText=If checked, all typed channel fields that have an empty value in the input csv will be parsed as empty strings.
wiresEmitters=Emitters
wiresReceivers=Receivers
diff --git a/kura/test/org.eclipse.kura.core.cloud.test/src/test/java/org/eclipse/kura/core/cloud/BirthMessagesTest.java b/kura/test/org.eclipse.kura.core.cloud.test/src/test/java/org/eclipse/kura/core/cloud/BirthMessagesTest.java
index 9e420278f41..5a0ab97179d 100644
--- a/kura/test/org.eclipse.kura.core.cloud.test/src/test/java/org/eclipse/kura/core/cloud/BirthMessagesTest.java
+++ b/kura/test/org.eclipse.kura.core.cloud.test/src/test/java/org/eclipse/kura/core/cloud/BirthMessagesTest.java
@@ -123,7 +123,7 @@ public void shouldPublishImmediatelyWhenDeactivate() throws KuraException {
whenDeactivate();
thenNoExceptionOccurred();
- thenBirthIsPublishedImmediately(BIRTH_TOPIC_PREFIX + CloudServiceOptions.getTopicDisconnectSuffix());
+ thenDisconnectIsPublishedImmediately(BIRTH_TOPIC_PREFIX + CloudServiceOptions.getTopicDisconnectSuffix());
}
@Test
@@ -180,7 +180,7 @@ public void shouldPublishImmediatelyOnDisconnecting() throws KuraException {
whenOnDisconnecting();
thenNoExceptionOccurred();
- thenBirthIsPublishedImmediately(BIRTH_TOPIC_PREFIX + CloudServiceOptions.getTopicDisconnectSuffix());
+ thenDisconnectIsPublishedImmediately(BIRTH_TOPIC_PREFIX + CloudServiceOptions.getTopicDisconnectSuffix());
}
@Test
@@ -394,11 +394,16 @@ private void thenNoBirthIsPublished() throws KuraStoreException {
private void thenBirthIsPublishedAfter(long delayMillis, String expectedTopic) throws KuraException {
verify(this.dataService, after(delayMillis).never()).publish(eq(expectedTopic), any(), eq(0), eq(false),
eq(0));
- verify(this.dataService, after(delayMillis + SLACK_DELAY).times(1)).publish(eq(expectedTopic), any(), eq(0),
+ verify(this.dataService, after(delayMillis + SLACK_DELAY).times(1)).publish(eq(expectedTopic), any(), eq(1),
eq(false), eq(0));
}
private void thenBirthIsPublishedImmediately(String expectedTopic) throws KuraException {
+ verify(this.dataService, timeout(SLACK_DELAY).times(1)).publish(eq(expectedTopic), any(), eq(1), eq(false),
+ eq(0));
+ }
+
+ private void thenDisconnectIsPublishedImmediately(String expectedTopic) throws KuraException {
verify(this.dataService, timeout(SLACK_DELAY).times(1)).publish(eq(expectedTopic), any(), eq(0), eq(false),
eq(0));
}
diff --git a/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImplTest.java b/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImplTest.java
index 51ef3cf28a3..2a70e3a3b8b 100644
--- a/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImplTest.java
+++ b/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImplTest.java
@@ -17,13 +17,19 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import java.security.PrivateKey;
+import java.security.KeyStore.PrivateKeyEntry;
+import java.security.KeyStore.TrustedCertificateEntry;
+import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -33,6 +39,7 @@
import org.eclipse.kura.KuraException;
import org.eclipse.kura.configuration.ComponentConfiguration;
+import org.eclipse.kura.configuration.ConfigurationService;
import org.eclipse.kura.configuration.metatype.AD;
import org.eclipse.kura.configuration.metatype.OCD;
import org.eclipse.kura.core.linux.executor.LinuxExitStatus;
@@ -48,6 +55,7 @@
import org.eclipse.kura.nm.NMDbusConnector;
import org.eclipse.kura.nm.NetworkProperties;
import org.eclipse.kura.nm.configuration.writer.DhcpServerConfigWriter;
+import org.eclipse.kura.security.keystore.KeystoreService;
import org.junit.Test;
import org.mockito.Mockito;
import org.osgi.framework.BundleContext;
@@ -67,6 +75,7 @@ public class NMConfigurationServiceImplTest {
private AtomicBoolean posted;
private Event event;
private final Set dhcpConfigWriterInterfaces = new HashSet<>();
+ private KeystoreService keystoreService = mock(KeystoreService.class);
@Test
public void shouldPostEventAfterActivationTest() throws InterruptedException, KuraException {
@@ -152,6 +161,18 @@ public void shouldStartConfigWriterIfEthernetInterfaceIsEnabledAndInDhcpServerMo
thenDhcpConfigWriterIsCreatedForInterfaces("eno1");
}
+ @Test
+ public void shouldStartConfigWriterIfEnterpriseWifi() throws KuraException {
+ givenNetworkConfigurationService();
+ givenEnterpriseWifiKeystore();
+ givenFullProperties();
+ givenWifiEnterprisePropertiesForInterfaceWlp2s0();
+
+ whenServiceIsActivated();
+
+ thenDhcpConfigWriterIsCreatedForInterfaces("wlp2s0");
+ }
+
@Test
public void shouldStartConfigWriterIfWifiInterfaceIsEnabledAndInDhcpServerMode() throws KuraException {
givenNetworkConfigurationService();
@@ -369,6 +390,92 @@ private void givenFullProperties() {
this.properties.put("net.interface.1-4.config.pdpType", "IP");
}
+ private void givenWifiEnterprisePropertiesForInterfaceWlp2s0() {
+ this.properties.put("net.interfaces", "enp5s0,lo,eno1,wlp1s0,wlp2s0,1-4");
+
+ this.properties.put("net.interface.wlp2s0.type", "WIFI");
+ this.properties.put("net.interface.wlp2s0.config.ip4.gateway", "");
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.driver", "nl80211");
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.ssid", "testssid");
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.groupCiphers", "CCMP_TKIP");
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.bgscan", "");
+ this.properties.put("net.interface.wlp2s0.config.dhcpServer4.rangeStart", "172.16.1.100");
+ this.properties.put("net.interface.wlp2s0.config.dhcpServer4.maxLeaseTime", 7200);
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.pingAccessPoint", false);
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.channel", "1");
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.passphrase", "qwerty=");
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.groupCiphers", "CCMP_TKIP");
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.bgscan", "");
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.passphrase", "");
+ this.properties.put("net.interface.wlp2s0.config.dhcpServer4.defaultLeaseTime", 7200);
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.ssid", "kura_gateway_0");
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.securityType", "SECURITY_WPA2");
+ this.properties.put("net.interface.wlp2s0.config.dhcpServer4.rangeEnd", "172.16.1.110");
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.ignoreSSID", false);
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.mode", "MASTER");
+ this.properties.put("net.interface.wlp2s0.config.dhcpServer4.prefix", 24);
+ this.properties.put("net.interface.wlp2s0.config.wifi.mode", "INFRA");
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.mode", "INFRA");
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.pingAccessPoint", false);
+ this.properties.put("net.interface.wlp2s0.config.nat.enabled", false);
+ this.properties.put("net.interface.wlp2s0.config.ip4.status", "netIPv4StatusEnabledWAN");
+ this.properties.put("net.interface.wlp2s0.config.ip6.status", "netIPv6StatusDisabled");
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.channel", "1");
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.radioMode", "RADIO_MODE_80211g");
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.driver", "nl80211");
+ this.properties.put("net.interface.wlp2s0.config.dhcpServer4.enabled", true);
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.ignoreSSID", false);
+ this.properties.put("net.interface.wlp2s0.config.ip4.address", "172.16.1.1");
+ this.properties.put("net.interface.wlp2s0.config.ip6.dnsServers", "");
+ this.properties.put("net.interface.wlp2s0.config.wifi.master.pairwiseCiphers", "CCMP");
+ this.properties.put("net.interface.wlp2s0.config.dhcpClient6.enabled", false);
+ this.properties.put("net.interface.wlp2s0.config.dhcpServer4.passDns", false);
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.securityType", "SECURITY_WPA2_WPA3_ENTERPRISE");
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.radioMode", "RADIO_MODE_80211b");
+ this.properties.put("net.interface.wlp2s0.config.ip4.dnsServers", "");
+ this.properties.put("net.interface.wlp2s0.config.wifi.infra.pairwiseCiphers", "CCMP_TKIP");
+ this.properties.put("net.interface.wlp2s0.config.ip4.prefix", 24);
+ this.properties.put("net.interface.wlp2s0.config.802-1x.eap", "Kura8021xEapTls");
+ this.properties.put("net.interface.wlp2s0.config.802-1x.keystore.pid", "WifiKeystore");
+ this.properties.put("net.interface.wlp2s0.config.802-1x.ca-cert-name", "caCert");
+ this.properties.put("net.interface.wlp2s0.config.802-1x.client-cert-name", "privatekey");
+ this.properties.put("net.interface.wlp2s0.config.802-1x.private-key-name", "privatekey");
+ }
+
+ private void givenEnterpriseWifiKeystore() {
+
+ try {
+ TrustedCertificateEntry trustedCertificateEntry = mock(TrustedCertificateEntry.class);
+ Certificate certificate = mock(Certificate.class);
+
+ PrivateKeyEntry privateKeyEntry = mock(PrivateKeyEntry.class);
+ Certificate privateKeyCertificate = mock(Certificate.class);
+ PrivateKey privateKey = mock(PrivateKey.class);
+
+ when(trustedCertificateEntry.getTrustedCertificate()).thenReturn(certificate);
+ when(privateKeyEntry.getCertificate()).thenReturn(privateKeyCertificate);
+ when(privateKeyEntry.getPrivateKey()).thenReturn(privateKey);
+
+ when(certificate.getEncoded()).thenReturn("ca-certificate".getBytes());
+ when(privateKeyCertificate.getEncoded()).thenReturn("certificate-key".getBytes());
+ when(privateKey.getEncoded()).thenReturn("privatekey".getBytes());
+
+ this.keystoreService = mock(KeystoreService.class);
+
+ when(this.keystoreService.getEntry("caCert")).thenReturn(trustedCertificateEntry);
+ when(this.keystoreService.getEntry("privatekey")).thenReturn(privateKeyEntry);
+
+ Map propertiesMap = new HashMap<>();
+ propertiesMap.put(ConfigurationService.KURA_SERVICE_PID, "WifiKeystore");
+
+ this.networkConfigurationService.setKeystoreService(keystoreService, propertiesMap);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+
+ }
+
private void givenPropertiesWithPppInterfaceNames() {
this.properties.clear();
this.properties.put("net.interfaces", "enp5s0,lo,eno1,wlp1s0,ppp3");
@@ -792,6 +899,55 @@ private void thenComponentDefinitionHasCorrectProperties() {
assertEquals(40, adsConfigured);
}
+ private void thenComponentDefinitionHasCorrectEnterpriseProperties() {
+ int adsConfigured = 0;
+ for (AD ad : this.ads) {
+
+ if ("net.interfaces".equals(ad.getId())) {
+ assertEquals("net.interfaces", ad.getName());
+ assertEquals("STRING", ad.getType().name());
+ assertTrue(ad.isRequired());
+ adsConfigured++;
+ }
+
+ if ("net.interface.wlp2s0.config.802-1x.eap".equals(ad.getId())) {
+ assertEquals("net.interface.wlp2s0.config.802-1x.eap", ad.getName());
+ assertEquals("STRING", ad.getType().name());
+ assertFalse(ad.isRequired());
+ adsConfigured++;
+ }
+
+ if ("net.interface.wlp2s0.config.802-1x.keystore.pid".equals(ad.getId())) {
+ assertEquals("net.interface.wlp2s0.config.802-1x.keystore.pid", ad.getName());
+ assertEquals("STRING", ad.getType().name());
+ assertFalse(ad.isRequired());
+ adsConfigured++;
+ }
+
+ if ("net.interface.wlp2s0.config.802-1x.ca-cert-name".equals(ad.getId())) {
+ assertEquals("net.interface.wlp2s0.config.802-1x.ca-cert-name", ad.getName());
+ assertEquals("STRING", ad.getType().name());
+ assertFalse(ad.isRequired());
+ adsConfigured++;
+ }
+
+ if ("net.interface.wlp2s0.config.802-1x.client-cert-name".equals(ad.getId())) {
+ assertEquals("net.interface.wlp2s0.config.802-1x.client-cert-name", ad.getName());
+ assertEquals("STRING", ad.getType().name());
+ assertFalse(ad.isRequired());
+ adsConfigured++;
+ }
+
+ if ("net.interface.wlp2s0.config.802-1x.private-key-name".equals(ad.getId())) {
+ assertEquals("net.interface.wlp2s0.config.802-1x.private-key-name", ad.getName());
+ assertEquals("STRING", ad.getType().name());
+ assertFalse(ad.isRequired());
+ adsConfigured++;
+ }
+ }
+ assertEquals(5, adsConfigured);
+ }
+
private void thenPropertiesNumberIsCorrect() {
assertEquals(33, this.event.getPropertyNames().length);
}
diff --git a/kura/test/org.eclipse.kura.rest.configuration.provider.test/src/main/java/org/eclipse/kura/rest/configuration/provider/test/ConfigurationRestServiceTest.java b/kura/test/org.eclipse.kura.rest.configuration.provider.test/src/main/java/org/eclipse/kura/rest/configuration/provider/test/ConfigurationRestServiceTest.java
index 4df3d30f39b..958d5f6c572 100644
--- a/kura/test/org.eclipse.kura.rest.configuration.provider.test/src/main/java/org/eclipse/kura/rest/configuration/provider/test/ConfigurationRestServiceTest.java
+++ b/kura/test/org.eclipse.kura.rest.configuration.provider.test/src/main/java/org/eclipse/kura/rest/configuration/provider/test/ConfigurationRestServiceTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2021, 2022 Eurotech and/or its affiliates and others
+ * Copyright (c) 2021, 2023 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -80,7 +80,7 @@
@RunWith(Parameterized.class)
public class ConfigurationRestServiceTest extends AbstractRequestHandlerTest {
- private char[] EncryptedPassword;
+ private char[] encryptedPassword;
@Test
public void shouldSupportGetSnapshots() throws KuraException {
@@ -270,16 +270,45 @@ public void testGetLongProperty() throws KuraException {
}
@Test
- public void testGetPasswordProperty() throws KuraException {
- this.EncryptedPassword = this.cryptoService.encryptAes("foobar".toCharArray());
+ public void testReturnPlaceholderInsteadOfEncryptedPassword() throws KuraException {
+ givenEncryptedPassword("foobar");
givenATestConfigurationPropertyWithAdTypeAndValue(Scalar.PASSWORD,
- new Password(this.EncryptedPassword));
+ new Password(this.encryptedPassword));
whenRequestIsPerformed(new MethodSpec("GET"), "/configurableComponents/configurations");
thenRequestSucceeds();
thenTestPropertyTypeIs(Json.value("PASSWORD"));
- thenTestPropertyValueIs(Json.value(new String(this.EncryptedPassword)));
+ thenTestPropertyValueIs(Json.value("placeholder"));
+ }
+
+ @Test
+ public void testReturnNoValueForMissingPasswordProperty() throws KuraException {
+ givenEncryptedPassword("foobar");
+ givenATestConfigurationPropertyWithAdTypeAndValue(Scalar.PASSWORD,
+ null);
+
+ whenRequestIsPerformed(new MethodSpec("GET"), "/configurableComponents/configurations");
+
+ thenRequestSucceeds();
+ thenTestPropertyIsMissing();
+ }
+
+ @Test
+ public void testGetSnapshotReturnsUnencryptedPassword() throws KuraException {
+ givenATestConfigurationPropertyWithAdTypeAndValue(Scalar.PASSWORD,
+ new Password("foobar".toCharArray()));
+
+ whenRequestIsPerformed(new MethodSpec("POST"), "/snapshots/byId",
+ "{\"id\":1}");
+
+ thenRequestSucceeds();
+ thenTestPropertyTypeIs(Json.value("PASSWORD"));
+ thenTestPropertyValueIs(Json.value("foobar"));
+ }
+
+ private void givenEncryptedPassword(final String password) throws KuraException {
+ this.encryptedPassword = this.cryptoService.encryptAes(password.toCharArray());
}
@Test
@@ -394,16 +423,16 @@ public void testGetLongArrayProperty() throws KuraException {
@Test
public void testGetPasswordArrayProperty() throws KuraException {
- this.EncryptedPassword = this.cryptoService.encryptAes("foobar".toCharArray());
+ givenEncryptedPassword("foobar");
givenATestConfigurationPropertyWithAdTypeAndValue(Scalar.PASSWORD,
- new Password[] { new Password(this.EncryptedPassword) });
+ new Password[] { new Password(this.encryptedPassword) });
whenRequestIsPerformed(new MethodSpec("GET"), "/configurableComponents/configurations");
thenRequestSucceeds();
thenTestPropertyTypeIs(Json.value("PASSWORD"));
- thenTestPropertyValueIs(Json.array(new String(this.EncryptedPassword)));
+ thenTestPropertyValueIs(Json.array("placeholder"));
}
@Test
@@ -1036,7 +1065,7 @@ public void testADOption() throws KuraException {
@Test
public void testGetConfigurationByPid() throws KuraException {
- this.EncryptedPassword = this.cryptoService.encryptAes("foobar".toCharArray());
+ givenEncryptedPassword("foobar");
givenConfigurations(configurationBuilder("foo") //
.withDefinition( //
ocdBuilder("foo") //
@@ -1046,7 +1075,7 @@ public void testGetConfigurationByPid() throws KuraException {
.build()) //
.build()) //
.withConfigurationProperties(
- singletonMap("testProp", new Password[] { new Password(this.EncryptedPassword) }))
+ singletonMap("testProp", new Password[] { new Password(this.encryptedPassword) }))
.build());
whenRequestIsPerformed(new MethodSpec("POST"), "/configurableComponents/configurations/byPid",
@@ -1058,14 +1087,14 @@ public void testGetConfigurationByPid() throws KuraException {
+ "{\"label\":\"pass\",\"value\":\"baz\"}],\"id\":\"fooAdName\",\"type\":\"PASSWORD\","
+ "\"cardinality\":0,\"isRequired\":false}],\"id\":\"foo\"},"
+ "\"properties\":{\"testProp\":{\"value\":[\""
- + new String(this.EncryptedPassword)
+ + "placeholder"
+ "\"],\"type\":\"PASSWORD\"}}}"),
self().field("configs").arrayItem(0));
}
@Test
public void testGetConfigurationByPidDefault() throws KuraException {
- this.EncryptedPassword = this.cryptoService.encryptAes("foobar".toCharArray());
+ givenEncryptedPassword("foobar");
givenConfigurations(configurationBuilder("foo") //
.withDefinition( //
ocdBuilder("foo") //
@@ -1076,7 +1105,7 @@ public void testGetConfigurationByPidDefault() throws KuraException {
.build()) //
.build()) //
.withConfigurationProperties(
- singletonMap("testProp", new Password[] { new Password(this.EncryptedPassword) }))
+ singletonMap("testProp", new Password[] { new Password(this.encryptedPassword) }))
.build());
whenRequestIsPerformed(new MethodSpec("POST"), "/configurableComponents/configurations/byPid/_default",
@@ -1088,7 +1117,7 @@ public void testGetConfigurationByPidDefault() throws KuraException {
+ "{\"label\":\"pass\",\"value\":\"baz\"}],\"id\":\"fooAdName\",\"type\":\"STRING\","
+ "\"cardinality\":0,\"defaultValue\":\"default\",\"isRequired\":false}]"
+ ",\"id\":\"foo\"},\"properties\":{\"testProp\":{\"value\":[\""
- + new String(this.EncryptedPassword)
+ + new String(this.encryptedPassword)
+ "\"],\"type\":\"PASSWORD\"}}}"),
self().field("configs").arrayItem(0));
}
@@ -1405,6 +1434,9 @@ private void givenConfigurations(final ComponentConfiguration... configurations)
final String pid = i.getArgument(0, String.class);
return byPid.get(pid);
});
+
+ Mockito.when(configurationService.getSnapshot(Mockito.anyLong()))
+ .thenReturn(byPid.values().stream().collect(Collectors.toList()));
}
private void givenATestConfigurationPropertyWithAdTypeAndValue(final Scalar type, final Object value)