feat: add business line permissions and Wayne namespace mapping
This commit is contained in:
@@ -15,7 +15,7 @@ func TestWayenLoginUsesDedicatedOAuthLoginURL(t *testing.T) {
|
||||
WayenOAuthRef: "/portal/namespace/1/app",
|
||||
}, nil)
|
||||
|
||||
result, err := service.Login("eastsales@qiniu.com", "eastsales@qiniu.com")
|
||||
result, err := service.Login("eastsales@qiniu.com", "eastsales@qiniu.com", "")
|
||||
if err != nil {
|
||||
t.Fatalf("Login() error = %v", err)
|
||||
}
|
||||
@@ -55,7 +55,7 @@ func TestWayenLoginFallsBackToOAuthRedirectURI(t *testing.T) {
|
||||
WayenTargetURL: "http://218.11.5.223:32000/",
|
||||
}, nil)
|
||||
|
||||
result, err := service.Login("eastsales@qiniu.com", "eastsales@qiniu.com")
|
||||
result, err := service.Login("eastsales@qiniu.com", "eastsales@qiniu.com", "")
|
||||
if err != nil {
|
||||
t.Fatalf("Login() error = %v", err)
|
||||
}
|
||||
@@ -67,3 +67,27 @@ func TestWayenLoginFallsBackToOAuthRedirectURI(t *testing.T) {
|
||||
t.Fatalf("target host = %q, want fallback redirect host", parsed.Host)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWayenLoginUsesRefOverride(t *testing.T) {
|
||||
service := NewWayenService(config.Config{
|
||||
WayenOAuthLoginURL: "http://218.11.5.223:32000/login/oauth2/oauth2",
|
||||
WayenTargetURL: "http://218.11.5.223:32000/",
|
||||
WayenOAuthRef: "/portal/namespace/1/app",
|
||||
}, nil)
|
||||
|
||||
result, err := service.Login("eastsales@qiniu.com", "eastsales@qiniu.com", "/portal/namespace/3/app")
|
||||
if err != nil {
|
||||
t.Fatalf("Login() error = %v", err)
|
||||
}
|
||||
parsed, err := url.Parse(result.TargetURL)
|
||||
if err != nil {
|
||||
t.Fatalf("invalid target url: %v", err)
|
||||
}
|
||||
parsedNext, err := url.Parse(parsed.Query().Get("next"))
|
||||
if err != nil {
|
||||
t.Fatalf("invalid next url: %v", err)
|
||||
}
|
||||
if parsedNext.Query().Get("ref") != "/portal/namespace/3/app" {
|
||||
t.Fatalf("next ref = %q", parsedNext.Query().Get("ref"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user