Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
Signed-off-by: ddl-rliu <[email protected]>

x

Signed-off-by: ddl-rliu <[email protected]>

x
  • Loading branch information
ddl-rliu committed Apr 9, 2024
1 parent 5f9abb1 commit bb76066
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flyteadmin/auth/auth_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
)

var (
callbackRelativeURL = config.MustParseURL("/callback")
callbackRelativeURL = config.MustParseURL("callback")
rootRelativeURL = config.MustParseURL("/")
)

Expand Down
41 changes: 41 additions & 0 deletions flyteadmin/auth/auth_context_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package auth

import (
"testing"

"github.com/stretchr/testify/assert"
"golang.org/x/oauth2"

"github.com/flyteorg/flyte/flyteadmin/auth/config"
)

func TestOAuth2ClientConfig(t *testing.T) {
authCtx := Context{
oauth2Client: &oauth2.Config{},
}

type test struct {
name string
url string
expectedRedirectURL string
}
tests := []test{
{
name: "simple publicUrl",
url: "https://flyte.com",
expectedRedirectURL: "https://flyte.com/callback",
},
{
name: "custom subpath",
url: "https://flyte.com/custom-subpath/console",
expectedRedirectURL: "https://flyte.com/custom-subpath/callback",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := authCtx.OAuth2ClientConfig(config.MustParseURL(tt.url))
assert.Equal(t, tt.expectedRedirectURL, cfg.RedirectURL)
})
}
}

0 comments on commit bb76066

Please sign in to comment.