Skip to content

Commit

Permalink
Merge branch 'main' into feat/otel-tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 authored Sep 5, 2024
2 parents 85b67b1 + 21dfb44 commit 37a6e9b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions mock/server/rotate_keys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: Apache-2.0

package server

import (
"net/http"
"strings"

"github.com/gin-gonic/gin"

"github.com/go-vela/server/router/middleware/auth"
"github.com/go-vela/types"
)

// rotateKeys returns success message. Pass `invalid` to auth header to test 401 error.
func rotateKeys(c *gin.Context) {
tkn, _ := auth.RetrieveAccessToken(c.Request)

if strings.EqualFold(tkn, "invalid") {
data := "unauthorized"
c.AbortWithStatusJSON(http.StatusUnauthorized, types.Error{Message: &data})

return
}

c.JSON(http.StatusOK, "keys rotated successfully")
}
1 change: 1 addition & 0 deletions mock/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func FakeHandler() http.Handler {
// mock endpoints for oidc calls
e.GET("/_services/token/.well-known/openid-configuration", openIDConfig)
e.GET("/_services/token/.well-known/jwks", getJWKS)
e.POST("/api/v1/admin/rotate_oidc_keys", rotateKeys)

// mock endpoint for queue credentials
e.GET("/api/v1/queue/info", getQueueCreds)
Expand Down

0 comments on commit 37a6e9b

Please sign in to comment.