2022-07-17 12:37:23 +08:00
|
|
|
package internal
|
2022-07-16 14:11:34 +08:00
|
|
|
|
|
|
|
import (
|
2022-10-17 06:30:58 +08:00
|
|
|
"net/http"
|
2022-07-16 14:11:34 +08:00
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBuildHeadersNoValue(t *testing.T) {
|
2022-10-17 06:30:58 +08:00
|
|
|
req := httptest.NewRequest("GET", "/", http.NoBody)
|
2022-07-16 14:11:34 +08:00
|
|
|
req.Header.Add("a", "b")
|
2022-07-17 23:21:19 +08:00
|
|
|
assert.Nil(t, ProcessHeaders(req.Header))
|
2022-07-16 14:11:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBuildHeadersWithValues(t *testing.T) {
|
2022-10-17 06:30:58 +08:00
|
|
|
req := httptest.NewRequest("GET", "/", http.NoBody)
|
2022-07-16 14:11:34 +08:00
|
|
|
req.Header.Add("grpc-metadata-a", "b")
|
|
|
|
req.Header.Add("grpc-metadata-b", "b")
|
2022-07-17 23:21:19 +08:00
|
|
|
assert.ElementsMatch(t, []string{"gateway-A:b", "gateway-B:b"}, ProcessHeaders(req.Header))
|
2022-07-16 14:11:34 +08:00
|
|
|
}
|