Files
zt/tests/network_jwt_test.go
Andrew MartinezandGitHub 0e61edb2f9 fix #2984 identity/router enrollment do not return full chains (#2990)
* fix #2984 identity/router enrollment do not return full chains

- router extend via REST/ctrl now return full chains
- identity extend via REST now return full chains
- updates tests to allow for chain lengths
- modifies verification to look at the first cert in the chain (leaf)
- modifies edge routers to not start extension if new certs can't be
  saved
- adds network-jwt tests
2025-04-11 11:27:57 -04:00

64 lines
1.9 KiB
Go

package tests
import (
"github.com/openziti/edge-api/rest_model"
"testing"
)
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)
})
})
}