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

Reconsider TLS unit tests #133

Merged
merged 1 commit into from
Apr 26, 2023
Merged

Reconsider TLS unit tests #133

merged 1 commit into from
Apr 26, 2023

Conversation

doodlesbykumbi
Copy link
Contributor

@doodlesbykumbi doodlesbykumbi commented Apr 24, 2023

Desired Outcome

The general idea is to NOT rely on external TLS endpoints to validate TLS behaviours

  1. httptest provides a server with a self signed cert
  2. The difference between self-signed and non self-signed certs seems to be limited to whether or not the cert pool contains the signing certificate. That means the cert/cert pool can be dependency injected and manipulated to give us one or the other scenario

Implemented Changes

Describe how the desired outcome above has been achieved with this PR. In
particular, consider:

  • What's changed? Why were these changes made?
  • How should the reviewer approach this PR, especially if manual tests are required?
  • Are there relevant screenshots you can add to the PR description?

Connected Issue/Story

CyberArk internal issue ID: CNJR-472

Definition of Done

At least 1 todo must be completed in the sections below for the PR to be
merged.

Changelog

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a
    CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code
    changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR
  • A follow-up issue to update official docs has been filed here: [insert issue ID]
  • This PR does not require updating any documentation

Behavior

  • This PR changes product behavior and has been reviewed by a PO, or
  • These changes are part of a larger initiative that will be reviewed later, or
  • No behavior was changed with this PR

Security

  • Security architect has reviewed the changes in this PR,
  • These changes are part of a larger initiative with a separate security review, or
  • There are no security aspects to these changes

@szh szh force-pushed the tls-tests branch 2 times, most recently from 5b9382d to 7dbb999 Compare April 24, 2023 18:47
@szh szh self-assigned this Apr 24, 2023
@szh szh marked this pull request as ready for review April 24, 2023 19:00
@szh szh requested a review from a team as a code owner April 24, 2023 19:00
Comment on lines 409 to 413
func startSelfSignedServer(t *testing.T, port int) func() {
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, client")
}))
l, err := net.Listen("tcp", "localhost:8080")
Copy link
Contributor

Choose a reason for hiding this comment

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

This bit is hardcoding 8080 instead of using the port parameter.

@codeclimate
Copy link

codeclimate bot commented Apr 25, 2023

Code Climate has analyzed commit d7afec6 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 82.2% (0.0% change).

View more on Code Climate.

@szh szh merged commit 980d3fc into master Apr 26, 2023
@szh szh deleted the tls-tests branch April 26, 2023 14:48
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.

3 participants