forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Modify the callback URL string in auth flow, to support custom b…
…ase URLs in deployments (flyteorg#5192) * x Signed-off-by: ddl-rliu <[email protected]> x Signed-off-by: ddl-rliu <[email protected]> x Signed-off-by: ddl-rliu <[email protected]> * x Signed-off-by: ddl-rliu <[email protected]> --------- Signed-off-by: ddl-rliu <[email protected]> Signed-off-by: Eduardo Apolinario <[email protected]> Co-authored-by: Eduardo Apolinario <[email protected]>
- Loading branch information
1 parent
084991f
commit b6166c6
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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", | ||
}, | ||
{ | ||
name: "complex publicUrl", | ||
url: "https://flyte.com/login?redirect_url=https://flyte.com/console/select-project", | ||
expectedRedirectURL: "https://flyte.com/callback", | ||
}, | ||
{ | ||
name: "complex publicUrl with custom subpath", | ||
url: "https://flyte.com/custom-subpath/login?redirect_url=https://flyte.com/custom-subpath/console/select-project", | ||
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) | ||
}) | ||
} | ||
} |