diff --git a/auth.go b/auth.go index 4126355e6..fa2f651c6 100644 --- a/auth.go +++ b/auth.go @@ -70,6 +70,9 @@ func determineAuthenticatorType(cfg *Config, value string) error { } else if upperCaseValue == AuthTypeUsernamePasswordMFA.String() { cfg.Authenticator = AuthTypeUsernamePasswordMFA return nil + } else if upperCaseValue == AuthTypeTokenAccessor.String() { + cfg.Authenticator = AuthTypeTokenAccessor + return nil } else { // possibly Okta case oktaURLString, err := url.QueryUnescape(lowerCaseValue) diff --git a/dsn_test.go b/dsn_test.go index 437297f0a..787f165e8 100644 --- a/dsn_test.go +++ b/dsn_test.go @@ -1100,6 +1100,15 @@ func TestDSN(t *testing.T) { }, dsn: "u:p@a.b.c.snowflakecomputing.com:443?ocspFailOpen=true®ion=b.c&token=t&validateDefaultParameters=true", }, + { + cfg: &Config{ + User: "u", + Password: "p", + Account: "a.b.c", + Authenticator: AuthTypeTokenAccessor, + }, + dsn: "u:p@a.b.c.snowflakecomputing.com:443?authenticator=tokenaccessor&ocspFailOpen=true®ion=b.c&validateDefaultParameters=true", + }, } for _, test := range testcases { dsn, err := DSN(test.cfg) diff --git a/file_transfer_agent_test.go b/file_transfer_agent_test.go index d4ad624b8..0cfe7f8e2 100644 --- a/file_transfer_agent_test.go +++ b/file_transfer_agent_test.go @@ -3,9 +3,11 @@ package gosnowflake import ( + "bytes" "context" "errors" "fmt" + "io" "net/url" "os" "path" @@ -597,3 +599,31 @@ func TestUploadWhenFilesystemReadOnlyError(t *testing.T) { t.Fatalf("should error when creating the temporary directory. Instead errored with: %v", err) } } + +func TestUnitUpdateProgess(t *testing.T) { + var b bytes.Buffer + buf := io.Writer(&b) + buf.Write([]byte("testing")) + + spp := &snowflakeProgressPercentage{ + filename: "test.txt", + fileSize: float64(1500), + outputStream: &buf, + showProgressBar: true, + done: false, + } + + spp.call(0) + if spp.done != false { + t.Fatal("should not be done.") + } + + if spp.seenSoFar != 0 { + t.Fatalf("expected seenSoFar to be 0 but was %v", spp.seenSoFar) + } + + spp.call(1516) + if spp.done != true { + t.Fatal("should be done after updating progess") + } +} diff --git a/heartbeat_test.go b/heartbeat_test.go index 839d50986..8fff076fa 100644 --- a/heartbeat_test.go +++ b/heartbeat_test.go @@ -54,3 +54,27 @@ func TestUnitPostHeartbeat(t *testing.T) { t.Fatalf("unexpected error code. expected: %v, got: %v", ErrFailedToHeartbeat, driverErr.Number) } } + +func TestStopHeartbeat(t *testing.T) { + createDSNWithClientSessionKeepAlive() + ctx := context.Background() + config, err := ParseDSN(dsn) + if err != nil { + t.Error(err) + } + driver := SnowflakeDriver{} + sc, err := driver.OpenWithConfig(ctx, *config) // starts heartbeat + if err != nil { + t.Error(err) + } + conn := sc.(*snowflakeConn) + if !conn.isClientSessionKeepAliveEnabled() { + t.Fatal("client session keep alive is not enabled") + } + + conn.rest.HeartBeat.stop() + _, ok := <-conn.rest.HeartBeat.shutdownChan + if ok { + t.Fatal("channel should be closed") + } +} diff --git a/test_util.go b/test_util_test.go similarity index 100% rename from test_util.go rename to test_util_test.go