violet/utils/server-utils_test.go

21 lines
489 B
Go
Raw Permalink Normal View History

2023-06-04 22:28:48 +01:00
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))
}