summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorJulien Dessaux2024-11-16 00:36:17 +0100
committerJulien Dessaux2024-11-16 00:36:17 +0100
commit5b6da560896970c610c691dff6ed052a57ed5a1d (patch)
tree7ec12f39943513230659d3068d59e8687770f053 /cmd
parentfix(tfstated): return 403 Forbidden on non existent account (diff)
downloadtfstated-5b6da560896970c610c691dff6ed052a57ed5a1d.tar.gz
tfstated-5b6da560896970c610c691dff6ed052a57ed5a1d.tar.bz2
tfstated-5b6da560896970c610c691dff6ed052a57ed5a1d.zip
fix(tfstated): hash passwords instead of relying on the database encryption key
Diffstat (limited to '')
-rw-r--r--cmd/tfstated/main_test.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/cmd/tfstated/main_test.go b/cmd/tfstated/main_test.go
index 3ad1d7e..82b7736 100644
--- a/cmd/tfstated/main_test.go
+++ b/cmd/tfstated/main_test.go
@@ -19,7 +19,7 @@ var baseURI = url.URL{
Scheme: "http",
}
var db *database.DB
-var password string
+var adminPassword string
func TestMain(m *testing.M) {
ctx := context.Background()
@@ -46,6 +46,9 @@ func TestMain(m *testing.M) {
}
}
+ database.AdvertiseAdminPassword = func(password string) {
+ adminPassword = password
+ }
go run(
ctx,
&config,
@@ -59,13 +62,6 @@ func TestMain(m *testing.M) {
os.Exit(1)
}
- admin, err := db.LoadAccountByUsername("admin")
- if err != nil {
- fmt.Fprintf(os.Stderr, "%+v\n", err)
- os.Exit(1)
- }
- password = admin.Password
-
ret := m.Run()
cancel()
@@ -88,7 +84,7 @@ func runHTTPRequest(method string, auth bool, uriRef *url.URL, body io.Reader, t
return
}
if auth {
- req.SetBasicAuth("admin", password)
+ req.SetBasicAuth("admin", adminPassword)
}
resp, err := client.Do(req)
if err != nil {