MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestBcryptCostTimes

Function TestBcryptCostTimes

auth/password_hash_test.go:45–62  ·  view source on GitHub ↗

TestBcryptCostTimes will output the time it takes to hash a password with each bcrypt cost value

(t *testing.T)

Source from the content-addressed store, hash-verified

43
44// TestBcryptCostTimes will output the time it takes to hash a password with each bcrypt cost value
45func TestBcryptCostTimes(t *testing.T) {
46 // Little value in running this regularly. Might be useful for one-off informational purposes
47 t.Skip("Test disabled")
48
49 minCostToTest := bcrypt.DefaultCost
50 maxCostToTest := bcrypt.DefaultCost + 5
51
52 for i := minCostToTest; i < maxCostToTest; i++ {
53 t.Run(fmt.Sprintf("cost%d", i), func(t *testing.T) {
54 startTime := time.Now()
55 _, err := bcrypt.GenerateFromPassword([]byte("hunter2"), i)
56 duration := time.Since(startTime)
57
58 t.Logf("bcrypt.GenerateFromPassword with cost %d took: %v", i, duration)
59 assert.NoError(t, err)
60 })
61 }
62}
63
64func TestSetBcryptCost(t *testing.T) {
65 ctx := base.TestCtx(t)

Callers

nothing calls this directly

Calls 3

RunMethod · 0.65
SinceMethod · 0.45
LogfMethod · 0.45

Tested by

no test coverage detected