MCPcopy Index your code
hub / github.com/go-sql-driver/mysql / TestTLS

Function TestTLS

driver_test.go:1481–1521  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1479}
1480
1481func TestTLS(t *testing.T) {
1482 tlsTestReq := func(dbt *DBTest) {
1483 if err := dbt.db.Ping(); err != nil {
1484 if err == ErrNoTLS {
1485 dbt.Skip("server does not support TLS")
1486 } else {
1487 dbt.Fatalf("error on Ping: %s", err.Error())
1488 }
1489 }
1490
1491 rows := dbt.mustQuery("SHOW STATUS LIKE 'Ssl_cipher'")
1492 defer rows.Close()
1493
1494 var variable, value *sql.RawBytes
1495 for rows.Next() {
1496 if err := rows.Scan(&variable, &value); err != nil {
1497 dbt.Fatal(err.Error())
1498 }
1499
1500 if len(*value) == 0 {
1501 dbt.Fatalf("no Cipher")
1502 } else {
1503 dbt.Logf("Cipher: %s", *value)
1504 }
1505 }
1506 }
1507 tlsTestOpt := func(dbt *DBTest) {
1508 if err := dbt.db.Ping(); err != nil {
1509 dbt.Fatalf("error on Ping: %s", err.Error())
1510 }
1511 }
1512
1513 runTests(t, dsn+"&tls=preferred", tlsTestOpt)
1514 runTests(t, dsn+"&tls=skip-verify", tlsTestReq)
1515
1516 // Verify that registering / using a custom cfg works
1517 RegisterTLSConfig("custom-skip-verify", &tls.Config{
1518 InsecureSkipVerify: true,
1519 })
1520 runTests(t, dsn+"&tls=custom-skip-verify", tlsTestReq)
1521}
1522
1523func TestReuseClosedConnection(t *testing.T) {
1524 // this test does not use sql.database, it uses the driver directly

Callers

nothing calls this directly

Calls 8

runTestsFunction · 0.85
RegisterTLSConfigFunction · 0.85
PingMethod · 0.80
mustQueryMethod · 0.80
ScanMethod · 0.80
ErrorMethod · 0.45
CloseMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…