MCPcopy
hub / github.com/go-sql-driver/mysql / TestDSNWithCustomTLSQueryEscape

Function TestDSNWithCustomTLSQueryEscape

dsn_test.go:278–294  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

276}
277
278func TestDSNWithCustomTLSQueryEscape(t *testing.T) {
279 const configKey = "&%!:"
280 dsn := "User:password@tcp(localhost:5555)/dbname?tls=" + url.QueryEscape(configKey)
281 name := "foohost"
282 tlsCfg := tls.Config{ServerName: name}
283
284 RegisterTLSConfig(configKey, &tlsCfg)
285 defer DeregisterTLSConfig(configKey)
286
287 cfg, err := ParseDSN(dsn)
288
289 if err != nil {
290 t.Error(err.Error())
291 } else if cfg.TLS.ServerName != name {
292 t.Errorf("did not get the correct TLS ServerName (%s) parsing DSN (%s).", name, dsn)
293 }
294}
295
296func TestDSNUnsafeCollation(t *testing.T) {
297 _, err := ParseDSN("/dbname?collation=gbk_chinese_ci&interpolateParams=true")

Callers

nothing calls this directly

Calls 4

RegisterTLSConfigFunction · 0.85
DeregisterTLSConfigFunction · 0.85
ParseDSNFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected