(t *testing.T)
| 163 | } |
| 164 | |
| 165 | func 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 | |
| 192 | func TestDSNServerPubKeyQueryEscape(t *testing.T) { |
| 193 | const name = "&%!:" |
nothing calls this directly
no test coverage detected
searching dependent graphs…