Home / File/ keyauth_test.go — fiber Source File

keyauth_test.go — fiber Source File

Architecture documentation for keyauth_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go FiberCore Adapters 1 imports 31 functions 3 classes

Entity Profile

Dependency Diagram

graph LR
  71f55784_a001_0646_0ce7_7ad97067c49c["keyauth_test.go"]
  cc7104af_aece_1fe5_3985_791c7f34910c["context"]
  71f55784_a001_0646_0ce7_7ad97067c49c --> cc7104af_aece_1fe5_3985_791c7f34910c
  style 71f55784_a001_0646_0ce7_7ad97067c49c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package keyauth

import (
	"context"
	"errors"
	"io"
	"net/http"
	"net/http/httptest"
	"net/url"
	"strings"
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"

	"github.com/gofiber/fiber/v3"
	"github.com/gofiber/fiber/v3/extractors"
)

const CorrectKey = "correct-token_123./~+"

var testConfig = fiber.TestConfig{
	Timeout: 0,
}

const (
	paramExtractorName      = "param"
	formExtractorName       = "form"
	queryExtractorName      = "query"
	headerExtractorName     = "header"
	authHeaderExtractorName = "authHeader"
	cookieExtractorName     = "cookie"
)

func Test_AuthSources(t *testing.T) {
	// define test cases
	testSources := []string{headerExtractorName, authHeaderExtractorName, cookieExtractorName, queryExtractorName, paramExtractorName, formExtractorName}

	tests := []struct {
		route         string
		authTokenName string
		description   string
		APIKey        string
		expectedBody  string
		expectedCode  int
	}{
		{
			route:         "/",
			authTokenName: "access_token",
			description:   "auth with correct key",
			APIKey:        CorrectKey,
			expectedCode:  200,
			expectedBody:  "Success!",
		},
		{
			route:         "/",
			authTokenName: "access_token",
			description:   "auth with no key",
			APIKey:        "",
			expectedCode:  401, // 404 in case of param authentication
// ... (1042 more lines)

Domain

Subdomains

Types

Dependencies

  • context

Frequently Asked Questions

What does keyauth_test.go do?
keyauth_test.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Adapters subdomain.
What functions are defined in keyauth_test.go?
keyauth_test.go defines 31 function(s): TestMultipleKeyLookup, Test_AuthSchemeBasic, Test_AuthSchemeToken, Test_AuthSources, Test_BearerErrorFields, Test_BearerErrorURIOnly, Test_BearerInsufficientScope, Test_CustomChallenge, Test_CustomNextFunc, Test_CustomSuccessAndFailureHandlers, and 21 more.
What does keyauth_test.go depend on?
keyauth_test.go imports 1 module(s): context.
Where is keyauth_test.go in the architecture?
keyauth_test.go is located at middleware/keyauth/keyauth_test.go (domain: FiberCore, subdomain: Adapters, directory: middleware/keyauth).

Analyze Your Own Codebase

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

Try Supermodel Free