Skip to content

Run unit tests on push#2

Merged
bastelfreak merged 9 commits into
mainfrom
run-unit-tests
Jul 8, 2025
Merged

Run unit tests on push#2
bastelfreak merged 9 commits into
mainfrom
run-unit-tests

Conversation

@smortex
Copy link
Copy Markdown
Member

@smortex smortex commented Jun 29, 2025

The project has some decorative unit tests. If we run them, they are not
decorative anymore and can help spot regressions.

smortex added 6 commits June 28, 2025 18:08
The project has some decorative unit tests. If we run them, they are not
decorative anymore and can help spot regressions.
The OpenVox Server default hostname is `puppet`, not `localhost`.
The test suite now pass on Linux, but fails on windows.  Maybe comparing
bundles will help stop the root cause of the issue.
Fix this warning from jRuby:
```
OpenSSL::X509::Request#version= has no effect on certification request
```
While MRI ruby/openssl seems to have no issue with OID vs. friendly name,
jruby/jruby-openssl raise an exception when passed these OIDs as String:

        Java::JavaLang::NullPointerException:
          'element' cannot be null
        # org.bouncycastle.asn1.ASN1EncodableVector.add(Unknown Source)
        # org.jruby.ext.openssl.X509ExtensionFactory.parseExtendedKeyUsage(X509ExtensionFactory.java:608)
        # org.jruby.ext.openssl.X509ExtensionFactory.create_ext(X509ExtensionFactory.java:200)
        # org.jruby.ext.openssl.X509ExtensionFactory.create_extension(X509ExtensionFactory.java:216)
        # org.jruby.ext.openssl.X509ExtensionFactory$INVOKER$i$0$0$create_extension.call(X509ExtensionFactory$INVOKER$i$0$0$create_extension.gen)
        # org.jruby.dist/org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:847)
        [... 200 lines of Java backtrace ...]
        # org.jruby.dist/org.jruby.Ruby.runScript(Ruby.java:1245)
        # org.jruby.dist/org.jruby.Ruby.runNormally(Ruby.java:1157)
        # org.jruby.dist/org.jruby.Ruby.runFromMain(Ruby.java:983)
        # org.jruby.dist/org.jruby.Main.doRunFromMain(Main.java:398)
        # org.jruby.dist/org.jruby.Main.internalRun(Main.java:282)
        # org.jruby.dist/org.jruby.Main.run(Main.java:227)
        # org.jruby.dist/org.jruby.Main.main(Main.java:199)

Pass the corresponding friendly names instead of OIDs to fix this issue.
When creating a CRL from scratch, the internal state of the CRL is
incorrect when calling #to_pem, resulting in an invalid CRL.  A bunch of
tests are failing because of this.

Implement a workaround by serializing the CRL to der format and use that
to initialize a new CRL object.
@smortex smortex force-pushed the run-unit-tests branch 4 times, most recently from 4f7e06c to da736e6 Compare June 30, 2025 04:06
Updating extensions in-place does not work with all Ruby
implementations.  Moreover, building a `crlNumber` extension does not
work the same way on MRI and jruby, its bugs all the way down :-(.

The first issue was already encountered with MRI:
https://github.com/smortex/puppet-renew-certificate/blob/761d5e768933aae0233e77aeac4aea01d3fd2fa8/exe/puppet-renew-certificate#L125

So, play safe: remove extensions and re-create them one by one instead
of trying to update them in-place.  Also check what implementation of
Ruby we are running to add the `crlNumber` as pleased the current
ruby virtual machine.
smortex added a commit that referenced this pull request Jun 30, 2025
Test workflows has been voluntarily skiped because they are currently
being worked on in another issue (#2).
smortex added 2 commits July 2, 2025 16:26
The code would need to be adjusted to support windows, but as the
OpenVox Server does not support windows, it is not worth working on it
at the moment.

This commit can be reverted when we decide to ship OpenVox Server for
windows.
ruby/openssl and jruby/jruby-openssl have slightly different
interfaces, and supporting both would require more adjustments, but as
the openvoxservec ca command run in the context of MRI, we do not depend
on this work for now.

This commit can be reverted if we want to run the code on jruby.
@smortex
Copy link
Copy Markdown
Member Author

smortex commented Jul 3, 2025

So, I finally added a pair of commits to skip non-working environments (windows, jruby). If we decide to run on them, we can revert these commits. For now we only test with MRI, that is the only environment supported by OpenVox Server for now.

@smortex smortex marked this pull request as ready for review July 3, 2025 02:32
csr = OpenSSL::X509::Request.new
csr.public_key = key.public_key
csr.subject = OpenSSL::X509::Name.new([["CN", name]])
csr.version = 2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the Impact of this Change? I am a bit lost Here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jruby-openssl produce warnings for non-critical issues it detects. In this case, it complain that we set a version in a CSR while this parameter is ignored:

https://github.com/jruby/jruby-openssl/blob/de0d96c189c29e4f7668e3943d678696e7d7e3c3/src/main/java/org/jruby/ext/openssl/X509Request.java#L253 (current warning)

https://github.com/jruby/jruby-openssl/blame/01e12c17698bef4d7671a795d30e1c368d02b848/src/main/java/org/jruby/ext/openssl/X509Request.java#L227 (initial introduction)

@bastelfreak bastelfreak merged commit 1330d5d into main Jul 8, 2025
7 checks passed
@smortex smortex deleted the run-unit-tests branch July 8, 2025 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants