auth_test.go — gin Source File
Architecture documentation for auth_test.go, a go file in the gin codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 8de69f2f_ba6f_8b4b_b264_a61861b36bb6["auth_test.go"] d9caca31_f0e7_60a9_c11e_ce8f83f31d36["base64"] 8de69f2f_ba6f_8b4b_b264_a61861b36bb6 --> d9caca31_f0e7_60a9_c11e_ce8f83f31d36 style 8de69f2f_ba6f_8b4b_b264_a61861b36bb6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package gin
import (
"encoding/base64"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBasicAuth(t *testing.T) {
pairs := processAccounts(Accounts{
"admin": "password",
"foo": "bar",
"bar": "foo",
})
assert.Len(t, pairs, 3)
assert.Contains(t, pairs, authPair{
user: "bar",
value: "Basic YmFyOmZvbw==",
})
assert.Contains(t, pairs, authPair{
user: "foo",
value: "Basic Zm9vOmJhcg==",
})
assert.Contains(t, pairs, authPair{
user: "admin",
value: "Basic YWRtaW46cGFzc3dvcmQ=",
})
}
func TestBasicAuthFails(t *testing.T) {
assert.Panics(t, func() { processAccounts(nil) })
assert.Panics(t, func() {
processAccounts(Accounts{
"": "password",
"foo": "bar",
})
})
}
func TestBasicAuthSearchCredential(t *testing.T) {
pairs := processAccounts(Accounts{
"admin": "password",
"foo": "bar",
"bar": "foo",
})
user, found := pairs.searchCredential(authorizationHeader("admin", "password"))
assert.Equal(t, "admin", user)
assert.True(t, found)
user, found = pairs.searchCredential(authorizationHeader("foo", "bar"))
assert.Equal(t, "foo", user)
// ... (117 more lines)
Domain
Subdomains
Functions
Dependencies
- base64
Source
Frequently Asked Questions
What does auth_test.go do?
auth_test.go is a source file in the gin codebase, written in go. It belongs to the GinCore domain, Middleware subdomain.
What functions are defined in auth_test.go?
auth_test.go defines 9 function(s): TestBasicAuth, TestBasicAuth401, TestBasicAuth401WithCustomRealm, TestBasicAuthAuthorizationHeader, TestBasicAuthFails, TestBasicAuthForProxy407, TestBasicAuthForProxySucceed, TestBasicAuthSearchCredential, TestBasicAuthSucceed.
What does auth_test.go depend on?
auth_test.go imports 1 module(s): base64.
Where is auth_test.go in the architecture?
auth_test.go is located at auth_test.go (domain: GinCore, subdomain: Middleware).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free