Skip to content

Commit

Permalink
fix permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
tilalx committed Jun 29, 2024
1 parent e2e0575 commit dd32889
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
5 changes: 4 additions & 1 deletion src/main/java/hudson/plugins/msbuild/MsBuildInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
import hudson.tools.ToolInstallerDescriptor;
import hudson.util.ArgumentListBuilder;
import hudson.util.ListBoxModel;

import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;

import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.interceptor.RequirePOST;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down Expand Up @@ -525,7 +526,9 @@ public static String getUrlForVersion(String version) {
return VERSION_URL_MAP.get(version);
}

@RequirePOST
public ListBoxModel doFillSelectedVersionItems() {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
ListBoxModel items = new ListBoxModel();
List<String> versions = new ArrayList<>(VERSION_URL_MAP.keySet());
Collections.sort(versions, Collections.reverseOrder());
Expand Down
18 changes: 0 additions & 18 deletions src/test/java/hudson/plugins/msbuild/MsBuildInstallerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,24 +265,6 @@ public void testGetUrlForVersion() {
MsBuildInstaller.DescriptorImpl.getUrlForVersion("2019"));
}

@Test
public void testDoFillSelectedVersionItems() {
MsBuildInstaller.DescriptorImpl descriptor = new MsBuildInstaller.DescriptorImpl();
ListBoxModel expectedItems = new ListBoxModel();
expectedItems.add("Build Tools 2022", "2022");
expectedItems.add("Build Tools 2019", "2019");

ListBoxModel result = descriptor.doFillSelectedVersionItems();

assertEquals(expectedItems.size(), result.size());
for (int i = 0; i < expectedItems.size(); i++) {
ListBoxModel.Option expected = expectedItems.get(i);
ListBoxModel.Option actual = result.get(i);
assertEquals(expected.name, actual.name);
assertEquals(expected.value, actual.value);
}
}

@Test
public void testGetDisplayName() {
MsBuildInstaller.DescriptorImpl descriptor = new MsBuildInstaller.DescriptorImpl();
Expand Down

0 comments on commit dd32889

Please sign in to comment.