Skip to content

Commit

Permalink
Removed bogus user password test (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-astachowski committed Aug 2, 2024
1 parent 52bb7bc commit 5f31c16
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,43 +469,6 @@ func runningOnGCP() bool {
return os.Getenv("CLOUD_PROVIDER") == "GCP"
}

func TestBogusUserPasswordParameters(t *testing.T) {
invalidDNS := fmt.Sprintf("%s:%s@%s", "bogus", pass, host)
invalidUserPassErrorTests(invalidDNS, t)
invalidDNS = fmt.Sprintf("%s:%s@%s", username, "INVALID_PASSWORD", host)
invalidUserPassErrorTests(invalidDNS, t)
}

func invalidUserPassErrorTests(invalidDNS string, t *testing.T) {
parameters := url.Values{}
if protocol != "" {
parameters.Add("protocol", protocol)
}
if account != "" {
parameters.Add("account", account)
}
invalidDNS += "?" + parameters.Encode()
db, err := sql.Open("snowflake", invalidDNS)
if err != nil {
t.Fatalf("error creating a connection object: %s", err.Error())
}
// actual connection won't happen until run a query
defer db.Close()
if _, err = db.Exec("SELECT 1"); err == nil {
t.Fatal("should cause an error.")
}
if driverErr, ok := err.(*SnowflakeError); ok {
if driverErr.Number != 390100 {
t.Fatalf("wrong error code: %v", driverErr)
}
if !strings.Contains(driverErr.Error(), "390100") {
t.Fatalf("error message should included the error code. got: %v", driverErr.Error())
}
} else {
t.Fatalf("wrong error code: %v", err)
}
}

func TestBogusHostNameParameters(t *testing.T) {
invalidDNS := fmt.Sprintf("%s:%s@%s", username, pass, "INVALID_HOST:1234")
invalidHostErrorTests(invalidDNS, []string{"no such host", "verify account name is correct", "HTTP Status: 403", "Temporary failure in name resolution", "server misbehaving"}, t)
Expand Down

0 comments on commit 5f31c16

Please sign in to comment.