Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed bogus user password test #1194

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading