Files
ziti/tests/rest_auth_test.go
Andrew Martinez 1b180d14e8 fix #3933 add controller to enrollment response (#3947)
* fix #3933 add controller to enrollment response

- adds the cluster's controllers to ott, ottca, updb, and token enrollment
  responses with client and OIDC API addresses only
- synthesizes the running controller with its API addresses in non-HA mode
  so the list is never empty
- adds --not-before to ziti pki create for backdated test CAs
- replaces the test PKI with a SPIFFE-capable, ziti pki generated and managed
  one and rewires the config sets
- tests the controller list across ott/ottca/updb/token, non-HA, and raft

* fix missing wildcard cert from new PKI

* go mod tidy
2026-06-29 11:44:23 -04:00

57 lines
1.4 KiB
Go

//go:build apitests
package tests
import (
"net/http"
"testing"
idlib "github.com/openziti/identity"
)
func Test_TestAuthWithCertFromDifferentChain(t *testing.T) {
ctx := NewTestContext(t)
defer ctx.Teardown()
ctx.StartServer()
badId, err := idlib.LoadClientIdentity(
"./testdata/invalid_client_cert/client.cert",
"./testdata/invalid_client_cert/client.key",
"./testdata/pki/root/certs/root.cert")
ctx.Req.NoError(err)
client := ctx.NewRestClient(badId)
resp, err := client.R().Get("https://localhost:1281/fabric/v1/services")
ctx.Req.NoError(err)
ctx.Req.Equal(http.StatusUnauthorized, resp.StatusCode())
}
func Test_ListServicesWithValidCert(t *testing.T) {
ctx := NewTestContext(t)
defer ctx.Teardown()
ctx.StartServer()
id, err := idlib.LoadClientIdentity(
"./testdata/valid_client_cert/client.cert",
"./testdata/valid_client_cert/client.key",
"./testdata/pki/root/certs/root.cert")
ctx.Req.NoError(err)
client := ctx.NewRestClient(id)
resp, err := client.R().Get("https://localhost:1281/fabric/v1/services")
ctx.Req.NoError(err)
ctx.Req.Equal(http.StatusUnauthorized, resp.StatusCode())
}
func Test_ListServicesWithEdgeAuth(t *testing.T) {
ctx := NewTestContext(t)
defer ctx.Teardown()
ctx.StartServer()
ctx.RequireAdminManagementApiLogin()
req := ctx.AdminManagementSession.newAuthenticatedRequest()
resp, err := req.Get("https://localhost:1281/fabric/v1/services")
ctx.Req.NoError(err)
ctx.Req.True(resp.IsSuccess())
}