Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Jenkins 2.235 #22

Merged
merged 2 commits into from
Jun 10, 2020

Conversation

Vlatombe
Copy link
Member

@Vlatombe Vlatombe commented Jun 8, 2020

Subsumes #21

Newer Jenkins pulls commons-codec 1.14 (from 1.12) which has slightly
different exception raised when certificate is invalid.

Test with
mvn test -Djenkins.version=2.235

Without the fix, you get the following error

Error Message
Unexpected exception, expected<org.jenkinsci.plugins.kubernetes.credentials.HttpClientWithTLSOptionsFactory$TLSConfigurationError> but was<java.lang.IllegalArgumentException>
Stacktrace
java.lang.Exception: Unexpected exception, expected<org.jenkinsci.plugins.kubernetes.credentials.HttpClientWithTLSOptionsFactory$TLSConfigurationError> but was<java.lang.IllegalArgumentException>
	at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:28)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:272)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:236)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:386)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:323)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:143)
Caused by: java.lang.IllegalArgumentException: Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible value. Expected the discarded bits to be zero.
	at org.apache.commons.codec.binary.Base64.validateCharacter(Base64.java:803)
	at org.apache.commons.codec.binary.Base64.decode(Base64.java:482)
	at org.apache.commons.codec.binary.BaseNCodecInputStream.read(BaseNCodecInputStream.java:163)
	at org.apache.commons.codec.binary.BaseNCodecInputStream.read(BaseNCodecInputStream.java:99)
	at sun.security.provider.X509Factory.readOneBlock(X509Factory.java:563)
	at sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:96)
	at java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:339)
	at org.jenkinsci.plugins.kubernetes.credentials.HttpClientWithTLSOptionsFactory.loadFromString(HttpClientWithTLSOptionsFactory.java:56)
	at org.jenkinsci.plugins.kubernetes.credentials.HttpClientWithTLSOptionsFactory.getVerifyCertSSLFactory(HttpClientWithTLSOptionsFactory.java:76)
	at org.jenkinsci.plugins.kubernetes.credentials.HttpClientWithTLSOptionsFactory.getBuilder(HttpClientWithTLSOptionsFactory.java:88)
	at org.jenkinsci.plugins.kubernetes.credentials.HttpClientWithTLSOptionsFactoryTest.testThrowAnErrorOnInvalidCertificate(HttpClientWithTLSOptionsFactoryTest.java:21)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:19)
	... 16 more

Newer Jenkins pulls commons-codec 1.14 (from 1.12) which has slightly
different exception raised when certificate is invalid
@Vlatombe
Copy link
Member Author

Vlatombe commented Jun 9, 2020

@maxlaverse can you review this?

@maxlaverse
Copy link

You probably know that better than me but it looks good. Thanks

@maxlaverse maxlaverse merged commit c617702 into jenkinsci:master Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants