mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-26 03:52:12 +02:00
bc35f20228
* feat(endpoint): add endpoint parser * fix parseTarget ut * fix insecure testing
30 lines
894 B
Go
30 lines
894 B
Go
package http
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestParseTarget(t *testing.T) {
|
|
target, err := parseTarget("localhost:8000", true)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, &Target{Scheme: "http", Authority: "localhost:8000"}, target)
|
|
|
|
target, err = parseTarget("discovery:///demo", true)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, &Target{Scheme: "discovery", Authority: "", Endpoint: "demo"}, target)
|
|
|
|
target, err = parseTarget("127.0.0.1:8000", true)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, &Target{Scheme: "http", Authority: "127.0.0.1:8000"}, target)
|
|
|
|
target, err = parseTarget("https://127.0.0.1:8000", false)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, &Target{Scheme: "https", Authority: "127.0.0.1:8000"}, target)
|
|
|
|
target, err = parseTarget("127.0.0.1:8000", false)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, &Target{Scheme: "https", Authority: "127.0.0.1:8000"}, target)
|
|
}
|