Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-32376] Changed the target to the least LTS 1.596.
- Loading branch information
Showing
6 changed files
with
114 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 21 additions & 12 deletions
33
...ikedam/jenkins/plugins/updatesitesmanager/internal/ExtendedCertJsonSignValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,38 @@ | ||
package jp.ikedam.jenkins.plugins.updatesitesmanager.internal; | ||
|
||
import net.sf.json.JSONObject; | ||
|
||
import org.apache.commons.io.Charsets; | ||
import org.apache.commons.io.IOUtils; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import java.security.cert.CertificateFactory; | ||
import java.security.cert.TrustAnchor; | ||
import java.util.Set; | ||
import hudson.util.FormValidation; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import jenkins.util.JSONSignatureValidator; | ||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* @author lanwen (Merkushev Kirill) | ||
*/ | ||
public class ExtendedCertJsonSignValidatorTest { | ||
|
||
@ClassRule | ||
public static JenkinsRule j = new JenkinsRule(); | ||
|
||
@Test | ||
public void shouldAddCustomCertToTrustAnchors() throws Exception { | ||
String RESOURCE_BASE = "jp/ikedam/jenkins/plugins/updatesitesmanager/ManagedUpdateSiteJenkinsTest"; | ||
|
||
String cert = IOUtils.toString(getClass().getClassLoader() | ||
.getResourceAsStream("jp/ikedam/jenkins/plugins/updatesitesmanager/" + | ||
"ManagedUpdateSiteJenkinsTest/caCertificate.crt"), Charsets.UTF_8); | ||
CertificateFactory cf = CertificateFactory.getInstance("X509"); | ||
|
||
Set<TrustAnchor> test = new ExtendedCertJsonSignValidator("test", cert).loadTrustAnchors(cf); | ||
assertThat(test, hasSize(1)); | ||
.getResourceAsStream(RESOURCE_BASE + "/caCertificate.crt"), Charsets.UTF_8); | ||
JSONSignatureValidator validator = new ExtendedCertJsonSignValidator("test", cert); | ||
//JSONSignatureValidator validator = new JSONSignatureValidator("test"); | ||
JSONObject ucToTest = JSONObject.fromObject(IOUtils.toString( | ||
getClass().getClassLoader().getResourceAsStream(RESOURCE_BASE + "/update-center.json"), | ||
Charsets.UTF_8 | ||
)); | ||
assertEquals(FormValidation.Kind.OK, validator.verifySignature(ucToTest).kind); | ||
} | ||
} | ||
} |