Home / Function/ Test_GenerateKey() — fiber Function Reference

Test_GenerateKey() — fiber Function Reference

Architecture documentation for the Test_GenerateKey() function in encryptcookie_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  b4f4bdc7_eb4c_f0ae_1f16_0ef87064a547["Test_GenerateKey()"]
  ac3bbef3_a1d3_d68b_64fb_619088dde10d["encryptcookie_test.go"]
  b4f4bdc7_eb4c_f0ae_1f16_0ef87064a547 -->|defined in| ac3bbef3_a1d3_d68b_64fb_619088dde10d
  style b4f4bdc7_eb4c_f0ae_1f16_0ef87064a547 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/encryptcookie/encryptcookie_test.go lines 387–418

func Test_GenerateKey(t *testing.T) {
	t.Parallel()

	tests := []struct {
		length int
	}{
		{length: 16},
		{length: 24},
		{length: 32},
	}

	decodeBase64 := func(t *testing.T, s string) []byte {
		t.Helper()
		data, err := base64.StdEncoding.DecodeString(s)
		require.NoError(t, err)
		return data
	}

	for _, tt := range tests {
		t.Run(strconv.Itoa(tt.length)+"_length", func(t *testing.T) {
			t.Parallel()
			key := GenerateKey(tt.length)
			decodedKey := decodeBase64(t, key)
			require.Len(t, decodedKey, tt.length)
		})
	}

	t.Run("Invalid Length", func(t *testing.T) {
		require.Panics(t, func() { GenerateKey(10) })
		require.Panics(t, func() { GenerateKey(20) })
	})
}

Domain

Subdomains

Frequently Asked Questions

What does Test_GenerateKey() do?
Test_GenerateKey() is a function in the fiber codebase, defined in middleware/encryptcookie/encryptcookie_test.go.
Where is Test_GenerateKey() defined?
Test_GenerateKey() is defined in middleware/encryptcookie/encryptcookie_test.go at line 387.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free