mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-27 12:46:03 +01:00
Merge pull request #2699 from ywk253100/170704_integration
Fix bugs found in test
This commit is contained in:
commit
b51b3ea5ac
@ -28,9 +28,9 @@ const (
|
|||||||
// AuthTokenHeader is the key of auth token header
|
// AuthTokenHeader is the key of auth token header
|
||||||
AuthTokenHeader = "x-xenon-auth-token"
|
AuthTokenHeader = "x-xenon-auth-token"
|
||||||
sysAdminRole = "CLOUD_ADMIN"
|
sysAdminRole = "CLOUD_ADMIN"
|
||||||
projectAdminRole = "DEVOPS_ADMIN"
|
projectAdminRole = "PROJECT_ADMIN"
|
||||||
developerRole = "DEVELOPER"
|
developerRole = "PROJECT_MEMBER"
|
||||||
guestRole = "GUEST"
|
guestRole = "PROJECT_VIEWER"
|
||||||
)
|
)
|
||||||
|
|
||||||
type project struct {
|
type project struct {
|
||||||
|
@ -604,14 +604,14 @@ func (ra *RepositoryAPI) GetTopRepos() {
|
|||||||
projectIDs := []int64{}
|
projectIDs := []int64{}
|
||||||
projects, err := ra.ProjectMgr.GetPublic()
|
projects, err := ra.ProjectMgr.GetPublic()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to get the public projects: %v", err)
|
ra.HandleInternalServerError(fmt.Sprintf("failed to get public projects: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ra.SecurityCtx.IsAuthenticated() {
|
if ra.SecurityCtx.IsAuthenticated() {
|
||||||
list, err := ra.ProjectMgr.GetByMember(ra.SecurityCtx.GetUsername())
|
list, err := ra.ProjectMgr.GetByMember(ra.SecurityCtx.GetUsername())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to get projects which the user %s is a member of: %v",
|
ra.HandleInternalServerError(fmt.Sprintf("failed to get projects which the user %s is a member of: %v",
|
||||||
ra.SecurityCtx.GetUsername(), err)
|
ra.SecurityCtx.GetUsername(), err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
projects = append(projects, list...)
|
projects = append(projects, list...)
|
||||||
|
@ -120,9 +120,15 @@ func initProjectManager() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path := os.Getenv("SERVICE_TOKEN_FILE_PATH")
|
||||||
|
if len(path) == 0 {
|
||||||
|
path = defaultTokenFilePath
|
||||||
|
}
|
||||||
|
log.Infof("service token file path: %s", path)
|
||||||
GlobalProjectMgr = pms.NewProjectManager(AdmiralClient,
|
GlobalProjectMgr = pms.NewProjectManager(AdmiralClient,
|
||||||
AdmiralEndpoint(), &pms.FileTokenReader{
|
AdmiralEndpoint(), &pms.FileTokenReader{
|
||||||
Path: defaultTokenFilePath,
|
Path: path,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ func (b *basicAuthReqCtxModifier) Modify(ctx *beegoctx.Context) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("using glocal project manager...")
|
log.Debug("using global project manager...")
|
||||||
pm := config.GlobalProjectMgr
|
pm := config.GlobalProjectMgr
|
||||||
log.Debug("creating admiral security context...")
|
log.Debug("creating admiral security context...")
|
||||||
securCtx := admiral.NewSecurityContext(authCtx, pm)
|
securCtx := admiral.NewSecurityContext(authCtx, pm)
|
||||||
|
@ -65,7 +65,7 @@ func (n *NotificationHandler) Post() {
|
|||||||
user = "anonymous"
|
user = "anonymous"
|
||||||
}
|
}
|
||||||
|
|
||||||
pro, err := n.ProjectMgr.Get(project)
|
pro, err := config.GlobalProjectMgr.Get(project)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to get project by name %s: %v", project, err)
|
log.Errorf("failed to get project by name %s: %v", project, err)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user