mirror of
https://github.com/1f349/violet.git
synced 2024-11-13 23:11:36 +00:00
21 lines
489 B
Go
21 lines
489 B
Go
package utils
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"net/http"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetBearer(t *testing.T) {
|
|
req, err := http.NewRequest(http.MethodPost, "https://example.com", nil)
|
|
assert.NoError(t, err)
|
|
req.Header.Set("Authorization", "Bearer abc")
|
|
assert.Equal(t, "abc", GetBearer(req))
|
|
}
|
|
|
|
func TestGetBearer_Empty(t *testing.T) {
|
|
req, err := http.NewRequest(http.MethodPost, "https://example.com", nil)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "", GetBearer(req))
|
|
}
|