source
public boolean isAllowedSourceDirectory(final String sourceDirectory) {
return normalizedSourceDirectories.contains(PATH_UTIL.getAbsolutePath(sourceDirectory));
}
-
- /**
- * Sets the active theme to be used when rendering the source code with prism.
- *
- * @param theme
- * the theme to use
- */
- @DataBoundSetter
- public void setTheme(final PrismTheme theme) {
- this.theme = theme;
- }
-
- public PrismTheme getTheme() {
- return theme;
- }
-
- /**
- * Returns all available themes.
- *
- * @return a model with all available themes
- */
- @POST
- public ListBoxModel doFillThemeItems() {
- ListBoxModel options = new ListBoxModel();
- if (jenkins.hasPermission(Jenkins.ADMINISTER)) {
- options.addAll(PrismTheme.getAllDisplayNames());
- }
- return options;
- }
}
diff --git a/src/main/resources/io/jenkins/plugins/prism/PrismAppearanceConfiguration/config.jelly b/src/main/resources/io/jenkins/plugins/prism/PrismAppearanceConfiguration/config.jelly
new file mode 100644
index 0000000..961bf28
--- /dev/null
+++ b/src/main/resources/io/jenkins/plugins/prism/PrismAppearanceConfiguration/config.jelly
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/io/jenkins/plugins/prism/PrismAppearanceConfiguration/config.properties b/src/main/resources/io/jenkins/plugins/prism/PrismAppearanceConfiguration/config.properties
new file mode 100644
index 0000000..59e85c7
--- /dev/null
+++ b/src/main/resources/io/jenkins/plugins/prism/PrismAppearanceConfiguration/config.properties
@@ -0,0 +1,2 @@
+sourceDirectories.title=Permitted Source Code Directories
+sourceDirectories.description=Valid and permitted source code locations on agents (outside the workspace).
diff --git a/src/main/resources/io/jenkins/plugins/prism/PrismAppearanceConfiguration/help-sourceDirectories.html b/src/main/resources/io/jenkins/plugins/prism/PrismAppearanceConfiguration/help-sourceDirectories.html
new file mode 100644
index 0000000..f7395ce
--- /dev/null
+++ b/src/main/resources/io/jenkins/plugins/prism/PrismAppearanceConfiguration/help-sourceDirectories.html
@@ -0,0 +1,7 @@
+
+ Some plugins copy source code files to Jenkins' build folder so that these files can be rendered in the user
+ interface together with build results (coverage, warnings, etc.). If these files are not part of the workspace
+ of a build then Jenkins will not show them by default: otherwise sensitive files could be shown by accident.
+ You can provide a list of additional source code directories that are allowed to be shown in Jenkins user interface
+ here. Note, that such a directory must be an absolute path on the agent that executes the build.
+
diff --git a/src/main/resources/io/jenkins/plugins/prism/PrismConfiguration/config.jelly b/src/main/resources/io/jenkins/plugins/prism/PrismConfiguration/config.jelly
index 2f34ae2..edae577 100644
--- a/src/main/resources/io/jenkins/plugins/prism/PrismConfiguration/config.jelly
+++ b/src/main/resources/io/jenkins/plugins/prism/PrismConfiguration/config.jelly
@@ -1,7 +1,7 @@
-
+
@@ -14,9 +14,6 @@
-
-
-
diff --git a/src/test/java/io/jenkins/plugins/prism/ConfigurationAsCodeITest.java b/src/test/java/io/jenkins/plugins/prism/ConfigurationAsCodeITest.java
index a64e8cb..6f4c873 100644
--- a/src/test/java/io/jenkins/plugins/prism/ConfigurationAsCodeITest.java
+++ b/src/test/java/io/jenkins/plugins/prism/ConfigurationAsCodeITest.java
@@ -34,7 +34,7 @@ void shouldImportSourceDirectoriesFromYaml() {
void shouldImportTheme() {
configureJenkins("theme.yaml");
- assertThat(PrismConfiguration.getInstance().getTheme()).isEqualTo(PrismTheme.DARK);
+ assertThat(PrismAppearanceConfiguration.getInstance().getTheme()).isEqualTo(PrismTheme.DARK);
}
private void configureJenkins(final String fileName) {
diff --git a/src/test/java/io/jenkins/plugins/prism/PrismAppearanceConfigurationTest.java b/src/test/java/io/jenkins/plugins/prism/PrismAppearanceConfigurationTest.java
new file mode 100644
index 0000000..5f84a35
--- /dev/null
+++ b/src/test/java/io/jenkins/plugins/prism/PrismAppearanceConfigurationTest.java
@@ -0,0 +1,38 @@
+package io.jenkins.plugins.prism;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import io.jenkins.plugins.util.GlobalConfigurationFacade;
+import io.jenkins.plugins.util.JenkinsFacade;
+import jenkins.model.Jenkins;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests the class {@link PrismAppearanceConfiguration}.
+ *
+ * @author Ullrich Hafner
+ */
+class PrismAppearanceConfigurationTest {
+
+ @Test
+ void shouldInitializeThemes() {
+ PrismAppearanceConfiguration configuration = createConfiguration();
+
+ assertThat(configuration.getTheme())
+ .isEqualTo(PrismTheme.PRISM)
+ .extracting(PrismTheme::getFileName)
+ .isEqualTo("prism.css");
+ configuration.setTheme(PrismTheme.COY);
+ assertThat(configuration.getTheme()).isEqualTo(PrismTheme.COY);
+
+ assertThat(configuration.doFillThemeItems()).extracting(o -> o.value).contains(PrismTheme.PRISM.name());
+ }
+
+ private PrismAppearanceConfiguration createConfiguration() {
+ JenkinsFacade jenkins = mock(JenkinsFacade.class);
+ when(jenkins.hasPermission(Jenkins.ADMINISTER)).thenReturn(true);
+ return new PrismAppearanceConfiguration(mock(GlobalConfigurationFacade.class), jenkins);
+ }
+}
diff --git a/src/test/java/io/jenkins/plugins/prism/PrismConfigurationTest.java b/src/test/java/io/jenkins/plugins/prism/PrismConfigurationTest.java
index 2cf3fec..692bbf4 100644
--- a/src/test/java/io/jenkins/plugins/prism/PrismConfigurationTest.java
+++ b/src/test/java/io/jenkins/plugins/prism/PrismConfigurationTest.java
@@ -1,24 +1,19 @@
package io.jenkins.plugins.prism;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import edu.hm.hafner.util.FilteredLog;
+import edu.hm.hafner.util.PathUtil;
+import io.jenkins.plugins.util.GlobalConfigurationFacade;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
-
import org.junit.jupiter.api.Test;
-import edu.hm.hafner.util.FilteredLog;
-import edu.hm.hafner.util.PathUtil;
-
-import jenkins.model.Jenkins;
-
-import io.jenkins.plugins.util.GlobalConfigurationFacade;
-import io.jenkins.plugins.util.JenkinsFacade;
-
-import static org.assertj.core.api.Assertions.*;
-import static org.mockito.Mockito.*;
-
/**
* Tests the class {@link PrismConfiguration}.
*
@@ -57,7 +52,7 @@ void shouldHaveNoRootFoldersWhenCreated() {
@Test
void shouldSaveConfigurationIfFoldersAreAdded() {
GlobalConfigurationFacade facade = mock(GlobalConfigurationFacade.class);
- PrismConfiguration configuration = new PrismConfiguration(facade, mock(JenkinsFacade.class));
+ PrismConfiguration configuration = new PrismConfiguration(facade);
configuration.setSourceDirectories(SOURCE_ROOTS);
@@ -103,20 +98,6 @@ void shouldNormalizePath() {
assertThat(log.getErrorMessages()).isEmpty();
}
- @Test
- void shouldInitializeThemes() {
- PrismConfiguration configuration = createConfiguration();
-
- assertThat(configuration.getTheme())
- .isEqualTo(PrismTheme.PRISM)
- .extracting(PrismTheme::getFileName)
- .isEqualTo("prism.css");
- configuration.setTheme(PrismTheme.COY);
- assertThat(configuration.getTheme()).isEqualTo(PrismTheme.COY);
-
- assertThat(configuration.doFillThemeItems()).extracting(o -> o.value).contains(PrismTheme.PRISM.name());
- }
-
private String getWorkspaceChild(final String expected) {
return PATH_UTIL.createAbsolutePath(NORMALIZED, expected);
}
@@ -143,8 +124,6 @@ private Set asSet(final String... absolutePaths) {
}
private PrismConfiguration createConfiguration() {
- JenkinsFacade jenkins = mock(JenkinsFacade.class);
- when(jenkins.hasPermission(Jenkins.ADMINISTER)).thenReturn(true);
- return new PrismConfiguration(mock(GlobalConfigurationFacade.class), jenkins);
+ return new PrismConfiguration(mock(GlobalConfigurationFacade.class));
}
}
diff --git a/src/test/resources/io/jenkins/plugins/prism/sourceDirectories.yaml b/src/test/resources/io/jenkins/plugins/prism/sourceDirectories.yaml
index e38dacb..2c7365b 100644
--- a/src/test/resources/io/jenkins/plugins/prism/sourceDirectories.yaml
+++ b/src/test/resources/io/jenkins/plugins/prism/sourceDirectories.yaml
@@ -1,5 +1,5 @@
-unclassified:
- prismConfiguration:
+security:
+ prism:
sourceDirectories:
- path: "C:\\Windows"
- path: "/absolute"
diff --git a/src/test/resources/io/jenkins/plugins/prism/theme.yaml b/src/test/resources/io/jenkins/plugins/prism/theme.yaml
index d9a8a51..096c775 100644
--- a/src/test/resources/io/jenkins/plugins/prism/theme.yaml
+++ b/src/test/resources/io/jenkins/plugins/prism/theme.yaml
@@ -1,3 +1,3 @@
-unclassified:
- prismConfiguration:
+appearance:
+ prism:
theme: "DARK"