mirror of
https://github.com/hanzozt/zt.git
synced 2026-10-30 15:04:55 +00:00
Global rebrand of all OpenZiti references to Hanzo ZT: - Go module paths: github.com/openziti/* → github.com/hanzozt/* - Docker images: openziti/* → hanzozt/* - Java packages: org.openziti.* → org.hanzozt.* - Brand: OpenZiti → Hanzo ZT - URLs: openziti.io → hanzozt.dev
65 lines
1.9 KiB
Go
65 lines
1.9 KiB
Go
package tests
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hanzozt/edge-api/rest_model"
|
|
)
|
|
|
|
func Test_NetworkJwts(t *testing.T) {
|
|
ctx := NewTestContext(t)
|
|
defer ctx.Teardown()
|
|
ctx.StartServer()
|
|
|
|
t.Run("network-jwts can be retrieved via", func(t *testing.T) {
|
|
|
|
t.Run("deprecated root path", func(t *testing.T) {
|
|
ctx.testContextChanged(t)
|
|
jwtRootUrl := "https://" + ctx.ApiHost + "/network-jwts"
|
|
|
|
respEnv := &rest_model.ListNetworkJWTsEnvelope{}
|
|
resp, err := ctx.newAnonymousClientApiRequest().SetResult(respEnv).Get(jwtRootUrl)
|
|
ctx.Req.NoError(err)
|
|
ctx.Req.NotNil(resp)
|
|
ctx.Req.Equal(200, resp.StatusCode())
|
|
|
|
ctx.Req.Len(respEnv.Data, 1)
|
|
ctx.Req.NotNil(respEnv.Data[0].Name)
|
|
ctx.Req.Equal("default", *respEnv.Data[0].Name)
|
|
ctx.Req.NotEmpty(respEnv.Data[0].Token)
|
|
})
|
|
|
|
t.Run("client path", func(t *testing.T) {
|
|
ctx.testContextChanged(t)
|
|
jwtRootUrl := "https://" + ctx.ApiHost + "/edge/client/v1/network-jwts"
|
|
|
|
respEnv := &rest_model.ListNetworkJWTsEnvelope{}
|
|
resp, err := ctx.newAnonymousClientApiRequest().SetResult(respEnv).Get(jwtRootUrl)
|
|
ctx.Req.NoError(err)
|
|
ctx.Req.NotNil(resp)
|
|
ctx.Req.Equal(200, resp.StatusCode())
|
|
|
|
ctx.Req.Len(respEnv.Data, 1)
|
|
ctx.Req.NotNil(respEnv.Data[0].Name)
|
|
ctx.Req.Equal("default", *respEnv.Data[0].Name)
|
|
ctx.Req.NotEmpty(respEnv.Data[0].Token)
|
|
})
|
|
|
|
t.Run("management path", func(t *testing.T) {
|
|
ctx.testContextChanged(t)
|
|
jwtRootUrl := "https://" + ctx.ApiHost + "/edge/management/v1/network-jwts"
|
|
|
|
respEnv := &rest_model.ListNetworkJWTsEnvelope{}
|
|
resp, err := ctx.newAnonymousClientApiRequest().SetResult(respEnv).Get(jwtRootUrl)
|
|
ctx.Req.NoError(err)
|
|
ctx.Req.NotNil(resp)
|
|
ctx.Req.Equal(200, resp.StatusCode())
|
|
|
|
ctx.Req.Len(respEnv.Data, 1)
|
|
ctx.Req.NotNil(respEnv.Data[0].Name)
|
|
ctx.Req.Equal("default", *respEnv.Data[0].Name)
|
|
ctx.Req.NotEmpty(respEnv.Data[0].Token)
|
|
})
|
|
})
|
|
}
|