MCPcopy Index your code
hub / github.com/tinyauthapp/tinyauth / TestGetSecret

Function TestGetSecret

internal/utils/security_utils_test.go:12–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestGetSecret(t *testing.T) {
13 // Setup
14 file, err := os.Create("/tmp/tinyauth_test_secret")
15 assert.NilError(t, err)
16
17 _, err = file.WriteString(" secret \n")
18 assert.NilError(t, err)
19
20 err = file.Close()
21 assert.NilError(t, err)
22 defer os.Remove("/tmp/tinyauth_test_secret")
23
24 // Get from config
25 assert.Equal(t, "mysecret", utils.GetSecret("mysecret", ""))
26
27 // Get from file
28 assert.Equal(t, "secret", utils.GetSecret("", "/tmp/tinyauth_test_secret"))
29
30 // Get from both (config should take precedence)
31 assert.Equal(t, "mysecret", utils.GetSecret("mysecret", "/tmp/tinyauth_test_secret"))
32
33 // Get from none
34 assert.Equal(t, "", utils.GetSecret("", ""))
35
36 // Get from non-existing file
37 assert.Equal(t, "", utils.GetSecret("", "/tmp/non_existing_file"))
38}
39
40func TestParseSecretFile(t *testing.T) {
41 // Normal case

Callers

nothing calls this directly

Calls 1

GetSecretFunction · 0.92

Tested by

no test coverage detected