MCPcopy Index your code
hub / github.com/coder/coder / TestInvalid

Function TestInvalid

coderd/apikey/apikey_test.go:178–188  ·  view source on GitHub ↗

TestInvalid just ensures the false case is asserted by some tests. Otherwise, a function that just `returns true` might pass all tests incorrectly.

(t *testing.T)

Source from the content-addressed store, hash-verified

176// TestInvalid just ensures the false case is asserted by some tests.
177// Otherwise, a function that just `returns true` might pass all tests incorrectly.
178func TestInvalid(t *testing.T) {
179 t.Parallel()
180
181 require.Falsef(t, apikey.ValidateHash([]byte{}, "secret"), "empty hash")
182
183 secret, hash, err := apikey.GenerateSecret(10)
184 require.NoError(t, err)
185
186 require.Falsef(t, apikey.ValidateHash(hash, secret+"_"), "different secret")
187 require.Falsef(t, apikey.ValidateHash(hash[:len(hash)-1], secret), "different hash length")
188}

Callers

nothing calls this directly

Calls 2

ValidateHashFunction · 0.92
GenerateSecretFunction · 0.92

Tested by

no test coverage detected