Commit 22a957e
authored
auth: add unit and acceptance tests for secure-storage guards (#5077)
## Why
I smoke-tested the experimental secure token storage opt-in against a
live Databricks workspace (env-var and config-file paths) and noticed
three gaps in automated coverage that CI does not catch today:
1. The cmd-layer guard that keeps secure, plaintext, and unknown modes
from writing legacy host-keyed entries has no direct unit test.
2. The config-file source of the storage mode has no invalid-value
acceptance test (only the env var does).
3. Nothing asserts that \`DATABRICKS_AUTH_STORAGE\` beats
\`[__settings__] auth_storage\` in \`.databrickscfg\`.
All three are safe to automate without touching a real OS keyring.
## Changes
**Before:** \`dualWriteLegacyHostKey\` is only exercised indirectly
through login-flow tests; storage-mode acceptance coverage is limited to
\`invalid-env\` and \`legacy-env-default\`.
**Now:** three test additions, no behavior change.
- \`cmd/auth/login_test.go\`: add \`TestDualWriteLegacyHostKey\` with
five table-driven cases (legacy mirrors host key, legacy no-op on empty
cache, secure / plaintext / unknown modes all skip dual-write).
- \`acceptance/cmd/auth/storage-modes/invalid-config/\`: mirror of
\`invalid-env\` for the config-file source. Writes \`[__settings__]
auth_storage = bogus\` and asserts the error names \`auth_storage\` as
the source.
- \`acceptance/cmd/auth/storage-modes/env-overrides-config/\`: config
says \`secure\`, env says \`legacy\`; \`auth logout\` clears the
file-backed cache, proving the env override wins and the keyring is
never touched.
## Test plan
- [x] \`go test ./cmd/auth/... ./libs/auth/...\` passes
- [x] \`go test ./acceptance -run 'TestAccept/cmd/auth/'\` passes
- [x] \`make checks\` clean
- [x] \`make lint\` 0 issues
- [x] New unit test passes in isolation and with \`-race\`
- [x] Both acceptance tests pass under both \`DATABRICKS_BUNDLE_ENGINE\`
matrix variants
Safe for CI: none of the added tests touch a real OS keyring, per the
secure-storage rollout plan.1 parent 08c97f8 commit 22a957e
7 files changed
Lines changed: 140 additions & 0 deletions
File tree
- acceptance/cmd/auth/storage-modes
- env-overrides-config
- invalid-config
- cmd/auth
Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
1089 | 1090 | | |
1090 | 1091 | | |
1091 | 1092 | | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
0 commit comments