test: pin static testing policies to numbered versions #4845
+309
−175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
Currently, a new s2n_config object is configured with one of three static configs based on runtime settings and testing overrides.
The security policy selection depends on testing override function calls and makes use of the "default" and "default_fips" policies.
As we attempt to evolve the default* policies, maintaining the current behavior becomes cumbersome. Specifically, along with adding TLS1.3 support to the "default" policy, we will also add a new test which temporarily set the "default" to TLS1.2. This "toggling" of the "default" policy will make the current config selection very complicated.
Description of changes:
To solve this issue, this PR creates dedicated static configs for testing override and pins them to numbered policies rather than rely on the "default" policy.
The cost of this strategy is 2 additional static configs, however, since these are only used in testing, we are able to avoid extra costs of the
s2n_config_load_system_certs
by gating initialization of test configs behind as2n_in_unit_test
check.Callout:
I have made other refactor changes to make reasoning about testing overrides and policy selection easier to reason about:
s2n_default_security_policy_selection
ands2n_testing_security_policy_override
s2n_config_testing_defaults_init_tls13_certs
: was used to avoid the costs ofs2n_config_load_system_certs
, however we can fully avoid the costs by gating initialization to unit tests.Testing:
Added unit testing with and without the testing overrides.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.