Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
34
plugins/common/auth/basic_auth_test.go
Normal file
34
plugins/common/auth/basic_auth_test.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestBasicAuth_VerifyWithCredentials(t *testing.T) {
|
||||
auth := BasicAuth{"username", "password"}
|
||||
|
||||
r := httptest.NewRequest("GET", "/github", nil)
|
||||
r.SetBasicAuth(auth.Username, auth.Password)
|
||||
|
||||
require.True(t, auth.Verify(r))
|
||||
}
|
||||
|
||||
func TestBasicAuth_VerifyWithoutCredentials(t *testing.T) {
|
||||
auth := BasicAuth{}
|
||||
|
||||
r := httptest.NewRequest("GET", "/github", nil)
|
||||
|
||||
require.True(t, auth.Verify(r))
|
||||
}
|
||||
|
||||
func TestBasicAuth_VerifyWithInvalidCredentials(t *testing.T) {
|
||||
auth := BasicAuth{"username", "password"}
|
||||
|
||||
r := httptest.NewRequest("GET", "/github", nil)
|
||||
r.SetBasicAuth("wrong-username", "wrong-password")
|
||||
|
||||
require.False(t, auth.Verify(r))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue