mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 10:45:45 +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 = "x-xenon-auth-token"
|
||||
sysAdminRole = "CLOUD_ADMIN"
|
||||
projectAdminRole = "DEVOPS_ADMIN"
|
||||
developerRole = "DEVELOPER"
|
||||
guestRole = "GUEST"
|
||||
projectAdminRole = "PROJECT_ADMIN"
|
||||
developerRole = "PROJECT_MEMBER"
|
||||
guestRole = "PROJECT_VIEWER"
|
||||
)
|
||||
|
||||
type project struct {
|
||||
|
@ -604,14 +604,14 @@ func (ra *RepositoryAPI) GetTopRepos() {
|
||||
projectIDs := []int64{}
|
||||
projects, err := ra.ProjectMgr.GetPublic()
|
||||
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
|
||||
}
|
||||
if ra.SecurityCtx.IsAuthenticated() {
|
||||
list, err := ra.ProjectMgr.GetByMember(ra.SecurityCtx.GetUsername())
|
||||
if err != nil {
|
||||
log.Errorf("failed to get projects which the user %s is a member of: %v",
|
||||
ra.SecurityCtx.GetUsername(), err)
|
||||
ra.HandleInternalServerError(fmt.Sprintf("failed to get projects which the user %s is a member of: %v",
|
||||
ra.SecurityCtx.GetUsername(), err))
|
||||
return
|
||||
}
|
||||
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,
|
||||
AdmiralEndpoint(), &pms.FileTokenReader{
|
||||
Path: defaultTokenFilePath,
|
||||
Path: path,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ func (b *basicAuthReqCtxModifier) Modify(ctx *beegoctx.Context) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
log.Debug("using glocal project manager...")
|
||||
log.Debug("using global project manager...")
|
||||
pm := config.GlobalProjectMgr
|
||||
log.Debug("creating admiral security context...")
|
||||
securCtx := admiral.NewSecurityContext(authCtx, pm)
|
||||
|
@ -65,7 +65,7 @@ func (n *NotificationHandler) Post() {
|
||||
user = "anonymous"
|
||||
}
|
||||
|
||||
pro, err := n.ProjectMgr.Get(project)
|
||||
pro, err := config.GlobalProjectMgr.Get(project)
|
||||
if err != nil {
|
||||
log.Errorf("failed to get project by name %s: %v", project, err)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user