Merge pull request #2699 from ywk253100/170704_integration

Fix bugs found in test
This commit is contained in:
Wenkai Yin 2017-07-04 17:42:43 +08:00 committed by GitHub
commit b51b3ea5ac
5 changed files with 15 additions and 9 deletions

View File

@ -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 {

View File

@ -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...)

View File

@ -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,
})
}

View File

@ -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)

View File

@ -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