Skip to content

Commit

Permalink
fix #2405 fix multiple default APIs, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpmartinez committed Sep 16, 2024
1 parent e5ddb7c commit 86ac976
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion controller/webapis/oidc-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (h OidcApiHandler) ServeHTTP(writer http.ResponseWriter, request *http.Requ
}

func (h OidcApiHandler) IsDefault() bool {
return true
return false
}

func NewOidcApiHandler(serverConfig *xweb.ServerConfig, ae *env.AppEnv, options map[interface{}]interface{}) (*OidcApiHandler, error) {
Expand Down
67 changes: 67 additions & 0 deletions tests/endpoint_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package tests

import (
"testing"
)

// Test_Endpoints does HTTP testing against public entry URLs to ensure they continue to function.
// Non-prefixed paths are deprecated, but some older clients do not use the edge/client/v1 path.
// The .well-known path has many handlers among different APIs and tests for those should exist
// perpetuity.
func Test_Endpoints(t *testing.T) {
ctx := NewTestContext(t)
defer ctx.Teardown()
ctx.StartServer()

t.Run("non-prefixed path defaults for enrollment", func(t *testing.T) {
ctx.testContextChanged(t)

rootPathClient, _, _ := ctx.NewClientComponents("/")

resp, err := rootPathClient.R().Post("https://" + ctx.ApiHost + "/enroll")

ctx.Req.NoError(err)
ctx.Req.Equal(400, resp.StatusCode())
ctx.Req.Equal("application/json", resp.Header().Get("Content-Type"))
ctx.Req.NotEmpty(resp.Body())
})

t.Run("non-prefixed path defaults for authentication", func(t *testing.T) {
ctx.testContextChanged(t)

rootPathClient, _, _ := ctx.NewClientComponents("/")

resp, err := rootPathClient.R().Post("https://" + ctx.ApiHost + "/authenticate")

ctx.Req.NoError(err)
ctx.Req.Equal(400, resp.StatusCode())
ctx.Req.Equal("application/json", resp.Header().Get("Content-Type"))
ctx.Req.NotEmpty(resp.Body())
})

t.Run("oidc-configuration works on .well-known", func(t *testing.T) {
ctx.testContextChanged(t)

rootPathClient, _, _ := ctx.NewClientComponents("/")

resp, err := rootPathClient.R().Get("https://" + ctx.ApiHost + "/.well-known/openid-configuration")

ctx.Req.NoError(err)
ctx.Req.Equal(200, resp.StatusCode())
ctx.Req.Equal("application/json", resp.Header().Get("Content-Type"))
ctx.Req.NotEmpty(resp.Body())
})

t.Run("est castore works on .well-known", func(t *testing.T) {
ctx.testContextChanged(t)

rootPathClient, _, _ := ctx.NewClientComponents("/")

resp, err := rootPathClient.R().Get("https://" + ctx.ApiHost + "/.well-known/est/cacerts")

ctx.Req.NoError(err)
ctx.Req.Equal(200, resp.StatusCode())
ctx.Req.Equal("application/pkcs7-mime", resp.Header().Get("Content-Type"))
ctx.Req.NotEmpty(resp.Body())
})
}

0 comments on commit 86ac976

Please sign in to comment.