Skip to content

Commit

Permalink
fix tls test
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-r-reis committed Oct 19, 2022
1 parent 01120ce commit c54a1fd
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions integration-tests/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,19 +1057,36 @@ func testProxyClientTls(t *testing.T, ccmSetup *setup.CcmTestSetup,

logMessages := buffer.String()

if !proxyTlsConfig.errExpected || proxyTlsConfig.errMsgExpected == "" { // if we have an errmsg to check, ignore warnings
for _, errWarnExpected := range proxyTlsConfig.errWarningsExpected {
require.True(t, strings.Contains(logMessages, errWarnExpected), "%v not found", errWarnExpected)
warnCheckFail := false
warnCheckDone := false
for _, errWarnExpected := range proxyTlsConfig.errWarningsExpected {
warnCheckDone = true
if !strings.Contains(logMessages, errWarnExpected) {
t.Logf("%v not found in %v", errWarnExpected, logMessages)
warnCheckFail = true
}
}

if proxyTlsConfig.errExpected {
require.NotNil(t, err, "Did not get expected error %s", proxyTlsConfig.errMsgExpected)
errCheckFail := false
errCheckDone := false
if proxyTlsConfig.errMsgExpected != "" {
require.True(t, strings.Contains(err.Error(), proxyTlsConfig.errMsgExpected),
"%v not found in %v", proxyTlsConfig.errMsgExpected, err.Error())
errCheckDone = true
if !strings.Contains(err.Error(), proxyTlsConfig.errMsgExpected) {
errCheckFail = true
t.Logf("%v not found in %v", err.Error(), proxyTlsConfig.errMsgExpected)
}
}
if errCheckDone && warnCheckDone {
require.True(t, !errCheckFail || !warnCheckFail) // only 1 check needs to pass in this scenario
} else if errCheckDone {
require.False(t, errCheckFail)
} else if warnCheckDone {
require.False(t, warnCheckFail)
}
} else {
require.False(t, warnCheckFail)
require.Nil(t, err, "testClient setup failed: %v", err)
// create schema on clusters through the proxy
sendRequest(cqlConn, "CREATE KEYSPACE IF NOT EXISTS testks "+
Expand Down

0 comments on commit c54a1fd

Please sign in to comment.