Skip to content

Commit

Permalink
Fixing bugs found with running integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Nemere committed Jun 21, 2024
1 parent 1763b74 commit 572739f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions api/ws/handlers/image-beam-location.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func HandleImageBeamLocationsReq(req *protos.ImageBeamLocationsReq, hctx wsHelpe
dbScanIds[scanLocs.ScanId] = true
}
scanBeamVersionsToReturn := req.ScanBeamVersions
if scanBeamVersionsToReturn == nil {
scanBeamVersionsToReturn = map[string]uint32{}
}

// If they didn't specify versions to return, return the latest version for each scan represented
if len(scanBeamVersionsToReturn) <= 0 {
Expand Down
2 changes: 1 addition & 1 deletion api/ws/handlers/piquant.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func HandlePiquantWriteCurrentVersionReq(req *protos.PiquantWriteCurrentVersionR
return nil, err
}

if result.MatchedCount != 1 {
if result.MatchedCount != 1 && result.UpsertedCount != 1 {
hctx.Svcs.Log.Errorf("PiquantWriteCurrentVersionReq UpdateByID result had unexpected counts %+v", result)
}

Expand Down
24 changes: 16 additions & 8 deletions api/ws/wsHelpers/ownership.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,20 +324,28 @@ func GetUserIdsForGroup(groupIds []string, mongoDB *mongo.Database) ([]string, e
userIds := []string{}
for _, group := range groups {
// Pull in the users
for _, userId := range group.Viewers.UserIds {
userIds = append(userIds, userId)
if group.Viewers != nil {
for _, userId := range group.Viewers.UserIds {
userIds = append(userIds, userId)
}
}
for _, userId := range group.Members.UserIds {
userIds = append(userIds, userId)
if group.Members != nil {
for _, userId := range group.Members.UserIds {
userIds = append(userIds, userId)
}
}

// Recurse into groups
groupIds := []string{}
for _, groupId := range group.Viewers.GroupIds {
groupIds = append(groupIds, groupId)
if group.Viewers != nil {
for _, groupId := range group.Viewers.GroupIds {
groupIds = append(groupIds, groupId)
}
}
for _, groupId := range group.Members.GroupIds {
groupIds = append(groupIds, groupId)
if group.Members != nil {
for _, groupId := range group.Members.GroupIds {
groupIds = append(groupIds, groupId)
}
}

usersForGroup, err := GetUserIdsForGroup(groupIds, mongoDB)
Expand Down

0 comments on commit 572739f

Please sign in to comment.