@@ -0,0 +1,2681 @@
+package com.cloudbees.jenkins;%0A%0Aimport com.gargoylesoftware.htmlunit.html.HtmlForm;%0Aimport com.gargoylesoftware.htmlunit.html.HtmlPage;%0Aimport hudson.util.Secret;%0Aimport java.net.URL;%0Aimport java.util.List;%0Aimport org.jvnet.hudson.test.HudsonTestCase;%0Aimport org.kohsuke.stapler.Stapler;%0A%0A/**%0A * Test Class for %7B@link GitHubPushTrigger%7D.%0A *%0A * @author Seiji Sogabe%0A */%0Apublic class GitHubPushTriggerConfigSubmitTest extends HudsonTestCase %7B%0A%0A    private static final String WEBHOOK_URL = %22http://jenkinsci.example.com/jenkins/github-webhook/%22;%0A%0A    public void testConfigSubmit_AutoManageHook() throws Exception %7B%0A%0A        WebClient client = configureWebClient();%0A        HtmlPage p = client.goTo(%22configure%22);%0A        HtmlForm f = p.getFormByName(%22config%22);%0A        f.getInputByValue(%22auto%22).setChecked(true);%0A        f.getInputByName(%22_.hookUrl%22).setChecked(true);%0A        f.getInputByName(%22url%22).setValueAttribute(WEBHOOK_URL);%0A        f.getInputByName(%22_.username%22).setValueAttribute(%22jenkins%22);%0A        f.getInputByName(%22_.password%22).setValueAttribute(%22password%22);%0A        submit(f);%0A%0A        GitHubPushTrigger.DescriptorImpl d = getDescriptor();%0A        assertTrue(d.isManageHook());%0A        assertEquals(new URL(WEBHOOK_URL), d.getHookUrl());%0A%0A        List%3CCredential%3E credentials = d.getCredentials();%0A        assertNotNull(credentials);%0A        assertEquals(1, credentials.size());%0A        Credential credential = credentials.get(0);%0A        assertEquals(%22jenkins%22, credential.username);%0A        assertEquals(%22password%22, Secret.toString(credential.password));%0A    %7D%0A%0A    public void testConfigSubmit_ManuallyManageHook() throws Exception %7B%0A%0A        WebClient client = configureWebClient();%0A        HtmlPage p = client.goTo(%22configure%22);%0A        HtmlForm f = p.getFormByName(%22config%22);%0A        f.getInputByValue(%22none%22).setChecked(true);%0A        submit(f);%0A%0A        GitHubPushTrigger.DescriptorImpl d = getDescriptor();%0A        assertFalse(d.isManageHook());%0A    %7D%0A%0A    private GitHubPushTrigger.DescriptorImpl getDescriptor() %7B%0A        return (GitHubPushTrigger.DescriptorImpl) GitHubPushTrigger.DescriptorImpl.get();%0A    %7D%0A%0A    private WebClient configureWebClient() %7B%0A        WebClient client = new WebClient();%0A        client.setThrowExceptionOnFailingStatusCode(false);%0A        client.setCssEnabled(false);%0A        client.setJavaScriptEnabled(true);%0A        return client;%0A    %7D%0A%0A    // workaround%0A    static %7B%0A        Stapler.CONVERT_UTILS.register(new org.apache.commons.beanutils.Converter() %7B%0A%0A            public Secret convert(Class type, Object value) %7B%0A                return Secret.fromString(value.toString());%0A            %7D%0A        %7D, Secret.class);%0A    %7D%0A%7D%0A

test for 64482a8ab8492ccc4c3e6d7dfd723e7cbb593847.