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

bettertls: test both pathbuilding and nameconstraints. #151

Merged
merged 1 commit into from Aug 14, 2023

Conversation

cpu
Copy link
Member

@cpu cpu commented Aug 11, 2023

Previously (#116) the bettertls test data and runner only included the 'pathbuilding' suite. This commit brings in the remaining 'nameconstraints' tests.

It turns out very little needs to change to also run these tests. In addition to trying path building with verify_for_usage, we also need to perform name verification for the subject indicated in the testcase 'hostname' field with verify_is_valid_for_subject_name. That's about it, the rest is plumbing. :)

One additional point of interest: with the full tests included the vendored JSON was about ~33mb. The Cargo.toml config doesn't include the third-party directory in the packaged crate, but it still felt too large. As a workaround this commit applies bzip2 compression, bringing it down to ~7mb, and updates the test runner to decompresses it on the fly.

@cpu cpu self-assigned this Aug 11, 2023
@codecov
Copy link

codecov bot commented Aug 11, 2023

Codecov Report

Merging #151 (7294be7) into main (91e42a5) will increase coverage by 0.25%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #151      +/-   ##
==========================================
+ Coverage   96.21%   96.46%   +0.25%     
==========================================
  Files          15       15              
  Lines        4304     4304              
==========================================
+ Hits         4141     4152      +11     
+ Misses        163      152      -11     

see 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

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

Great to have better test coverage of the name constraint validation!

Honestly not sure about the compression. The smaller git clone size comes at the expense of making it harder to inspect the test contents, and in my mind git clone size isn't a priority. (Subsequent pulls shouldn't be affected much.)

tests/better_tls.rs Outdated Show resolved Hide resolved
@cpu
Copy link
Member Author

cpu commented Aug 14, 2023

Honestly not sure about the compression. The smaller git clone size comes at the expense of making it harder to inspect the test contents, and in my mind git clone size isn't a priority. (Subsequent pulls shouldn't be affected much.)

That's fair, I don't feel very strongly but I also don't find the raw JSON very helpful for inspection. I suppose it shows the expected pass/fail but otherwise it seems opaque in decompressed form as well since most of the content is base64 certificates.

Copy link
Member

@ctz ctz left a comment

Choose a reason for hiding this comment

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

Pleased to know that this didn't find any latent bugs in name constraints!

It's a bit annoying that the default rust test runner is so low on features, such as runtime test case generation and fixtures. Ideally all these test cases would have names so someone could cargo test them individually. Oh well!

tests/better_tls.rs Outdated Show resolved Hide resolved
@djc
Copy link
Member

djc commented Aug 14, 2023

Honestly not sure about the compression. The smaller git clone size comes at the expense of making it harder to inspect the test contents, and in my mind git clone size isn't a priority. (Subsequent pulls shouldn't be affected much.)

That's fair, I don't feel very strongly but I also don't find the raw JSON very helpful for inspection. I suppose it shows the expected pass/fail but otherwise it seems opaque in decompressed form as well since most of the content is base64 certificates.

Also fair! 🤷

@cpu
Copy link
Member Author

cpu commented Aug 14, 2023

@ctz Do you have an opinion RE: compressing the data file? Should I back that out?

@cpu
Copy link
Member Author

cpu commented Aug 14, 2023

It's a bit annoying that the default rust test runner is so low on features, such as runtime test case generation and fixtures. Ideally all these test cases would have names so someone could cargo test them individually. Oh well!

I do miss the Go test runner's nice support for table driven tests w/ named subtests ☹️

@djc
Copy link
Member

djc commented Aug 14, 2023

Pleased to know that this didn't find any latent bugs in name constraints!

It's a bit annoying that the default rust test runner is so low on features, such as runtime test case generation and fixtures. Ideally all these test cases would have names so someone could cargo test them individually. Oh well!

You can do more with a custom test harness, like here: https://github.com/servo/rust-url/blob/master/url/tests/wpt.rs. I think there are also crates that help with this? Some folks on the Cargo team are investigating making this better, see https://epage.github.io/blog/2023/06/iterating-on-test/.

Previously the bettertls test data and runner only included the
'pathbuilding' suite. This commit brings in the remaining
'nameconstraints' tests.

It turns out very little needs to change to also run these tests. In
addition to trying path building with `verify_for_usage`, we also need
to perform name verification for the subject indicated in the testcase
'hostname' field with `verify_is_valid_for_subject_name`. That's about
it, the rest is plumbing. :)

One additional point of interest: with the full tests included the
vendored JSON was about ~33mb. The `Cargo.toml` config doesn't
include the `third-party` directory in the packaged crate, but it
still felt too large. As a workaround this commit applies bzip2
compression, bringing it down to ~7mb, and updates the test runner to
decompresses it on the fly.
@cpu cpu force-pushed the cpu-bettertls-even-better branch from e94f0d5 to 7294be7 Compare August 14, 2023 12:32
@ctz
Copy link
Member

ctz commented Aug 14, 2023

@ctz Do you have an opinion RE: compressing the data file? Should I back that out?

I'm in favour of compressing it, but for a slightly odd reason -- I use ack a lot and it skips over binary files automatically.

@cpu cpu added this pull request to the merge queue Aug 14, 2023
Merged via the queue into rustls:main with commit eb1a4dd Aug 14, 2023
24 checks passed
@cpu cpu deleted the cpu-bettertls-even-better branch August 14, 2023 12:53
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.

None yet

3 participants