Skip to content

Ssl: improve tests - #551

Merged
schlessera merged 12 commits into
developfrom
feature/ssl-improve-tests
Sep 23, 2021
Merged

Ssl: improve tests#551
schlessera merged 12 commits into
developfrom
feature/ssl-improve-tests

Conversation

@jrfnl

@jrfnl jrfnl commented Sep 17, 2021

Copy link
Copy Markdown
Member

SslTest: rearrange the method order in the test class

... grouping tests using the same data provider together, with the data provider they are using directly below it.

SslTest: improve "match" tests

  • Add docblock documentation to the tests and the data provider.
  • Use same parameter names in the test method, as used in the functions under test.
  • Rename the data provider method to match the test name(s) it applies to.
  • Remove static keyword from data provider.
  • Used named datasets and keyed data entries in the data provider

SslTest: improve "no-match" tests

  • Add docblock documentation to the tests and the data provider.
  • Use same parameter names in the test method, as used in the functions under test.
  • Rename the data provider method to match the test name(s) it applies to.
  • Remove static keyword from data provider.
  • Used named datasets and keyed data entries in the data provider

SslTest: add extra "no-match" test cases

... to cover a previously uncovered code path and safeguard against regressions.

SslTest: refactor additional verify_certificate() tests

Merge two additional tests into the base test methods.

As these additional methods are specific to the verify_certificate() method and do not apply to the match_domain() method, they are placed in separate data providers (yes, you can have multiple data providers for one test), but having them in a data provider allows for more easily adding more additional test cases at a later point in time.

I'm leaving the SslTest::testIgnoreCNWithSAN() test method in place as that's testing something very specific and the test method documentation explains that case well.

SslTest::fakeCertificate(): make test helper a little more flexible

... to allow for testing more edge cases.

SslTest: add extra "no-match" test cases specifically for verify_certificate()

... to cover a previously uncovered code path and safeguard against regressions.

Ssl::verify_certificate(): remove unnecessary condition

No need to check whether $cert['extensions'] is empty if we're going to check if $cert['extensions']['subjectAltName'] is empty anyway.

See: https://3v4l.org/Z1hgQ

Ssl::verify_certificate(): minor code tweaks

... to reduce the number of possible paths which can be taken through the function / lower complexity.

SslTest: add docblock to helper function

SslTest: add @Covers tags

Related to #497

... grouping tests using the same data provider together, with the data provider they are using directly below it.
* Add docblock documentation to the tests and the data provider.
* Use same parameter names in the test method, as used in the functions under test.
* Rename the data provider method to match the test name(s) it applies to.
* Remove `static` keyword from data provider.
* Used named datasets and keyed data entries in the data provider
* Add docblock documentation to the tests and the data provider.
* Use same parameter names in the test method, as used in the functions under test.
* Rename the data provider method to match the test name(s) it applies to.
* Remove `static` keyword from data provider.
* Used named datasets and keyed data entries in the data provider
... to cover a previously uncovered code path and safeguard against regressions.
Merge two additional tests into the base test methods.

As these additional methods are specific to the `verify_certificate()` method and do not apply to the `match_domain()` method, they are placed in separate data providers (yes, you can have multiple data providers for one test), but having them in a data provider allows for more easily adding more additional test cases at a later point in time.

I'm leaving the `SslTest::testIgnoreCNWithSAN()` test method in place as that's testing something very specific and the test method documentation explains that case well.
…tificate()`

... to cover a previously uncovered code path and safeguard against regressions.
No need to check whether `$cert['extensions']` is empty if we're going to check if `$cert['extensions']['subjectAltName']` is empty anyway.

See: https://3v4l.org/Z1hgQ
... to reduce the number of possible paths which can be taken through the function / lower complexity.
@jrfnl jrfnl added this to the 2.0.0 milestone Sep 17, 2021
@jrfnl
jrfnl requested a review from schlessera September 17, 2021 12:32
@jrfnl jrfnl changed the title SslTest: improve tests Ssl: improve tests Sep 17, 2021
@schlessera
schlessera merged commit 2415594 into develop Sep 23, 2021
@schlessera
schlessera deleted the feature/ssl-improve-tests branch September 23, 2021 09:56
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