+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.server.config.ws;
-
-import com.google.common.base.Splitter;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Ordering;
-import com.google.common.collect.TreeMultimap;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-import org.sonar.api.config.PropertyDefinition;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.core.permission.GlobalPermissions;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.component.ComponentDto;
-import org.sonar.db.property.PropertyDto;
-import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.user.UserSession;
-import org.sonar.server.ws.WsAction;
-
-import static org.apache.commons.lang.StringUtils.isEmpty;
-import static org.sonar.api.PropertyType.PROPERTY_SET;
-import static org.sonar.api.server.ws.RailsHandler.PARAM_FORMAT;
-import static org.sonar.api.server.ws.RailsHandler.addJsonOnlyFormatParam;
-import static org.sonar.api.web.UserRole.ADMIN;
-import static org.sonar.server.setting.ws.SettingsPermissionPredicates.DOT_LICENSE;
-import static org.sonar.server.setting.ws.SettingsPermissionPredicates.DOT_SECURED;
-import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
-
-public class IndexAction implements WsAction {
-
- private static final Splitter DOT_SPLITTER = Splitter.on(".").omitEmptyStrings();
- private static final Splitter COMMA_SPLITTER = Splitter.on(",");
- private static final String COMMA_ENCODED_VALUE = "%2C";
-
- public static final String PARAM_KEY = "key";
- private static final String PARAM_COMPONENT = "resource";
-
- private final DbClient dbClient;
- private final ComponentFinder componentFinder;
- private final UserSession userSession;
- private final PropertyDefinitions propertyDefinitions;
-
- public IndexAction(DbClient dbClient, ComponentFinder componentFinder, UserSession userSession, PropertyDefinitions propertyDefinitions) {
- this.dbClient = dbClient;
- this.componentFinder = componentFinder;
- this.userSession = userSession;
- this.propertyDefinitions = propertyDefinitions;
- }
-
- @Override
- public void define(WebService.NewController context) {
- WebService.NewAction action = context.createAction("index")
- .setDescription("This web service is deprecated, please use api/settings/values instead.")
- .setDeprecatedSince("6.3")
- .setResponseExample(getClass().getResource("index-example.json"))
- .setSince("2.6")
- .setHandler(this);
- action.createParam(PARAM_KEY)
- .setDescription("Setting key")
- .setExampleValue("sonar.technicalDebt.hoursInDay");
- action.createParam(PARAM_COMPONENT)
- .setDescription("Component key or database id")
- .setExampleValue(KEY_PROJECT_EXAMPLE_001);
- addJsonOnlyFormatParam(action);
- }
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- request.param(PARAM_FORMAT);
- JsonWriter json = response.newJsonWriter();
- json.beginArray();
- doHandle(json, request);
- json.endArray();
- json.close();
- }
-
- private void doHandle(JsonWriter json, Request request) {
- DbSession dbSession = dbClient.openSession(true);
- try {
- Optional<ComponentDto> component = loadComponent(dbSession, request);
- String key = request.param(PARAM_KEY);
- List<PropertyDto> propertyDtos = loadProperties(dbSession, component, Optional.ofNullable(key));
- new ResponseBuilder(propertyDtos).build(json);
- } finally {
- dbClient.closeSession(dbSession);
- }
- }
-
- private Optional<ComponentDto> loadComponent(DbSession dbSession, Request request) {
- String component = request.param(PARAM_COMPONENT);
- if (component == null) {
- return Optional.empty();
- }
- return Optional.of(loadComponent(dbSession, component));
- }
-
- private ComponentDto loadComponent(DbSession dbSession, String component) {
- try {
- Long componentId = Long.parseLong(component);
- return componentFinder.getById(dbSession, componentId);
- } catch (NumberFormatException e) {
- return componentFinder.getByKey(dbSession, component);
- }
- }
-
- private List<PropertyDto> loadProperties(DbSession dbSession, Optional<ComponentDto> component, Optional<String> key) {
- // List of settings must be kept in the following orders : default -> global -> component
- List<PropertyDto> propertyDtos = new ArrayList<>();
- propertyDtos.addAll(loadDefaultSettings(key));
- propertyDtos.addAll(loadGlobalSettings(dbSession, key));
- component.ifPresent(componentDto -> propertyDtos.addAll(loadComponentSettings(dbSession, key, componentDto).values()));
- return propertyDtos.stream().filter(isVisible(component)).collect(Collectors.toList());
- }
-
- Predicate<PropertyDto> isVisible(Optional<ComponentDto> component) {
- return propertyDto -> !propertyDto.getKey().endsWith(DOT_SECURED)
- || hasAdminPermission(component)
- || (propertyDto.getKey().contains(DOT_LICENSE) && userSession.isLoggedIn());
- }
-
- private boolean hasAdminPermission(Optional<ComponentDto> component) {
- return component.isPresent() ? userSession.hasComponentUuidPermission(ADMIN, component.get().uuid()) : userSession.hasPermission(GlobalPermissions.SYSTEM_ADMIN);
- }
-
- private List<PropertyDto> loadGlobalSettings(DbSession dbSession, Optional<String> key) {
- if (key.isPresent()) {
- return dbClient.propertiesDao().selectGlobalPropertiesByKeys(dbSession, Collections.singleton(key.get()));
- }
- return dbClient.propertiesDao().selectGlobalProperties(dbSession);
- }
-
- /**
- * Return list of propertyDto by component uuid, sorted from project to lowest module
- */
- private Multimap<String, PropertyDto> loadComponentSettings(DbSession dbSession, Optional<String> key, ComponentDto component) {
- List<String> componentUuids = DOT_SPLITTER.splitToList(component.moduleUuidPath());
- List<ComponentDto> componentDtos = dbClient.componentDao().selectByUuids(dbSession, componentUuids);
- Set<Long> componentIds = componentDtos.stream().map(ComponentDto::getId).collect(Collectors.toSet());
- Map<Long, String> uuidsById = componentDtos.stream().collect(Collectors.toMap(ComponentDto::getId, ComponentDto::uuid));
- List<PropertyDto> properties = key.isPresent() ? dbClient.propertiesDao().selectPropertiesByKeysAndComponentIds(dbSession, Collections.singleton(key.get()), componentIds)
- : dbClient.propertiesDao().selectPropertiesByComponentIds(dbSession, componentIds);
-
- Multimap<String, PropertyDto> propertyDtosByUuid = TreeMultimap.create(Ordering.explicit(componentUuids), Ordering.arbitrary());
- for (PropertyDto propertyDto : properties) {
- Long componentId = propertyDto.getResourceId();
- String componentUuid = uuidsById.get(componentId);
- propertyDtosByUuid.put(componentUuid, propertyDto);
- }
- return propertyDtosByUuid;
- }
-
- private List<PropertyDto> loadDefaultSettings(Optional<String> key) {
- return propertyDefinitions.getAll().stream()
- .filter(definition -> !key.isPresent() || key.get().equals(definition.key()))
- .filter(defaultProperty -> !isEmpty(defaultProperty.defaultValue()))
- .map(definition -> new PropertyDto().setKey(definition.key()).setValue(definition.defaultValue()))
- .collect(Collectors.toList());
- }
-
- private class ResponseBuilder {
- private final List<PropertyDto> propertyDtos;
- private final Map<String, Property> propertiesByKey = new HashMap<>();
-
- ResponseBuilder(List<PropertyDto> propertyDtos) {
- this.propertyDtos = propertyDtos;
- }
-
- void build(JsonWriter json) {
- processSettings();
- propertiesByKey.values().forEach(property -> {
- json.beginObject()
- .prop("key", property.key)
- .prop("value", property.value);
- if (!property.values.isEmpty()) {
- json.name("values").beginArray().values(property.values).endArray();
- }
- json.endObject();
- });
- }
-
- private void processSettings() {
- propertyDtos.forEach(setting -> {
- Property property = createProperty(setting.getKey());
- setValue(setting, property);
- });
- }
-
- private Property createProperty(String key) {
- return propertiesByKey.computeIfAbsent(key, k -> new Property(key));
- }
-
- private void setValue(PropertyDto propertyDto, Property property) {
- String value = propertyDto.getValue();
- property.setValue(value);
- PropertyDefinition definition = propertyDefinitions.get(propertyDto.getKey());
- if (definition != null && (definition.multiValues() || definition.type().equals(PROPERTY_SET))) {
- property.setValues(createValues(value));
- }
- }
-
- private List<String> createValues(String value) {
- return COMMA_SPLITTER.splitToList(value).stream().map(v -> v.replace(COMMA_ENCODED_VALUE, ",")).collect(Collectors.toList());
- }
- }
-
- private static class Property {
- private final String key;
- private String value;
- private List<String> values = new ArrayList<>();
-
- public Property(String key) {
- this.key = key;
- }
-
- public Property setValue(String value) {
- this.value = value;
- return this;
- }
-
- public Property setValues(List<String> values) {
- this.values = values;
- return this;
- }
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.config.ws;
-
-import org.sonar.api.server.ws.WebService;
-
-public class PropertiesWs implements WebService {
-
- public static final String CONTROLLER_PROPERTIES = "api/properties";
-
- private final IndexAction indexAction;
-
- public PropertiesWs(IndexAction indexAction) {
- this.indexAction = indexAction;
- }
-
- @Override
- public void define(Context context) {
- NewController controller = context.createController(CONTROLLER_PROPERTIES)
- .setDescription("This web service is deprecated, please use api/settings instead.")
- .setSince("2.6");
- indexAction.define(controller);
- controller.done();
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.server.config.ws;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
import org.sonar.server.component.DefaultRubyComponentService;
import org.sonar.server.component.es.ProjectsEsModule;
import org.sonar.server.component.ws.ComponentsWsModule;
-import org.sonar.server.config.ws.PropertiesWs;
import org.sonar.server.debt.DebtModelBackup;
import org.sonar.server.debt.DebtModelPluginRepository;
import org.sonar.server.debt.DebtModelService;
import org.sonar.server.projectanalysis.ProjectAnalysisModule;
import org.sonar.server.projectlink.ws.ProjectLinksModule;
import org.sonar.server.property.InternalPropertiesImpl;
+import org.sonar.server.property.ws.PropertiesWs;
import org.sonar.server.qualitygate.QualityGateModule;
import org.sonar.server.qualityprofile.QProfileBackuper;
import org.sonar.server.qualityprofile.QProfileComparison;
// Settings
PersistentSettings.class,
PropertiesWs.class,
- org.sonar.server.config.ws.IndexAction.class,
+ org.sonar.server.property.ws.IndexAction.class,
SettingsWsModule.class,
// Licences
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.property.ws;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Ordering;
+import com.google.common.collect.TreeMultimap;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import org.sonar.api.config.PropertyDefinition;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.text.JsonWriter;
+import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.db.component.ComponentDto;
+import org.sonar.db.property.PropertyDto;
+import org.sonar.server.component.ComponentFinder;
+import org.sonar.server.user.UserSession;
+import org.sonar.server.ws.WsAction;
+
+import static org.apache.commons.lang.StringUtils.isEmpty;
+import static org.sonar.api.PropertyType.PROPERTY_SET;
+import static org.sonar.api.server.ws.RailsHandler.PARAM_FORMAT;
+import static org.sonar.api.server.ws.RailsHandler.addJsonOnlyFormatParam;
+import static org.sonar.api.web.UserRole.ADMIN;
+import static org.sonar.server.setting.ws.SettingsPermissionPredicates.DOT_LICENSE;
+import static org.sonar.server.setting.ws.SettingsPermissionPredicates.DOT_SECURED;
+import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
+
+public class IndexAction implements WsAction {
+
+ private static final Splitter DOT_SPLITTER = Splitter.on(".").omitEmptyStrings();
+ private static final Splitter COMMA_SPLITTER = Splitter.on(",");
+ private static final String COMMA_ENCODED_VALUE = "%2C";
+
+ public static final String PARAM_KEY = "key";
+ private static final String PARAM_COMPONENT = "resource";
+
+ private final DbClient dbClient;
+ private final ComponentFinder componentFinder;
+ private final UserSession userSession;
+ private final PropertyDefinitions propertyDefinitions;
+
+ public IndexAction(DbClient dbClient, ComponentFinder componentFinder, UserSession userSession, PropertyDefinitions propertyDefinitions) {
+ this.dbClient = dbClient;
+ this.componentFinder = componentFinder;
+ this.userSession = userSession;
+ this.propertyDefinitions = propertyDefinitions;
+ }
+
+ @Override
+ public void define(WebService.NewController context) {
+ WebService.NewAction action = context.createAction("index")
+ .setDescription("This web service is deprecated, please use api/settings/values instead.")
+ .setDeprecatedSince("6.3")
+ .setResponseExample(getClass().getResource("index-example.json"))
+ .setSince("2.6")
+ .setHandler(this);
+ action.createParam(PARAM_KEY)
+ .setDescription("Setting key")
+ .setExampleValue("sonar.technicalDebt.hoursInDay");
+ action.createParam(PARAM_COMPONENT)
+ .setDescription("Component key or database id")
+ .setExampleValue(KEY_PROJECT_EXAMPLE_001);
+ addJsonOnlyFormatParam(action);
+ }
+
+ @Override
+ public void handle(Request request, Response response) throws Exception {
+ request.param(PARAM_FORMAT);
+ JsonWriter json = response.newJsonWriter();
+ json.beginArray();
+ doHandle(json, request);
+ json.endArray();
+ json.close();
+ }
+
+ private void doHandle(JsonWriter json, Request request) {
+ DbSession dbSession = dbClient.openSession(true);
+ try {
+ Optional<ComponentDto> component = loadComponent(dbSession, request);
+ String key = request.param(PARAM_KEY);
+ List<PropertyDto> propertyDtos = loadProperties(dbSession, component, Optional.ofNullable(key));
+ new ResponseBuilder(propertyDtos).build(json);
+ } finally {
+ dbClient.closeSession(dbSession);
+ }
+ }
+
+ private Optional<ComponentDto> loadComponent(DbSession dbSession, Request request) {
+ String component = request.param(PARAM_COMPONENT);
+ if (component == null) {
+ return Optional.empty();
+ }
+ return Optional.of(loadComponent(dbSession, component));
+ }
+
+ private ComponentDto loadComponent(DbSession dbSession, String component) {
+ try {
+ Long componentId = Long.parseLong(component);
+ return componentFinder.getById(dbSession, componentId);
+ } catch (NumberFormatException e) {
+ return componentFinder.getByKey(dbSession, component);
+ }
+ }
+
+ private List<PropertyDto> loadProperties(DbSession dbSession, Optional<ComponentDto> component, Optional<String> key) {
+ // List of settings must be kept in the following orders : default -> global -> component
+ List<PropertyDto> propertyDtos = new ArrayList<>();
+ propertyDtos.addAll(loadDefaultSettings(key));
+ propertyDtos.addAll(loadGlobalSettings(dbSession, key));
+ component.ifPresent(componentDto -> propertyDtos.addAll(loadComponentSettings(dbSession, key, componentDto).values()));
+ return propertyDtos.stream().filter(isVisible(component)).collect(Collectors.toList());
+ }
+
+ Predicate<PropertyDto> isVisible(Optional<ComponentDto> component) {
+ return propertyDto -> !propertyDto.getKey().endsWith(DOT_SECURED)
+ || hasAdminPermission(component)
+ || (propertyDto.getKey().contains(DOT_LICENSE) && userSession.isLoggedIn());
+ }
+
+ private boolean hasAdminPermission(Optional<ComponentDto> component) {
+ return component.isPresent() ? userSession.hasComponentUuidPermission(ADMIN, component.get().uuid()) : userSession.hasPermission(GlobalPermissions.SYSTEM_ADMIN);
+ }
+
+ private List<PropertyDto> loadGlobalSettings(DbSession dbSession, Optional<String> key) {
+ if (key.isPresent()) {
+ return dbClient.propertiesDao().selectGlobalPropertiesByKeys(dbSession, Collections.singleton(key.get()));
+ }
+ return dbClient.propertiesDao().selectGlobalProperties(dbSession);
+ }
+
+ /**
+ * Return list of propertyDto by component uuid, sorted from project to lowest module
+ */
+ private Multimap<String, PropertyDto> loadComponentSettings(DbSession dbSession, Optional<String> key, ComponentDto component) {
+ List<String> componentUuids = DOT_SPLITTER.splitToList(component.moduleUuidPath());
+ List<ComponentDto> componentDtos = dbClient.componentDao().selectByUuids(dbSession, componentUuids);
+ Set<Long> componentIds = componentDtos.stream().map(ComponentDto::getId).collect(Collectors.toSet());
+ Map<Long, String> uuidsById = componentDtos.stream().collect(Collectors.toMap(ComponentDto::getId, ComponentDto::uuid));
+ List<PropertyDto> properties = key.isPresent() ? dbClient.propertiesDao().selectPropertiesByKeysAndComponentIds(dbSession, Collections.singleton(key.get()), componentIds)
+ : dbClient.propertiesDao().selectPropertiesByComponentIds(dbSession, componentIds);
+
+ Multimap<String, PropertyDto> propertyDtosByUuid = TreeMultimap.create(Ordering.explicit(componentUuids), Ordering.arbitrary());
+ for (PropertyDto propertyDto : properties) {
+ Long componentId = propertyDto.getResourceId();
+ String componentUuid = uuidsById.get(componentId);
+ propertyDtosByUuid.put(componentUuid, propertyDto);
+ }
+ return propertyDtosByUuid;
+ }
+
+ private List<PropertyDto> loadDefaultSettings(Optional<String> key) {
+ return propertyDefinitions.getAll().stream()
+ .filter(definition -> !key.isPresent() || key.get().equals(definition.key()))
+ .filter(defaultProperty -> !isEmpty(defaultProperty.defaultValue()))
+ .map(definition -> new PropertyDto().setKey(definition.key()).setValue(definition.defaultValue()))
+ .collect(Collectors.toList());
+ }
+
+ private class ResponseBuilder {
+ private final List<PropertyDto> propertyDtos;
+ private final Map<String, Property> propertiesByKey = new HashMap<>();
+
+ ResponseBuilder(List<PropertyDto> propertyDtos) {
+ this.propertyDtos = propertyDtos;
+ }
+
+ void build(JsonWriter json) {
+ processSettings();
+ propertiesByKey.values().forEach(property -> {
+ json.beginObject()
+ .prop("key", property.key)
+ .prop("value", property.value);
+ if (!property.values.isEmpty()) {
+ json.name("values").beginArray().values(property.values).endArray();
+ }
+ json.endObject();
+ });
+ }
+
+ private void processSettings() {
+ propertyDtos.forEach(setting -> {
+ Property property = createProperty(setting.getKey());
+ setValue(setting, property);
+ });
+ }
+
+ private Property createProperty(String key) {
+ return propertiesByKey.computeIfAbsent(key, k -> new Property(key));
+ }
+
+ private void setValue(PropertyDto propertyDto, Property property) {
+ String value = propertyDto.getValue();
+ property.setValue(value);
+ PropertyDefinition definition = propertyDefinitions.get(propertyDto.getKey());
+ if (definition != null && (definition.multiValues() || definition.type().equals(PROPERTY_SET))) {
+ property.setValues(createValues(value));
+ }
+ }
+
+ private List<String> createValues(String value) {
+ return COMMA_SPLITTER.splitToList(value).stream().map(v -> v.replace(COMMA_ENCODED_VALUE, ",")).collect(Collectors.toList());
+ }
+ }
+
+ private static class Property {
+ private final String key;
+ private String value;
+ private List<String> values = new ArrayList<>();
+
+ public Property(String key) {
+ this.key = key;
+ }
+
+ public Property setValue(String value) {
+ this.value = value;
+ return this;
+ }
+
+ public Property setValues(List<String> values) {
+ this.values = values;
+ return this;
+ }
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.property.ws;
+
+import org.sonar.api.server.ws.WebService;
+
+public class PropertiesWs implements WebService {
+
+ public static final String CONTROLLER_PROPERTIES = "api/properties";
+
+ private final IndexAction indexAction;
+
+ public PropertiesWs(IndexAction indexAction) {
+ this.indexAction = indexAction;
+ }
+
+ @Override
+ public void define(Context context) {
+ NewController controller = context.createController(CONTROLLER_PROPERTIES)
+ .setDescription("This web service is deprecated, please use api/settings instead.")
+ .setSince("2.6");
+ indexAction.define(controller);
+ controller.done();
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.property.ws;
+
+import javax.annotation.ParametersAreNonnullByDefault;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.sonar.api.web.ServletFilter;
-import org.sonar.server.config.ws.IndexAction;
+import org.sonar.server.property.ws.IndexAction;
-import static org.sonar.server.config.ws.PropertiesWs.CONTROLLER_PROPERTIES;
+import static org.sonar.server.property.ws.PropertiesWs.CONTROLLER_PROPERTIES;
/**
* This filter is used to execute some deprecated Java WS, that were using REST
import org.sonar.api.server.ws.WebService;
import org.sonar.api.web.ServletFilter;
-import static org.sonar.server.config.ws.PropertiesWs.CONTROLLER_PROPERTIES;
+import static org.sonar.server.property.ws.PropertiesWs.CONTROLLER_PROPERTIES;
/**
* This filter is used to execute Java WS.
+++ /dev/null
-[
- {
- "key": "sonar.test.jira",
- "value": "abc"
- },
- {
- "key": "sonar.autogenerated",
- "value": "val1,val2,val3",
- "values": [
- "val1",
- "val2",
- "val3"
- ]
- },
- {
- "key": "sonar.demo",
- "value": "1,2",
- "values": [
- "1",
- "2"
- ]
- },
- {
- "key": "sonar.demo.1.text",
- "value": "foo"
- },
- {
- "key": "sonar.demo.1.boolean",
- "value": "true"
- },
- {
- "key": "sonar.demo.2.text",
- "value": "bar"
- },
- {
- "key": "sonar.demo.2.boolean",
- "value": "false"
- }
-]
--- /dev/null
+[
+ {
+ "key": "sonar.test.jira",
+ "value": "abc"
+ },
+ {
+ "key": "sonar.autogenerated",
+ "value": "val1,val2,val3",
+ "values": [
+ "val1",
+ "val2",
+ "val3"
+ ]
+ },
+ {
+ "key": "sonar.demo",
+ "value": "1,2",
+ "values": [
+ "1",
+ "2"
+ ]
+ },
+ {
+ "key": "sonar.demo.1.text",
+ "value": "foo"
+ },
+ {
+ "key": "sonar.demo.1.boolean",
+ "value": "true"
+ },
+ {
+ "key": "sonar.demo.2.text",
+ "value": "bar"
+ },
+ {
+ "key": "sonar.demo.2.boolean",
+ "value": "false"
+ }
+]
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.server.config.ws;
-
-import com.google.common.collect.ImmutableMap;
-import java.net.URL;
-import javax.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.PropertyType;
-import org.sonar.api.config.PropertyDefinition;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.PropertyFieldDefinition;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbTester;
-import org.sonar.db.component.ComponentDbTester;
-import org.sonar.db.component.ComponentDto;
-import org.sonar.db.property.PropertyDbTester;
-import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestRequest;
-import org.sonar.server.ws.WsActionTester;
-import org.sonar.test.JsonAssert;
-import org.sonarqube.ws.MediaTypes;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.api.PropertyType.LICENSE;
-import static org.sonar.api.web.UserRole.ADMIN;
-import static org.sonar.api.web.UserRole.CODEVIEWER;
-import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
-import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto;
-import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto;
-import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.MediaTypes.JSON;
-
-public class IndexActionTest {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Rule
- public UserSessionRule userSession = UserSessionRule.standalone();
-
- @Rule
- public DbTester db = DbTester.create(System2.INSTANCE);
-
- DbClient dbClient = db.getDbClient();
- PropertyDbTester propertyDb = new PropertyDbTester(db);
- ComponentDbTester componentDb = new ComponentDbTester(db);
- PropertyDefinitions definitions = new PropertyDefinitions();
-
- ComponentDto project;
-
- WsActionTester ws = new WsActionTester(new IndexAction(dbClient, new ComponentFinder(dbClient), userSession, definitions));
-
- @Before
- public void setUp() throws Exception {
- project = componentDb.insertComponent(newProjectDto());
- }
-
- @Test
- public void return_simple_value() throws Exception {
- setAuthenticatedUser();
- definitions.addComponent(PropertyDefinition.builder("foo").build());
- propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one"));
-
- executeAndVerify(null, null, "return_simple_value.json");
- }
-
- @Test
- public void return_multi_values() throws Exception {
- setAuthenticatedUser();
- // Property never defined, default value is returned
- definitions.addComponent(PropertyDefinition.builder("default")
- .multiValues(true)
- .defaultValue("one,two")
- .build());
- // Property defined at global level
- definitions.addComponent(PropertyDefinition.builder("global")
- .multiValues(true)
- .build());
- propertyDb.insertProperties(newGlobalPropertyDto().setKey("global").setValue("three,four"));
-
- executeAndVerify(null, null, "return_multi_values.json");
- }
-
- @Test
- public void return_multi_value_with_coma() throws Exception {
- setAuthenticatedUser();
- definitions.addComponent(PropertyDefinition.builder("global").multiValues(true).build());
- propertyDb.insertProperties(newGlobalPropertyDto().setKey("global").setValue("three,four%2Cfive"));
-
- executeAndVerify(null, null, "return_multi_value_with_coma.json");
- }
-
- @Test
- public void return_property_set() throws Exception {
- setAuthenticatedUser();
- definitions.addComponent(PropertyDefinition
- .builder("foo")
- .type(PropertyType.PROPERTY_SET)
- .fields(asList(
- PropertyFieldDefinition.build("key").name("Key").build(),
- PropertyFieldDefinition.build("size").name("Size").build()))
- .build());
- propertyDb.insertPropertySet("foo", null, ImmutableMap.of("key", "key1", "size", "size1"), ImmutableMap.of("key", "key2"));
-
- executeAndVerify(null, null, "return_property_set.json");
- }
-
- @Test
- public void return_default_values() throws Exception {
- setAuthenticatedUser();
- definitions.addComponent(PropertyDefinition.builder("foo").defaultValue("default").build());
-
- executeAndVerify(null, null, "return_default_values.json");
- }
-
- @Test
- public void return_global_values() throws Exception {
- setAuthenticatedUser();
- definitions.addComponent(PropertyDefinition.builder("property").defaultValue("default").build());
- propertyDb.insertProperties(
- // The property is overriding default value
- newGlobalPropertyDto().setKey("property").setValue("one"));
-
- executeAndVerify(null, null, "return_global_values.json");
- }
-
- @Test
- public void return_project_values() throws Exception {
- setUserWithBrowsePermissionOnProject();
- definitions.addComponent(PropertyDefinition.builder("property").defaultValue("default").build());
- propertyDb.insertProperties(
- newGlobalPropertyDto().setKey("property").setValue("one"),
- // The property is overriding global value
- newComponentPropertyDto(project).setKey("property").setValue("two"));
-
- executeAndVerify(project.key(), null, "return_project_values.json");
- }
-
- @Test
- public void return_values_even_if_no_property_definition() throws Exception {
- setAuthenticatedUser();
- propertyDb.insertProperties(newGlobalPropertyDto().setKey("globalPropertyWithoutDefinition").setValue("value"));
-
- executeAndVerify(null, null, "return_values_even_if_no_property_definition.json");
- }
-
- @Test
- public void return_empty_when_property_def_exists_but_no_value() throws Exception {
- setAuthenticatedUser();
- definitions.addComponent(PropertyDefinition.builder("foo").build());
-
- executeAndVerify(null, null, "empty.json");
- }
-
- @Test
- public void return_nothing_when_unknown_key() throws Exception {
- setAuthenticatedUser();
- definitions.addComponent(PropertyDefinition.builder("foo").defaultValue("default").build());
- propertyDb.insertProperties(newGlobalPropertyDto().setKey("bar").setValue(""));
-
- executeAndVerify(null, "unknown", "empty.json");
- }
-
- @Test
- public void return_module_values() throws Exception {
- setUserWithBrowsePermissionOnProject();
- ComponentDto module = componentDb.insertComponent(newModuleDto(project));
- definitions.addComponent(PropertyDefinition.builder("property").defaultValue("default").build());
- propertyDb.insertProperties(
- newGlobalPropertyDto().setKey("property").setValue("one"),
- // The property is overriding global value
- newComponentPropertyDto(module).setKey("property").setValue("two"));
-
- executeAndVerify(module.key(), "property", "return_module_values.json");
- }
-
- @Test
- public void return_inherited_values_on_module() throws Exception {
- setUserWithBrowsePermissionOnProject();
- ComponentDto module = componentDb.insertComponent(newModuleDto(project));
- definitions.addComponents(asList(
- PropertyDefinition.builder("defaultProperty").defaultValue("default").build(),
- PropertyDefinition.builder("globalProperty").build(),
- PropertyDefinition.builder("projectProperty").build(),
- PropertyDefinition.builder("moduleProperty").build()));
- propertyDb.insertProperties(
- newGlobalPropertyDto().setKey("globalProperty").setValue("global"),
- newComponentPropertyDto(project).setKey("projectProperty").setValue("project"),
- newComponentPropertyDto(module).setKey("moduleProperty").setValue("module"));
-
- executeAndVerify(module.key(), null, "return_inherited_values_on_module.json");
- }
-
- @Test
- public void return_inherited_values_on_global_setting() throws Exception {
- setAuthenticatedUser();
- definitions.addComponents(asList(
- PropertyDefinition.builder("defaultProperty").defaultValue("default").build(),
- PropertyDefinition.builder("globalProperty").build()));
- propertyDb.insertProperties(
- newGlobalPropertyDto().setKey("globalProperty").setValue("global"));
-
- executeAndVerify(null, null, "return_inherited_values_on_global_setting.json");
- }
-
- @Test
- public void does_not_return_value_of_deprecated_key() throws Exception {
- setAuthenticatedUser();
- definitions.addComponent(PropertyDefinition.builder("foo").deprecatedKey("deprecated").build());
- propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one"));
-
- executeAndVerify(null, "deprecated", "empty.json");
- }
-
- @Test
- public void does_not_returned_secured_and_license_settings_when_not_authenticated() throws Exception {
- definitions.addComponents(asList(
- PropertyDefinition.builder("foo").build(),
- PropertyDefinition.builder("secret.secured").build(),
- PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
- propertyDb.insertProperties(
- newGlobalPropertyDto().setKey("foo").setValue("one"),
- newGlobalPropertyDto().setKey("secret.secured").setValue("password"),
- newGlobalPropertyDto().setKey("plugin.license.secured").setValue("ABCD"));
-
- executeAndVerify(null, null, "does_not_returned_secured_and_license_settings_when_not_authenticated.json");
- }
-
- @Test
- public void does_not_returned_secured_and_license_settings_in_property_set_when_not_authenticated() throws Exception {
- definitions.addComponent(PropertyDefinition
- .builder("foo")
- .type(PropertyType.PROPERTY_SET)
- .fields(asList(
- PropertyFieldDefinition.build("key").name("Key").build(),
- PropertyFieldDefinition.build("plugin.license.secured").name("License").type(LICENSE).build(),
- PropertyFieldDefinition.build("secret.secured").name("Secured").build()))
- .build());
- propertyDb.insertPropertySet("foo", null,
- ImmutableMap.of("key", "key1", "plugin.license.secured", "ABCD", "secret.secured", "123456"));
-
- executeAndVerify(null, null, "does_not_returned_secured_and_license_settings_in_property_set_when_not_authenticated.json");
- }
-
- @Test
- public void return_license_with_hash_settings_when_authenticated_but_not_admin() throws Exception {
- setUserWithBrowsePermissionOnProject();
- definitions.addComponents(asList(
- PropertyDefinition.builder("foo").build(),
- PropertyDefinition.builder("secret.secured").build(),
- PropertyDefinition.builder("commercial.plugin").type(LICENSE).build(),
- PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
- propertyDb.insertProperties(
- newGlobalPropertyDto().setKey("foo").setValue("one"),
- newGlobalPropertyDto().setKey("secret.secured").setValue("password"),
- newGlobalPropertyDto().setKey("commercial.plugin").setValue("ABCD"),
- newGlobalPropertyDto().setKey("plugin.license.secured").setValue("ABCD"),
- newGlobalPropertyDto().setKey("plugin.licenseHash.secured").setValue("987654321"));
-
- executeAndVerify(null, null, "return_license_with_hash_settings_when_authenticated_but_not_admin.json");
- }
-
- @Test
- public void return_secured_and_license_settings_when_system_admin() throws Exception {
- setUserAsSystemAdmin();
- definitions.addComponents(asList(
- PropertyDefinition.builder("foo").build(),
- PropertyDefinition.builder("secret.secured").build(),
- PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
- propertyDb.insertProperties(
- newGlobalPropertyDto().setKey("foo").setValue("one"),
- newGlobalPropertyDto().setKey("secret.secured").setValue("password"),
- newGlobalPropertyDto().setKey("plugin.license.secured").setValue("ABCD"),
- newGlobalPropertyDto().setKey("plugin.licenseHash.secured").setValue("987654321"));
-
- executeAndVerify(null, null, "return_secured_and_license_settings_when_system_admin.json");
- }
-
- @Test
- public void return_secured_and_license_settings_when_project_admin() throws Exception {
- setUserAsProjectAdmin();
- definitions.addComponents(asList(
- PropertyDefinition.builder("foo").build(),
- PropertyDefinition.builder("secret.secured").build(),
- PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
- propertyDb.insertProperties(
- newComponentPropertyDto(project).setKey("foo").setValue("one"),
- newComponentPropertyDto(project).setKey("secret.secured").setValue("password"),
- newComponentPropertyDto(project).setKey("plugin.license.secured").setValue("ABCD"),
- newComponentPropertyDto(project).setKey("plugin.licenseHash.secured").setValue("987654321"));
-
- executeAndVerify(project.key(), null, "return_secured_and_license_settings_when_project_admin.json");
- }
-
- @Test
- public void return_secured_and_license_settings_in_property_set_when_system_admin() throws Exception {
- setUserAsSystemAdmin();
- definitions.addComponent(PropertyDefinition
- .builder("foo")
- .type(PropertyType.PROPERTY_SET)
- .fields(asList(
- PropertyFieldDefinition.build("key").name("Key").build(),
- PropertyFieldDefinition.build("plugin.license.secured").name("License").type(LICENSE).build(),
- PropertyFieldDefinition.build("secret.secured").name("Secured").build()))
- .build());
- propertyDb.insertPropertySet("foo", null,
- ImmutableMap.of("key", "key1", "plugin.license.secured", "ABCD", "secret.secured", "123456"));
-
- executeAndVerify(null, null, "return_secured_and_license_settings_in_property_set_when_system_admin.json");
- }
-
- @Test
- public void return_all_settings_when_no_component_and_no_key() throws Exception {
- setUserAsSystemAdmin();
- definitions.addComponents(asList(
- PropertyDefinition.builder("foo").build(),
- PropertyDefinition.builder("secret.secured").build(),
- PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
- propertyDb.insertProperties(
- newGlobalPropertyDto().setKey("foo").setValue("one"),
- newGlobalPropertyDto().setKey("secret.secured").setValue("password"),
- newGlobalPropertyDto().setKey("plugin.license.secured").setValue("ABCD"),
- newGlobalPropertyDto().setKey("not_defined").setValue("ABCD"));
-
- executeAndVerify(null, null, "return_all_settings_when_no_component_and_no_key.json");
- }
-
- @Test
- public void return_all_project_settings_when_component_and_no_key() throws Exception {
- setUserAsProjectAdmin();
- definitions.addComponents(asList(
- PropertyDefinition.builder("foo").build(),
- PropertyDefinition.builder("secret.secured").build(),
- PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
- propertyDb.insertProperties(
- newComponentPropertyDto(project).setKey("foo").setValue("one"),
- newComponentPropertyDto(project).setKey("secret.secured").setValue("password"),
- newComponentPropertyDto(project).setKey("plugin.license.secured").setValue("ABCD"),
- newComponentPropertyDto(project).setKey("not_defined").setValue("ABCD"),
- newGlobalPropertyDto().setKey("global_not_defined").setValue("ABCD"));
-
- executeAndVerify(project.key(), null, "return_all_project_settings_when_component_and_no_key.json");
- }
-
- @Test
- public void return_only_one_setting_when_key_is_provided() throws Exception {
- definitions.addComponents(asList(
- PropertyDefinition.builder("foo").build(),
- PropertyDefinition.builder("bar").build()));
- propertyDb.insertProperties(
- newGlobalPropertyDto().setKey("foo").setValue("one"),
- newGlobalPropertyDto().setKey("bar").setValue("two"));
-
- executeAndVerify(project.key(), "foo", "return_only_one_setting_when_key_is_provided.json");
- executeAndVerify(project.key(), "unknown", "empty.json");
- }
-
- @Test
- public void does_not_fail_when_user_has_not_project_browse_permission() throws Exception {
- userSession.login("project-admin").addProjectUuidPermissions(CODEVIEWER, project.uuid());
- definitions.addComponent(PropertyDefinition.builder("foo").build());
- propertyDb.insertProperties(newComponentPropertyDto(project).setKey("foo").setValue("one"));
-
- executeAndVerify(project.key(), null, "does_not_fail_when_user_has_not_project_browse_permission.json");
- }
-
- @Test
- public void does_not_fail_when_format_is_set_to_json() throws Exception {
- setAuthenticatedUser();
- definitions.addComponent(PropertyDefinition.builder("foo").defaultValue("default").build());
-
- ws.newRequest().setParam("format", "json").execute();
- }
-
- @Test
- public void fail_when_format_is_set_to_xml() throws Exception {
- setAuthenticatedUser();
- definitions.addComponent(PropertyDefinition.builder("foo").defaultValue("default").build());
-
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("Value of parameter 'format' (xml) must be one of: [json]");
- ws.newRequest().setParam("format", "xml").execute();
- }
-
- @Test
- public void test_example_json_response() {
- setAuthenticatedUser();
- definitions.addComponent(PropertyDefinition
- .builder("sonar.test.jira")
- .defaultValue("abc")
- .build());
- definitions.addComponent(PropertyDefinition
- .builder("sonar.autogenerated")
- .multiValues(true)
- .build());
- propertyDb.insertProperties(newGlobalPropertyDto().setKey("sonar.autogenerated").setValue("val1,val2,val3"));
- definitions.addComponent(PropertyDefinition
- .builder("sonar.demo")
- .type(PropertyType.PROPERTY_SET)
- .fields(PropertyFieldDefinition.build("text").name("Text").build(),
- PropertyFieldDefinition.build("boolean").name("Boolean").build())
- .build());
- propertyDb.insertPropertySet("sonar.demo", null, ImmutableMap.of("text", "foo", "boolean", "true"), ImmutableMap.of("text", "bar", "boolean", "false"));
-
- String result = ws.newRequest().setMediaType(JSON).execute().getInput();
-
- JsonAssert.assertJson(ws.getDef().responseExampleAsString()).isSimilarTo(result);
- }
-
- @Test
- public void test_ws_definition() {
- WebService.Action action = ws.getDef();
- assertThat(action).isNotNull();
- assertThat(action.isInternal()).isFalse();
- assertThat(action.isPost()).isFalse();
- assertThat(action.responseExampleAsString()).isNotEmpty();
- assertThat(action.params()).hasSize(3);
- }
-
- private void executeAndVerify(@Nullable String componentKey, @Nullable String key, String expectedFile) {
- TestRequest request = ws.newRequest().setMediaType(MediaTypes.JSON);
- if (key != null) {
- request.setParam("key", key);
- }
- if (componentKey != null) {
- request.setParam("resource", componentKey);
- }
- String result = request.execute().getInput();
- assertJson(result).isSimilarTo(resource(expectedFile));
- }
-
- private void setAuthenticatedUser() {
- userSession.login("user");
- }
-
- private void setUserWithBrowsePermissionOnProject() {
- userSession.login("user").addProjectUuidPermissions(USER, project.uuid());
- }
-
- private void setUserAsSystemAdmin() {
- userSession.login("admin").setGlobalPermissions(SYSTEM_ADMIN);
- }
-
- private void setUserAsProjectAdmin() {
- userSession.login("project-admin")
- .addProjectUuidPermissions(ADMIN, project.uuid())
- .addProjectUuidPermissions(USER, project.uuid());
- }
-
- protected static URL resource(String s) {
- Class<IndexActionTest> clazz = IndexActionTest.class;
- return clazz.getResource(clazz.getSimpleName() + "/" + s);
- }
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.property.ws;
+
+import com.google.common.collect.ImmutableMap;
+import java.net.URL;
+import javax.annotation.Nullable;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.PropertyType;
+import org.sonar.api.config.PropertyDefinition;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.api.config.PropertyFieldDefinition;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbTester;
+import org.sonar.db.component.ComponentDbTester;
+import org.sonar.db.component.ComponentDto;
+import org.sonar.db.property.PropertyDbTester;
+import org.sonar.server.component.ComponentFinder;
+import org.sonar.server.tester.UserSessionRule;
+import org.sonar.server.ws.TestRequest;
+import org.sonar.server.ws.WsActionTester;
+import org.sonar.test.JsonAssert;
+import org.sonarqube.ws.MediaTypes;
+
+import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.api.PropertyType.LICENSE;
+import static org.sonar.api.web.UserRole.ADMIN;
+import static org.sonar.api.web.UserRole.CODEVIEWER;
+import static org.sonar.api.web.UserRole.USER;
+import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
+import static org.sonar.db.component.ComponentTesting.newModuleDto;
+import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto;
+import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto;
+import static org.sonar.test.JsonAssert.assertJson;
+import static org.sonarqube.ws.MediaTypes.JSON;
+
+public class IndexActionTest {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Rule
+ public UserSessionRule userSession = UserSessionRule.standalone();
+
+ @Rule
+ public DbTester db = DbTester.create(System2.INSTANCE);
+
+ DbClient dbClient = db.getDbClient();
+ PropertyDbTester propertyDb = new PropertyDbTester(db);
+ ComponentDbTester componentDb = new ComponentDbTester(db);
+ PropertyDefinitions definitions = new PropertyDefinitions();
+
+ ComponentDto project;
+
+ WsActionTester ws = new WsActionTester(new IndexAction(dbClient, new ComponentFinder(dbClient), userSession, definitions));
+
+ @Before
+ public void setUp() throws Exception {
+ project = componentDb.insertComponent(newProjectDto());
+ }
+
+ @Test
+ public void return_simple_value() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition.builder("foo").build());
+ propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one"));
+
+ executeAndVerify(null, null, "return_simple_value.json");
+ }
+
+ @Test
+ public void return_multi_values() throws Exception {
+ setAuthenticatedUser();
+ // Property never defined, default value is returned
+ definitions.addComponent(PropertyDefinition.builder("default")
+ .multiValues(true)
+ .defaultValue("one,two")
+ .build());
+ // Property defined at global level
+ definitions.addComponent(PropertyDefinition.builder("global")
+ .multiValues(true)
+ .build());
+ propertyDb.insertProperties(newGlobalPropertyDto().setKey("global").setValue("three,four"));
+
+ executeAndVerify(null, null, "return_multi_values.json");
+ }
+
+ @Test
+ public void return_multi_value_with_coma() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition.builder("global").multiValues(true).build());
+ propertyDb.insertProperties(newGlobalPropertyDto().setKey("global").setValue("three,four%2Cfive"));
+
+ executeAndVerify(null, null, "return_multi_value_with_coma.json");
+ }
+
+ @Test
+ public void return_property_set() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition
+ .builder("foo")
+ .type(PropertyType.PROPERTY_SET)
+ .fields(asList(
+ PropertyFieldDefinition.build("key").name("Key").build(),
+ PropertyFieldDefinition.build("size").name("Size").build()))
+ .build());
+ propertyDb.insertPropertySet("foo", null, ImmutableMap.of("key", "key1", "size", "size1"), ImmutableMap.of("key", "key2"));
+
+ executeAndVerify(null, null, "return_property_set.json");
+ }
+
+ @Test
+ public void return_default_values() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition.builder("foo").defaultValue("default").build());
+
+ executeAndVerify(null, null, "return_default_values.json");
+ }
+
+ @Test
+ public void return_global_values() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition.builder("property").defaultValue("default").build());
+ propertyDb.insertProperties(
+ // The property is overriding default value
+ newGlobalPropertyDto().setKey("property").setValue("one"));
+
+ executeAndVerify(null, null, "return_global_values.json");
+ }
+
+ @Test
+ public void return_project_values() throws Exception {
+ setUserWithBrowsePermissionOnProject();
+ definitions.addComponent(PropertyDefinition.builder("property").defaultValue("default").build());
+ propertyDb.insertProperties(
+ newGlobalPropertyDto().setKey("property").setValue("one"),
+ // The property is overriding global value
+ newComponentPropertyDto(project).setKey("property").setValue("two"));
+
+ executeAndVerify(project.key(), null, "return_project_values.json");
+ }
+
+ @Test
+ public void return_values_even_if_no_property_definition() throws Exception {
+ setAuthenticatedUser();
+ propertyDb.insertProperties(newGlobalPropertyDto().setKey("globalPropertyWithoutDefinition").setValue("value"));
+
+ executeAndVerify(null, null, "return_values_even_if_no_property_definition.json");
+ }
+
+ @Test
+ public void return_empty_when_property_def_exists_but_no_value() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition.builder("foo").build());
+
+ executeAndVerify(null, null, "empty.json");
+ }
+
+ @Test
+ public void return_nothing_when_unknown_key() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition.builder("foo").defaultValue("default").build());
+ propertyDb.insertProperties(newGlobalPropertyDto().setKey("bar").setValue(""));
+
+ executeAndVerify(null, "unknown", "empty.json");
+ }
+
+ @Test
+ public void return_module_values() throws Exception {
+ setUserWithBrowsePermissionOnProject();
+ ComponentDto module = componentDb.insertComponent(newModuleDto(project));
+ definitions.addComponent(PropertyDefinition.builder("property").defaultValue("default").build());
+ propertyDb.insertProperties(
+ newGlobalPropertyDto().setKey("property").setValue("one"),
+ // The property is overriding global value
+ newComponentPropertyDto(module).setKey("property").setValue("two"));
+
+ executeAndVerify(module.key(), "property", "return_module_values.json");
+ }
+
+ @Test
+ public void return_inherited_values_on_module() throws Exception {
+ setUserWithBrowsePermissionOnProject();
+ ComponentDto module = componentDb.insertComponent(newModuleDto(project));
+ definitions.addComponents(asList(
+ PropertyDefinition.builder("defaultProperty").defaultValue("default").build(),
+ PropertyDefinition.builder("globalProperty").build(),
+ PropertyDefinition.builder("projectProperty").build(),
+ PropertyDefinition.builder("moduleProperty").build()));
+ propertyDb.insertProperties(
+ newGlobalPropertyDto().setKey("globalProperty").setValue("global"),
+ newComponentPropertyDto(project).setKey("projectProperty").setValue("project"),
+ newComponentPropertyDto(module).setKey("moduleProperty").setValue("module"));
+
+ executeAndVerify(module.key(), null, "return_inherited_values_on_module.json");
+ }
+
+ @Test
+ public void return_inherited_values_on_global_setting() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponents(asList(
+ PropertyDefinition.builder("defaultProperty").defaultValue("default").build(),
+ PropertyDefinition.builder("globalProperty").build()));
+ propertyDb.insertProperties(
+ newGlobalPropertyDto().setKey("globalProperty").setValue("global"));
+
+ executeAndVerify(null, null, "return_inherited_values_on_global_setting.json");
+ }
+
+ @Test
+ public void does_not_return_value_of_deprecated_key() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition.builder("foo").deprecatedKey("deprecated").build());
+ propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one"));
+
+ executeAndVerify(null, "deprecated", "empty.json");
+ }
+
+ @Test
+ public void does_not_returned_secured_and_license_settings_when_not_authenticated() throws Exception {
+ definitions.addComponents(asList(
+ PropertyDefinition.builder("foo").build(),
+ PropertyDefinition.builder("secret.secured").build(),
+ PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
+ propertyDb.insertProperties(
+ newGlobalPropertyDto().setKey("foo").setValue("one"),
+ newGlobalPropertyDto().setKey("secret.secured").setValue("password"),
+ newGlobalPropertyDto().setKey("plugin.license.secured").setValue("ABCD"));
+
+ executeAndVerify(null, null, "does_not_returned_secured_and_license_settings_when_not_authenticated.json");
+ }
+
+ @Test
+ public void does_not_returned_secured_and_license_settings_in_property_set_when_not_authenticated() throws Exception {
+ definitions.addComponent(PropertyDefinition
+ .builder("foo")
+ .type(PropertyType.PROPERTY_SET)
+ .fields(asList(
+ PropertyFieldDefinition.build("key").name("Key").build(),
+ PropertyFieldDefinition.build("plugin.license.secured").name("License").type(LICENSE).build(),
+ PropertyFieldDefinition.build("secret.secured").name("Secured").build()))
+ .build());
+ propertyDb.insertPropertySet("foo", null,
+ ImmutableMap.of("key", "key1", "plugin.license.secured", "ABCD", "secret.secured", "123456"));
+
+ executeAndVerify(null, null, "does_not_returned_secured_and_license_settings_in_property_set_when_not_authenticated.json");
+ }
+
+ @Test
+ public void return_license_with_hash_settings_when_authenticated_but_not_admin() throws Exception {
+ setUserWithBrowsePermissionOnProject();
+ definitions.addComponents(asList(
+ PropertyDefinition.builder("foo").build(),
+ PropertyDefinition.builder("secret.secured").build(),
+ PropertyDefinition.builder("commercial.plugin").type(LICENSE).build(),
+ PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
+ propertyDb.insertProperties(
+ newGlobalPropertyDto().setKey("foo").setValue("one"),
+ newGlobalPropertyDto().setKey("secret.secured").setValue("password"),
+ newGlobalPropertyDto().setKey("commercial.plugin").setValue("ABCD"),
+ newGlobalPropertyDto().setKey("plugin.license.secured").setValue("ABCD"),
+ newGlobalPropertyDto().setKey("plugin.licenseHash.secured").setValue("987654321"));
+
+ executeAndVerify(null, null, "return_license_with_hash_settings_when_authenticated_but_not_admin.json");
+ }
+
+ @Test
+ public void return_secured_and_license_settings_when_system_admin() throws Exception {
+ setUserAsSystemAdmin();
+ definitions.addComponents(asList(
+ PropertyDefinition.builder("foo").build(),
+ PropertyDefinition.builder("secret.secured").build(),
+ PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
+ propertyDb.insertProperties(
+ newGlobalPropertyDto().setKey("foo").setValue("one"),
+ newGlobalPropertyDto().setKey("secret.secured").setValue("password"),
+ newGlobalPropertyDto().setKey("plugin.license.secured").setValue("ABCD"),
+ newGlobalPropertyDto().setKey("plugin.licenseHash.secured").setValue("987654321"));
+
+ executeAndVerify(null, null, "return_secured_and_license_settings_when_system_admin.json");
+ }
+
+ @Test
+ public void return_secured_and_license_settings_when_project_admin() throws Exception {
+ setUserAsProjectAdmin();
+ definitions.addComponents(asList(
+ PropertyDefinition.builder("foo").build(),
+ PropertyDefinition.builder("secret.secured").build(),
+ PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
+ propertyDb.insertProperties(
+ newComponentPropertyDto(project).setKey("foo").setValue("one"),
+ newComponentPropertyDto(project).setKey("secret.secured").setValue("password"),
+ newComponentPropertyDto(project).setKey("plugin.license.secured").setValue("ABCD"),
+ newComponentPropertyDto(project).setKey("plugin.licenseHash.secured").setValue("987654321"));
+
+ executeAndVerify(project.key(), null, "return_secured_and_license_settings_when_project_admin.json");
+ }
+
+ @Test
+ public void return_secured_and_license_settings_in_property_set_when_system_admin() throws Exception {
+ setUserAsSystemAdmin();
+ definitions.addComponent(PropertyDefinition
+ .builder("foo")
+ .type(PropertyType.PROPERTY_SET)
+ .fields(asList(
+ PropertyFieldDefinition.build("key").name("Key").build(),
+ PropertyFieldDefinition.build("plugin.license.secured").name("License").type(LICENSE).build(),
+ PropertyFieldDefinition.build("secret.secured").name("Secured").build()))
+ .build());
+ propertyDb.insertPropertySet("foo", null,
+ ImmutableMap.of("key", "key1", "plugin.license.secured", "ABCD", "secret.secured", "123456"));
+
+ executeAndVerify(null, null, "return_secured_and_license_settings_in_property_set_when_system_admin.json");
+ }
+
+ @Test
+ public void return_all_settings_when_no_component_and_no_key() throws Exception {
+ setUserAsSystemAdmin();
+ definitions.addComponents(asList(
+ PropertyDefinition.builder("foo").build(),
+ PropertyDefinition.builder("secret.secured").build(),
+ PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
+ propertyDb.insertProperties(
+ newGlobalPropertyDto().setKey("foo").setValue("one"),
+ newGlobalPropertyDto().setKey("secret.secured").setValue("password"),
+ newGlobalPropertyDto().setKey("plugin.license.secured").setValue("ABCD"),
+ newGlobalPropertyDto().setKey("not_defined").setValue("ABCD"));
+
+ executeAndVerify(null, null, "return_all_settings_when_no_component_and_no_key.json");
+ }
+
+ @Test
+ public void return_all_project_settings_when_component_and_no_key() throws Exception {
+ setUserAsProjectAdmin();
+ definitions.addComponents(asList(
+ PropertyDefinition.builder("foo").build(),
+ PropertyDefinition.builder("secret.secured").build(),
+ PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
+ propertyDb.insertProperties(
+ newComponentPropertyDto(project).setKey("foo").setValue("one"),
+ newComponentPropertyDto(project).setKey("secret.secured").setValue("password"),
+ newComponentPropertyDto(project).setKey("plugin.license.secured").setValue("ABCD"),
+ newComponentPropertyDto(project).setKey("not_defined").setValue("ABCD"),
+ newGlobalPropertyDto().setKey("global_not_defined").setValue("ABCD"));
+
+ executeAndVerify(project.key(), null, "return_all_project_settings_when_component_and_no_key.json");
+ }
+
+ @Test
+ public void return_only_one_setting_when_key_is_provided() throws Exception {
+ definitions.addComponents(asList(
+ PropertyDefinition.builder("foo").build(),
+ PropertyDefinition.builder("bar").build()));
+ propertyDb.insertProperties(
+ newGlobalPropertyDto().setKey("foo").setValue("one"),
+ newGlobalPropertyDto().setKey("bar").setValue("two"));
+
+ executeAndVerify(project.key(), "foo", "return_only_one_setting_when_key_is_provided.json");
+ executeAndVerify(project.key(), "unknown", "empty.json");
+ }
+
+ @Test
+ public void does_not_fail_when_user_has_not_project_browse_permission() throws Exception {
+ userSession.login("project-admin").addProjectUuidPermissions(CODEVIEWER, project.uuid());
+ definitions.addComponent(PropertyDefinition.builder("foo").build());
+ propertyDb.insertProperties(newComponentPropertyDto(project).setKey("foo").setValue("one"));
+
+ executeAndVerify(project.key(), null, "does_not_fail_when_user_has_not_project_browse_permission.json");
+ }
+
+ @Test
+ public void does_not_fail_when_format_is_set_to_json() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition.builder("foo").defaultValue("default").build());
+
+ ws.newRequest().setParam("format", "json").execute();
+ }
+
+ @Test
+ public void fail_when_format_is_set_to_xml() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition.builder("foo").defaultValue("default").build());
+
+ expectedException.expect(IllegalArgumentException.class);
+ expectedException.expectMessage("Value of parameter 'format' (xml) must be one of: [json]");
+ ws.newRequest().setParam("format", "xml").execute();
+ }
+
+ @Test
+ public void test_example_json_response() {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition
+ .builder("sonar.test.jira")
+ .defaultValue("abc")
+ .build());
+ definitions.addComponent(PropertyDefinition
+ .builder("sonar.autogenerated")
+ .multiValues(true)
+ .build());
+ propertyDb.insertProperties(newGlobalPropertyDto().setKey("sonar.autogenerated").setValue("val1,val2,val3"));
+ definitions.addComponent(PropertyDefinition
+ .builder("sonar.demo")
+ .type(PropertyType.PROPERTY_SET)
+ .fields(PropertyFieldDefinition.build("text").name("Text").build(),
+ PropertyFieldDefinition.build("boolean").name("Boolean").build())
+ .build());
+ propertyDb.insertPropertySet("sonar.demo", null, ImmutableMap.of("text", "foo", "boolean", "true"), ImmutableMap.of("text", "bar", "boolean", "false"));
+
+ String result = ws.newRequest().setMediaType(JSON).execute().getInput();
+
+ JsonAssert.assertJson(ws.getDef().responseExampleAsString()).isSimilarTo(result);
+ }
+
+ @Test
+ public void test_ws_definition() {
+ WebService.Action action = ws.getDef();
+ assertThat(action).isNotNull();
+ assertThat(action.isInternal()).isFalse();
+ assertThat(action.isPost()).isFalse();
+ assertThat(action.responseExampleAsString()).isNotEmpty();
+ assertThat(action.params()).hasSize(3);
+ }
+
+ private void executeAndVerify(@Nullable String componentKey, @Nullable String key, String expectedFile) {
+ TestRequest request = ws.newRequest().setMediaType(MediaTypes.JSON);
+ if (key != null) {
+ request.setParam("key", key);
+ }
+ if (componentKey != null) {
+ request.setParam("resource", componentKey);
+ }
+ String result = request.execute().getInput();
+ assertJson(result).isSimilarTo(resource(expectedFile));
+ }
+
+ private void setAuthenticatedUser() {
+ userSession.login("user");
+ }
+
+ private void setUserWithBrowsePermissionOnProject() {
+ userSession.login("user").addProjectUuidPermissions(USER, project.uuid());
+ }
+
+ private void setUserAsSystemAdmin() {
+ userSession.login("admin").setGlobalPermissions(SYSTEM_ADMIN);
+ }
+
+ private void setUserAsProjectAdmin() {
+ userSession.login("project-admin")
+ .addProjectUuidPermissions(ADMIN, project.uuid())
+ .addProjectUuidPermissions(USER, project.uuid());
+ }
+
+ protected static URL resource(String s) {
+ Class<IndexActionTest> clazz = IndexActionTest.class;
+ return clazz.getResource(clazz.getSimpleName() + "/" + s);
+ }
+}
+++ /dev/null
-[
- {
- "key": "foo",
- "value": "one"
- }
-]
+++ /dev/null
-[
- {
- "key": "foo",
- "value": "1",
- "values": [
- "1"
- ]
- },
- {
- "key": "foo.1.key",
- "value": "key1"
- }
-]
+++ /dev/null
-[
- {
- "key": "foo",
- "value": "one"
- }
-]
+++ /dev/null
-[
- {
- "key": "secret.secured",
- "value": "password"
- },
- {
- "key": "foo",
- "value": "one"
- },
- {
- "key": "not_defined",
- "value": "ABCD"
- },
- {
- "key": "plugin.license.secured",
- "value": "ABCD"
- },
- {
- "key": "global_not_defined",
- "value": "ABCD"
- }
-]
+++ /dev/null
-[
- {
- "key": "secret.secured",
- "value": "password"
- },
- {
- "key": "foo",
- "value": "one"
- },
- {
- "key": "not_defined",
- "value": "ABCD"
- },
- {
- "key": "plugin.license.secured",
- "value": "ABCD"
- }
-]
+++ /dev/null
-[
- {
- "key": "foo",
- "value": "default"
- }
-]
+++ /dev/null
-[
- {
- "key": "property",
- "value": "one"
- }
-]
+++ /dev/null
-[
- {
- "key": "defaultProperty",
- "value": "default"
- },
- {
- "key": "globalProperty",
- "value": "global"
- }
-]
+++ /dev/null
-[
- {
- "key": "defaultProperty",
- "value": "default"
- },
- {
- "key": "projectProperty",
- "value": "project"
- },
- {
- "key": "globalProperty",
- "value": "global"
- },
- {
- "key": "moduleProperty",
- "value": "module"
- }
-]
+++ /dev/null
-[
- {
- "key": "plugin.licenseHash.secured",
- "value": "987654321"
- },
- {
- "key": "foo",
- "value": "one"
- },
- {
- "key": "plugin.license.secured",
- "value": "ABCD"
- },
- {
- "key": "commercial.plugin",
- "value": "ABCD"
- }
-]
+++ /dev/null
-[
- {
- "key": "property",
- "value": "two"
- }
-]
+++ /dev/null
-[
- {
- "key": "global",
- "value": "three,four%2Cfive",
- "values": [
- "three",
- "four,five"
- ]
- }
-]
+++ /dev/null
-[
- {
- "key": "default",
- "value": "one,two",
- "values": [
- "one",
- "two"
- ]
- },
- {
- "key": "global",
- "value": "three,four",
- "values": [
- "three",
- "four"
- ]
- }
-]
+++ /dev/null
-[
- {
- "key": "foo",
- "value": "one"
- }
-]
+++ /dev/null
-[
- {
- "key": "property",
- "value": "two"
- }
-]
+++ /dev/null
-[
- {
- "key": "foo",
- "value": "1,2",
- "values": [
- "1",
- "2"
- ]
- },
- {
- "key": "foo.1.key",
- "value": "key1"
- },
- {
- "key": "foo.2.key",
- "value": "key2"
- },
- {
- "key": "foo.1.size",
- "value": "size1"
- }
-]
+++ /dev/null
-[
- {
- "key": "foo",
- "value": "1",
- "values": [
- "1"
- ]
- },
- {
- "key": "foo.1.key",
- "value": "key1"
- },
- {
- "key": "foo.1.plugin.license.secured",
- "value": "ABCD"
- },
- {
- "key": "foo.1.secret.secured",
- "value": "123456"
- }
-]
+++ /dev/null
-[
- {
- "key": "secret.secured",
- "value": "password"
- },
- {
- "key": "plugin.licenseHash.secured",
- "value": "987654321"
- },
- {
- "key": "foo",
- "value": "one"
- },
- {
- "key": "plugin.license.secured",
- "value": "ABCD"
- }
-]
+++ /dev/null
-[
- {
- "key": "secret.secured",
- "value": "password"
- },
- {
- "key": "plugin.licenseHash.secured",
- "value": "987654321"
- },
- {
- "key": "foo",
- "value": "one"
- },
- {
- "key": "plugin.license.secured",
- "value": "ABCD"
- }
-]
+++ /dev/null
-[
- {
- "key": "foo",
- "value": "one"
- }
-]
+++ /dev/null
-[
- {
- "key": "globalPropertyWithoutDefinition",
- "value": "value"
- }
-]
--- /dev/null
+[
+ {
+ "key": "foo",
+ "value": "one"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "foo",
+ "value": "1",
+ "values": [
+ "1"
+ ]
+ },
+ {
+ "key": "foo.1.key",
+ "value": "key1"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "foo",
+ "value": "one"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "secret.secured",
+ "value": "password"
+ },
+ {
+ "key": "foo",
+ "value": "one"
+ },
+ {
+ "key": "not_defined",
+ "value": "ABCD"
+ },
+ {
+ "key": "plugin.license.secured",
+ "value": "ABCD"
+ },
+ {
+ "key": "global_not_defined",
+ "value": "ABCD"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "secret.secured",
+ "value": "password"
+ },
+ {
+ "key": "foo",
+ "value": "one"
+ },
+ {
+ "key": "not_defined",
+ "value": "ABCD"
+ },
+ {
+ "key": "plugin.license.secured",
+ "value": "ABCD"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "foo",
+ "value": "default"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "property",
+ "value": "one"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "defaultProperty",
+ "value": "default"
+ },
+ {
+ "key": "globalProperty",
+ "value": "global"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "defaultProperty",
+ "value": "default"
+ },
+ {
+ "key": "projectProperty",
+ "value": "project"
+ },
+ {
+ "key": "globalProperty",
+ "value": "global"
+ },
+ {
+ "key": "moduleProperty",
+ "value": "module"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "plugin.licenseHash.secured",
+ "value": "987654321"
+ },
+ {
+ "key": "foo",
+ "value": "one"
+ },
+ {
+ "key": "plugin.license.secured",
+ "value": "ABCD"
+ },
+ {
+ "key": "commercial.plugin",
+ "value": "ABCD"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "property",
+ "value": "two"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "global",
+ "value": "three,four%2Cfive",
+ "values": [
+ "three",
+ "four,five"
+ ]
+ }
+]
--- /dev/null
+[
+ {
+ "key": "default",
+ "value": "one,two",
+ "values": [
+ "one",
+ "two"
+ ]
+ },
+ {
+ "key": "global",
+ "value": "three,four",
+ "values": [
+ "three",
+ "four"
+ ]
+ }
+]
--- /dev/null
+[
+ {
+ "key": "foo",
+ "value": "one"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "property",
+ "value": "two"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "foo",
+ "value": "1,2",
+ "values": [
+ "1",
+ "2"
+ ]
+ },
+ {
+ "key": "foo.1.key",
+ "value": "key1"
+ },
+ {
+ "key": "foo.2.key",
+ "value": "key2"
+ },
+ {
+ "key": "foo.1.size",
+ "value": "size1"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "foo",
+ "value": "1",
+ "values": [
+ "1"
+ ]
+ },
+ {
+ "key": "foo.1.key",
+ "value": "key1"
+ },
+ {
+ "key": "foo.1.plugin.license.secured",
+ "value": "ABCD"
+ },
+ {
+ "key": "foo.1.secret.secured",
+ "value": "123456"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "secret.secured",
+ "value": "password"
+ },
+ {
+ "key": "plugin.licenseHash.secured",
+ "value": "987654321"
+ },
+ {
+ "key": "foo",
+ "value": "one"
+ },
+ {
+ "key": "plugin.license.secured",
+ "value": "ABCD"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "secret.secured",
+ "value": "password"
+ },
+ {
+ "key": "plugin.licenseHash.secured",
+ "value": "987654321"
+ },
+ {
+ "key": "foo",
+ "value": "one"
+ },
+ {
+ "key": "plugin.license.secured",
+ "value": "ABCD"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "foo",
+ "value": "one"
+ }
+]
--- /dev/null
+[
+ {
+ "key": "globalPropertyWithoutDefinition",
+ "value": "value"
+ }
+]