Skip to content

tls: Refactor the ssl socket test#5402

Merged
htuch merged 37 commits intoenvoyproxy:masterfrom
vadimeisenbergibm:refactor_ssl_socket_test
Dec 27, 2018
Merged

tls: Refactor the ssl socket test#5402
htuch merged 37 commits intoenvoyproxy:masterfrom
vadimeisenbergibm:refactor_ssl_socket_test

Conversation

@vadimeisenbergibm
Copy link
Copy Markdown
Contributor

Description: Refactor the ssl socket test - use options objects instead of long parameter lists.
Risk Level: Zero risk
Testing: the test itself
Docs Changes: None
Release Notes:

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
@vadimeisenbergibm vadimeisenbergibm changed the title ssl: Refactor the ssl socket test tls: Refactor the ssl socket test Dec 22, 2018
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
@vadimeisenbergibm vadimeisenbergibm changed the title tls: Refactor the ssl socket test [WIP] tls: Refactor the ssl socket test Dec 22, 2018
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
to match the order in the original call to testUtilV2()

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
This reverts commit 53bbe1e.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
This reverts commit 05f85c5.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
This reverts commit c43b76f.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
This reverts commit cc9a9c5.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
This reverts commit 9ccec68.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
….exit""

This reverts commit 2090ae3.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
This reverts commit c43b76f.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
This reverts commit f02bdb8.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
This reverts commit bcbbe9d.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
This reverts commit 334c2c0.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
This reverts commit 53bbe1e.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
This reverts commit 05f85c5.

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
…ilOptionsV2)

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
…lOptionsV2)

remove the other version of testUtilV2, leave the version with options only
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
@vadimeisenbergibm vadimeisenbergibm changed the title [WIP] tls: Refactor the ssl socket test tls: Refactor the ssl socket test Dec 23, 2018
@vadimeisenbergibm
Copy link
Copy Markdown
Contributor Author

@htuch Following your comment #4973 (comment)

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks @vadimeisenbergibm! This is a really nice cleanup!

: expected_server_stats_(expected_server_stats), expect_success_(expect_success),
version_(version) {}

void expectedClientCertURI(const std::string& expected_client_cert_uri) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: can you prefix all these mutators with set, e.g. setExpectedClientCertUri? I think this will improve readability a bit.

: TestUtilOptionsBase(expected_server_stats, expect_success, version),
client_ctx_yaml_(client_ctx_yaml), server_ctx_yaml_(server_ctx_yaml) {}

const std::string& clientCtxYAML() const { return client_ctx_yaml_; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Envoy style is clientCtxtYaml.

}

const std::string& expectedClientCertURI() const {
return TestUtilOptionsBase::expectedClientCertURI();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You need to implement this method if it's just the same as in the parent class.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@htuch I guess you mean "You need not to implement". Currently, it is needed because the setter version of expectedClientCertURI() overrides the version of the parent class, so all the versions of expectedClientCertURI() are not inherited and have to be implemented, as far as I understand it.

Anyway, I will rename the setter to be setExpectedClientCertUri(), so the getter will be inherited from the parent class.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SGTM

}

TestUtilOptions& expectedDigest(const std::string& expected_digest) {
expected_digest_ = expected_digest;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: as above, setExpectedDigest() etc.

// The SAN field only has DNS, expect "" for uriSanPeerCertificate().
testUtil(client_ctx_yaml, server_ctx_yaml, "", "", "", TEST_SAN_DNS_CERT_SERIAL, "", "", "",
"ssl.handshake", true, GetParam());
TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, "ssl.handshake", true, GetParam());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's still 5 params here, which is getting a little long, could some of these be switched to the builder pattern, or are they all compulsory?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@htuch I can switch all the parameters to be set by setters, however it will produce longer code at the call sites. How about leaving four parameters in the constructor, for TestUtilOptions and TestUtilOptionsV2? It will be client ctx, server ctx, expected_success and version. "ssl.handshake" can be set by default for client and server stats.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SGTM, thanks.

@htuch htuch self-assigned this Dec 24, 2018
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
it is inherited from the base class
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
…ificate

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
@vadimeisenbergibm
Copy link
Copy Markdown
Contributor Author

@htuch I have applied your comments. asan seems to fail on an unrelated test.

Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Nice cleanup.

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🔨 rebuilding ci/circleci: asan (failed build)

🐱

Caused by: a #5402 (review) was submitted by @lizan.

see: more, trace.

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks, this is a really nice cleanup!

@htuch htuch merged commit 2f77974 into envoyproxy:master Dec 27, 2018
if (expect_success) {
setExpectedServerStats("ssl.handshake");
} else {
setExpectedServerStats("ssl.fail_verify_error");
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.

I know this is merged already, but... why is this the default in case of failure instead of ssl.connection_error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because for testUtil this is the server stats in all the cases when expect_success is false, and for testUtilV2 it has the same number of cases as ssl.connection_error. If you think the default value is important, I can change it in a new PR.

if (expect_success) {
setExpectedServerStats("ssl.handshake").setExpectedClientStats("ssl.handshake");
} else {
setExpectedServerStats("ssl.fail_verify_error")
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.

Same here.


// Connection using defaults (client & server) succeeds.
testUtilV2(listener, client, "", true, "", "", "spiffe://lyft.com/test-team", "", "",
"ssl.sigalgs.rsa_pss_rsae_sha256", "ssl.sigalgs.ecdsa_secp256r1_sha256", GetParam(),
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.

I know this is merged already, but... you removed the only thing that's tested here (ssl.sigalgs.* stats).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@PiotrSikora Oops, let me put it back in a separate PR, sorry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@PiotrSikora Submitted an additional PR to fix it #5429. Good catch!
I will go over all the tests and recheck the stats. More comments are welcome.

fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
Refactor the ssl socket test - use options objects instead of long parameter lists.

Risk Level: Zero risk
Testing: the test itself
Docs Changes: None

Signed-off-by: Vadim Eisenberg <vadime@il.ibm.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
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.

4 participants