mirror of
https://github.com/1f349/violet.git
synced 2024-11-24 20:31:37 +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))
|
|
}
|