Repository: snowflakedb/gosnowflake
Pull request #1357 (2025-04-07 06:38:50)

SNOW-1825476 Remove PAT with password instead of token
### Description

SNOW-1825476 Removed rewriting password to token field for PAT authentication.

### Checklist
- [x] Created tests which fail without the change (if possible)
- [x] Extended the README / documentation, if necessary


sfc-gh-snowflakedb-snyk-sa: ![](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests/pr-banner-default.svg)

### :tada: **Snyk checks have passed. No issues have been found so far.**

:white_check_mark: **security/snyk** check is complete. No issues have been found. [(View Details)](https://app.snyk.io/org/snowflakedb-sca-scanning-public-repo/pr-checks/bdf3fb01-35af-409d-a055-a1f0d1d4677e?refs=f11c5c49fe72783c12b12c22804a4a43cf59f446&source=prChecksComment)

:white_check_mark: **license/snyk** check is complete. No issues have been found. [(View Details)](https://app.snyk.io/org/snowflakedb-sca-scanning-public-repo/pr-checks/bdf3fb01-35af-409d-a055-a1f0d1d4677e/license?refs=f11c5c49fe72783c12b12c22804a4a43cf59f446&source=prChecksComment)



codecov[bot]: ## [Codecov](https://app.codecov.io/gh/snowflakedb/gosnowflake/pull/1357?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snowflakedb) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 82.19%. Comparing base [(`47db2ad`)](https://app.codecov.io/gh/snowflakedb/gosnowflake/commit/47db2ad2f558b6142beb519379ae726c4139e82d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snowflakedb) to head [(`f11c5c4`)](https://app.codecov.io/gh/snowflakedb/gosnowflake/commit/f11c5c49fe72783c12b12c22804a4a43cf59f446?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snowflakedb).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #1357      +/-   ##
==========================================
- Coverage   82.20%   82.19%   -0.01%     
==========================================
  Files          57       57              
  Lines       13911    13908       -3     
==========================================
- Hits        11435    11432       -3     
  Misses       2476     2476              
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/snowflakedb/gosnowflake/pull/1357?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snowflakedb).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snowflakedb).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>

Patch:
diff --git a/auth.go b/auth.go
index eb3eeca..cf8f916 100644
--- a/auth.go
+++ b/auth.go
@@ -454,9 +454,6 @@ func createRequestBody(sc *snowflakeConn, sessionParameters map[string]interface
 		requestMain.Authenticator = AuthTypePat.String()
 		requestMain.LoginName = sc.cfg.User
 		requestMain.Token = sc.cfg.Token
-		if sc.cfg.Password != "" && sc.cfg.Token == "" {
-			requestMain.Token = sc.cfg.Password
-		}
 	case AuthTypeSnowflake:
 		logger.WithContext(sc.ctx).Info("Username and password")
 		requestMain.LoginName = sc.cfg.User


Test patch:
diff --git a/auth_test.go b/auth_test.go
index ec261ef..0e55da3 100644
--- a/auth_test.go
+++ b/auth_test.go
@@ -1002,14 +1002,15 @@ func TestContextPropagatedToAuthWhenUsingOpenDB(t *testing.T) {
 	cancel()
 }
 
+func enableExperimentalAuth(t *testing.T) {
+	err := os.Setenv("ENABLE_EXPERIMENTAL_AUTHENTICATION", "true")
+	assertNilF(t, err)
+}
+
 func TestPatSuccessfulFlow(t *testing.T) {
 	cfg := wiremock.connectionConfig()
 	cfg.Authenticator = AuthTypePat
 	cfg.Token = "some PAT"
-	testPatSuccessfulFlow(t, cfg)
-}
-
-func testPatSuccessfulFlow(t *testing.T, cfg *Config) {
 	enableExperimentalAuth(t)
 	wiremock.registerMappings(t,
 		wiremockMapping{filePath: "auth/pat/successful_flow.json"},
@@ -1025,18 +1026,6 @@ func testPatSuccessfulFlow(t *testing.T, cfg *Config) {
 	assertEqualE(t, v, 1)
 }
 
-func enableExperimentalAuth(t *testing.T) {
-	err := os.Setenv("ENABLE_EXPERIMENTAL_AUTHENTICATION", "true")
-	assertNilF(t, err)
-}
-
-func TestPatSuccessfulFlowWithPatAsPasswordWithPatAuthenticator(t *testing.T) {
-	cfg := wiremock.connectionConfig()
-	cfg.Authenticator = AuthTypePat
-	cfg.Password = "some PAT"
-	testPatSuccessfulFlow(t, cfg)
-}
-
 func TestPatInvalidToken(t *testing.T) {
 	enableExperimentalAuth(t)
 	wiremock.registerMappings(t,