Test_Extractor_FromAuthHeader_Token68_Validation() — fiber Function Reference
Architecture documentation for the Test_Extractor_FromAuthHeader_Token68_Validation() function in extractors_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 4dd4e313_b48e_de06_b0f4_71e2c6ec7797["Test_Extractor_FromAuthHeader_Token68_Validation()"] cf5e296e_8db5_6f84_b05a_9c0cac6f83e7["extractors_test.go"] 4dd4e313_b48e_de06_b0f4_71e2c6ec7797 -->|defined in| cf5e296e_8db5_6f84_b05a_9c0cac6f83e7 style 4dd4e313_b48e_de06_b0f4_71e2c6ec7797 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
extractors/extractors_test.go lines 579–637
func Test_Extractor_FromAuthHeader_Token68_Validation(t *testing.T) {
t.Parallel()
app := fiber.New()
// Test valid token68 characters (should pass)
ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
t.Cleanup(func() { app.ReleaseCtx(ctx) })
ctx.Request().Header.Set(fiber.HeaderAuthorization, "Bearer ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~+/=")
token, err := FromAuthHeader("Bearer").Extract(ctx)
require.NoError(t, err)
require.Equal(t, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~+/=", token)
// Test tokens with spaces (should fail)
testCases := []struct {
name string
header string
description string
shouldFail bool
}{
{name: "space_in_token", header: "Bearer abc def", shouldFail: true, description: "space in token"},
{name: "space_after_scheme", header: "Bearer abc", shouldFail: true, description: "multiple spaces after scheme"},
{name: "no_space_after_scheme", header: "Bearertoken", shouldFail: true, description: "no space after scheme"},
{name: "only_scheme", header: "Bearer", shouldFail: true, description: "only scheme, no token"},
{name: "tab_after_scheme", header: "Bearer\ttoken", shouldFail: true, description: "tab after scheme"},
{name: "tab_in_token", header: "Bearer abc\tdef", shouldFail: true, description: "tab in token"},
{name: "newline_in_token", header: "Bearer abc\ndef", shouldFail: true, description: "newline in token"},
{name: "leading_space_in_token", header: "Bearer abc", shouldFail: true, description: "leading space in token after scheme space"},
{name: "trailing_space_in_token", header: "Bearer abc ", shouldFail: true, description: "trailing space in token"},
{name: "comma_in_token", header: "Bearer abc,def", shouldFail: true, description: "comma in token"},
{name: "semicolon_in_token", header: "Bearer abc;def", shouldFail: true, description: "semicolon in token"},
{name: "quote_in_token", header: "Bearer abc\"def", shouldFail: true, description: "quote in token"},
{name: "bracket_in_token", header: "Bearer abc[def", shouldFail: true, description: "bracket in token"},
{name: "equals_at_start", header: "Bearer =abc", shouldFail: true, description: "equals at start of token"},
{name: "equals_in_middle", header: "Bearer ab=cd", shouldFail: true, description: "equals in middle of token"},
{name: "valid_equals_at_end", header: "Bearer abc=", shouldFail: false, description: "valid equals at end"},
{name: "valid_double_equals", header: "Bearer abc==", shouldFail: false, description: "valid double equals at end"},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
t.Cleanup(func() { app.ReleaseCtx(ctx) })
ctx.Request().Header.Set(fiber.HeaderAuthorization, tc.header)
token, err := FromAuthHeader("Bearer").Extract(ctx)
if tc.shouldFail {
require.Error(t, err, "Expected error for %s", tc.description)
require.ErrorIs(t, err, ErrNotFound)
require.Empty(t, token)
} else {
require.NoError(t, err, "Expected no error for %s", tc.description)
require.NotEmpty(t, token)
}
})
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Extractor_FromAuthHeader_Token68_Validation() do?
Test_Extractor_FromAuthHeader_Token68_Validation() is a function in the fiber codebase, defined in extractors/extractors_test.go.
Where is Test_Extractor_FromAuthHeader_Token68_Validation() defined?
Test_Extractor_FromAuthHeader_Token68_Validation() is defined in extractors/extractors_test.go at line 579.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free