"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/src/test/java/hudson/model/FreeStyleProjectTest.java" between
jenkins-jenkins-2.280.tar.gz and jenkins-jenkins-2.281.tar.gz

About: Jenkins is a automation server (written in Java) which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software (for e.g. as Continuous Integration and Continuous Delivery server). Weekly release.

FreeStyleProjectTest.java  (jenkins-jenkins-2.280):FreeStyleProjectTest.java  (jenkins-jenkins-2.281)
skipping to change at line 26 skipping to change at line 26
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package hudson.model; package hudson.model;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNotSame;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.ExtensionList;
import hudson.diagnosis.OldDataMonitor;
import hudson.tasks.Builder; import hudson.tasks.Builder;
import hudson.tasks.Shell; import hudson.tasks.Shell;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import jenkins.model.Jenkins;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
import org.jvnet.hudson.test.FailureBuilder; import org.jvnet.hudson.test.FailureBuilder;
import org.jvnet.hudson.test.Issue; import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.JenkinsRule.WebClient; import org.jvnet.hudson.test.JenkinsRule.WebClient;
import org.jvnet.hudson.test.MockAuthorizationStrategy;
import org.jvnet.hudson.test.SmokeTest; import org.jvnet.hudson.test.SmokeTest;
import java.util.List; import java.util.List;
import java.io.File; import java.io.File;
import java.util.Map;
/** /**
* @author Kohsuke Kawaguchi * @author Kohsuke Kawaguchi
*/ */
@Category(SmokeTest.class) @Category(SmokeTest.class)
public class FreeStyleProjectTest { public class FreeStyleProjectTest {
@Rule @Rule
public JenkinsRule j = new JenkinsRule(); public JenkinsRule j = new JenkinsRule();
skipping to change at line 155 skipping to change at line 166
expectedFails++; expectedFails++;
} }
} }
p.scheduleBuild2(0).get(); p.scheduleBuild2(0).get();
} }
HealthReport health = p.getBuildHealth(); HealthReport health = p.getBuildHealth();
assertThat(String.format("Pattern %s score", Integer.toBinaryString( i)), health.getScore(), is(100*(5-expectedFails)/5)); assertThat(String.format("Pattern %s score", Integer.toBinaryString( i)), health.getScore(), is(100*(5-expectedFails)/5));
} }
} }
@Issue("SECURITY-1923")
@Test
public void configDotXmlWithValidXmlAndBadField() throws Exception {
final String CONFIGURATOR = "configure_user";
j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
MockAuthorizationStrategy mas = new MockAuthorizationStrategy();
mas.grant(Item.CONFIGURE, Item.READ, Jenkins.READ)
.everywhere()
.to(CONFIGURATOR);
j.jenkins.setAuthorizationStrategy(mas);
FreeStyleProject project = j.createFreeStyleProject();
JenkinsRule.WebClient wc = j.createWebClient();
wc.login(CONFIGURATOR);
WebRequest req = new WebRequest(wc.createCrumbedUrl(String.format("%s/co
nfig.xml", project.getUrl())), HttpMethod.POST);
req.setAdditionalHeader("Content-Type", "application/xml");
req.setRequestBody(VALID_XML_BAD_FIELD_USER_XML);
try {
wc.getPage(req);
fail("Should have returned failure.");
} catch (FailingHttpStatusCodeException e) {
// This really shouldn't return 500, but that's what it does now.
assertThat(e.getStatusCode(), equalTo(500));
}
OldDataMonitor odm = ExtensionList.lookupSingleton(OldDataMonitor.class)
;
Map<Saveable, OldDataMonitor.VersionRange> data = odm.getData();
assertThat(data.size(), equalTo(0));
odm.doDiscard(null, null);
User.AllUsers.scanAll();
boolean createUser = false;
User badUser = User.getById("foo", createUser);
assertNull("Should not have created user.", badUser);
}
private static final String VALID_XML_BAD_FIELD_USER_XML =
"<hudson.model.User>\n" +
" <id>foo</id>\n" +
" <fullName>Foo User</fullName>\n" +
" <badField/>\n" +
"</hudson.model.User>\n";
} }
 End of changes. 8 change blocks. 
0 lines changed or deleted 62 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)