Files
Andrew MartinezandGitHub d6edd476e5 fix openziti/ziti#3352 adds api session ressumption to edge_apis (#833)
* fix openziti/ziti#3352 adds api session ressumption to edge_apis

adds method type, ApiSession interface JSON wrapper

- adds string alias type AuthMethod
- adds AuthMethodEmpty as a sentinal type
- adds ApiSessionJsonWrapper to allow direct (un)marshalling of
  ApiSession via interface
- adds the ability to provide custom http client and transports
- adds an inline OAuth2/OIDC rp token authentication
- update redirect URI handling, ensure default uses ported value
2025-11-13 10:18:11 -05:00

34 lines
700 B
Go

package edge_apis
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/require"
)
func Test_ApiSessionMarshalling(t *testing.T) {
t.Run("test marshalling", func(t *testing.T) {
req := require.New(t)
type testStruct struct {
ApiSession ApiSessionJsonWrapper `json:"apiSession"`
}
test := &testStruct{
ApiSession: ApiSessionJsonWrapper{
ApiSession: NewApiSessionOidc("access", "refresh"),
},
}
testJson, err := json.Marshal(test)
req.NoError(err)
testUnmarhsal := &testStruct{}
err = json.Unmarshal(testJson, testUnmarhsal)
req.NoError(err)
req.Equal(test.ApiSession.ApiSession.GetToken(), testUnmarhsal.ApiSession.ApiSession.GetToken())
})
}