Skip to content

Commit

Permalink
fixes #2712 edge-oidc missing from /version
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpmartinez committed Feb 12, 2025
1 parent 0cee46c commit c4f8391
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions controller/internal/routes/version_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (ir *VersionRouter) List(ae *env.AppEnv, rc *response.RequestContext) {
APIVersions: map[string]map[string]rest_model.APIVersion{
webapis.ClientApiBinding: {webapis.VersionV1: mapApiVersionToRestModel(webapis.ClientRestApiBaseUrlV1)},
webapis.ManagementApiBinding: {webapis.VersionV1: mapApiVersionToRestModel(webapis.ManagementRestApiBaseUrlV1)},
webapis.OidcApiBinding: {webapis.VersionV1: mapApiVersionToRestModel(webapis.OidcRestApiBaseUrl)},
},
Capabilities: []string{},
}
Expand Down
1 change: 1 addition & 0 deletions controller/webapis/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
ClientRestApiBaseUrlV1 = ClientRestApiBase + RestApiV1
ManagementRestApiBaseUrlV1 = ManagementRestApiBase + RestApiV1
ControllerHealthCheckApiBaseUrlV1 = ControllerHealthCheck + RestApiV1
OidcRestApiBaseUrl = "/oidc"

ClientRestApiBaseUrlLatest = ClientRestApiBaseUrlV1
ManagementRestApiBaseUrlLatest = ManagementRestApiBaseUrlV1
Expand Down
76 changes: 76 additions & 0 deletions tests/endpoint_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package tests

import (
"encoding/json"
"github.com/openziti/edge-api/rest_model"
"net/http"
"testing"
)
Expand Down Expand Up @@ -76,4 +78,78 @@ func Test_Endpoints(t *testing.T) {
ctx.Req.Equal("application/pkcs7-mime", resp.Header().Get("Content-Type"))
ctx.Req.NotEmpty(resp.Body())
})

t.Run("the version endpoint", func(t *testing.T) {

t.Run("responds on root /version", func(t *testing.T) {
ctx.testContextChanged(t)

rootResp, err := ctx.newAnonymousClientApiRequest().Get("https://" + ctx.ApiHost + "/version")
ctx.Req.NoError(err)
ctx.Req.Equal(200, rootResp.StatusCode())

t.Run("has the proper values", func(t *testing.T) {
ctx.testContextChanged(t)

ctx.Req.Equal("application/json", rootResp.Header().Get("Content-Type"))

data := &rest_model.Version{}
envelope := &rest_model.Empty{
Data: data,
}

err = json.Unmarshal(rootResp.Body(), envelope)
ctx.Req.NoError(err)

ctx.Req.NotEmpty(envelope)
ctx.Req.NotEmpty(envelope.Data)
ctx.Req.NotEmpty(data)
ctx.Req.NotEmpty(data.Version)
ctx.Req.NotEmpty(data.APIVersions)
ctx.Req.NotEmpty(data.BuildDate)
ctx.Req.NotEmpty(data.Capabilities)
ctx.Req.NotEmpty(data.Revision)
ctx.Req.NotEmpty(data.RuntimeVersion)

ctx.Req.Contains(data.APIVersions, "edge")
ctx.Req.Contains(data.APIVersions["edge"], "v1")
ctx.Req.Equal(*data.APIVersions["edge"]["v1"].Path, "/edge/client/v1")

ctx.Req.Contains(data.APIVersions, "edge-client")
ctx.Req.Contains(data.APIVersions["edge-client"], "v1")
ctx.Req.Equal(*data.APIVersions["edge-client"]["v1"].Path, "/edge/client/v1")

ctx.Req.Contains(data.APIVersions, "edge-management")
ctx.Req.Contains(data.APIVersions["edge-management"], "v1")
ctx.Req.Equal(*data.APIVersions["edge-management"]["v1"].Path, "/edge/management/v1")

ctx.Req.Contains(data.APIVersions, "edge-oidc")
ctx.Req.Contains(data.APIVersions["edge-oidc"], "v1")
ctx.Req.Equal(*data.APIVersions["edge-oidc"]["v1"].Path, "/oidc")

ctx.Req.Contains(data.APIVersions, "health-checks")
ctx.Req.Contains(data.APIVersions["health-checks"], "v1")
ctx.Req.Equal(*data.APIVersions["health-checks"]["v1"].Path, "/health-checks/v1")
})

t.Run("responds on /edge/client/v1/version", func(t *testing.T) {
ctx.testContextChanged(t)

resp, err := ctx.newAnonymousClientApiRequest().Get("version")
ctx.Req.NoError(err)
ctx.Req.Equal(200, resp.StatusCode())
ctx.Req.Equal(rootResp.Body(), resp.Body())
})

t.Run("responds on /edge/management/v1/version", func(t *testing.T) {
ctx.testContextChanged(t)

resp, err := ctx.newAnonymousManagementApiRequest().Get("version")
ctx.Req.NoError(err)
ctx.Req.Equal(200, resp.StatusCode())
ctx.Req.Equal(rootResp.Body(), resp.Body())
})
})

})
}

0 comments on commit c4f8391

Please sign in to comment.