Skip to content
Permalink
Browse files

Merge pull request #1811 from ikedam/feature/JENKINS-28440_AdditionalFix

[JENKINS-28440] Additional fixes for #1715
  • Loading branch information
jglick committed Aug 31, 2015
2 parents bc2ad1b + 0d54d89 commit 69a98484c8a879fef9532e68670e72f5d74267b7
@@ -29,6 +29,8 @@

/**
* Wraps {@link XStreamException} to indicate it is critical for Jenkins.
*
* @since 1.625
*/
public class CriticalXStreamException extends ConversionException {
private static final long serialVersionUID = 1L;
@@ -24,7 +24,7 @@

package hudson.util;

import hudson.cli.CLI;
import hudson.cli.CLICommandInvoker;
import hudson.diagnosis.OldDataMonitor;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Items;
@@ -37,8 +37,6 @@
import hudson.security.ACL;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;

@@ -274,23 +272,19 @@ public void testCliFailure() throws Exception {

// Configure a bad keyword via CLI.
r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
CLI cli = new CLI(r.getURL());
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
int ret = cli.execute(
Arrays.asList(
"update-job",
p.getFullName(),
"--username",
"test",
"--password",
"test"
),
new ByteArrayInputStream(String.format(CONFIGURATION_TEMPLATE, "badvalue", AcceptOnlySpecificKeyword.ACCEPT_KEYWORD).getBytes()),
stdout,
stderr
);
assertEquals(0, ret);

CLICommandInvoker.Result ret = new CLICommandInvoker(r, "update-job")
.withStdin(new ByteArrayInputStream(String.format(CONFIGURATION_TEMPLATE, "badvalue", AcceptOnlySpecificKeyword.ACCEPT_KEYWORD).getBytes()))
.withArgs(
p.getFullName(),
"--username",
"test",
"--password",
"test"
)
.invoke();

assertEquals(0, ret.returnCode());

// AcceptOnlySpecificKeyword with bad value is not instantiated for rejected with readResolve,
assertNull(p.getProperty(KeywordProperty.class).getNonCriticalField());
@@ -314,23 +308,17 @@ public void testCliFailure() throws Exception {

// Configure a bad keyword via CLI.
r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
CLI cli = new CLI(r.getURL());
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
int ret = cli.execute(
Arrays.asList(
"update-job",
p.getFullName(),
"--username",
"test",
"--password",
"test"
),
new ByteArrayInputStream(String.format(CONFIGURATION_TEMPLATE, AcceptOnlySpecificKeyword.ACCEPT_KEYWORD, "badvalue").getBytes()),
stdout,
stderr
);
assertNotEquals(0, ret);
CLICommandInvoker.Result ret = new CLICommandInvoker(r, "update-job")
.withStdin(new ByteArrayInputStream(String.format(CONFIGURATION_TEMPLATE, AcceptOnlySpecificKeyword.ACCEPT_KEYWORD, "badvalue").getBytes()))
.withArgs(
p.getFullName(),
"--username",
"test",
"--password",
"test"
)
.invoke();
assertNotEquals(0, ret.returnCode());

// Configuration should not be updated for a failure of the critical field,
assertNotEquals("badvalue", p.getProperty(KeywordProperty.class).getCriticalField().getKeyword());

0 comments on commit 69a9848

Please sign in to comment.
You can’t perform that action at this time.