Add tests for getSessionId helper
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_desanitize64(t *testing.T) {
|
||||
@@ -23,3 +26,13 @@ func Test_cleanQuery(t *testing.T) {
|
||||
assert.Equal(t, "", cleanQuery("--something"))
|
||||
assert.Equal(t, "test", cleanQuery("--test\ntest\n -- test\n"))
|
||||
}
|
||||
|
||||
func Test_getSessionId(t *testing.T) {
|
||||
req := &http.Request{Header: http.Header{}}
|
||||
req.Header.Add("x-session-id", "token")
|
||||
assert.Equal(t, "token", getSessionId(req))
|
||||
|
||||
req = &http.Request{}
|
||||
req.URL, _ = url.Parse("http://foobar/?_session_id=token")
|
||||
assert.Equal(t, "token", getSessionId(req))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user