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

Function TestDSNServerPubKey

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

Source from the content-addressed store, hash-verified

163}
164
165func TestDSNServerPubKey(t *testing.T) {
166 baseDSN := "User:password@tcp(localhost:5555)/dbname?serverPubKey="
167
168 RegisterServerPubKey("testKey", testPubKeyRSA)
169 defer DeregisterServerPubKey("testKey")
170
171 tst := baseDSN + "testKey"
172 cfg, err := ParseDSN(tst)
173 if err != nil {
174 t.Error(err.Error())
175 }
176
177 if cfg.ServerPubKey != "testKey" {
178 t.Errorf("unexpected cfg.ServerPubKey value: %v", cfg.ServerPubKey)
179 }
180 if cfg.pubKey != testPubKeyRSA {
181 t.Error("pub key pointer doesn't match")
182 }
183
184 // Key is missing
185 tst = baseDSN + "invalid_name"
186 cfg, err = ParseDSN(tst)
187 if err == nil {
188 t.Errorf("invalid name in DSN (%s) but did not error. Got config: %#v", tst, cfg)
189 }
190}
191
192func TestDSNServerPubKeyQueryEscape(t *testing.T) {
193 const name = "&%!:"

Callers

nothing calls this directly

Calls 4

RegisterServerPubKeyFunction · 0.85
DeregisterServerPubKeyFunction · 0.85
ParseDSNFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…