Skip to content

Commit 5708584

Browse files
committed
fix(cinder): retain project filter with all-tenants requests
Signed-off-by: Senol Colak <senol.colak@sap.com>
1 parent f0a70f9 commit 5708584

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎internal/cinder/spec028_conformance_test.go‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,19 @@ func TestVolumeListAllTenantsAndProjectFilter_DB(t *testing.T) {
304304
if code != http.StatusOK || !strings.Contains(body, otherVol) || strings.Contains(body, ownVol) {
305305
t.Errorf("admin volumes?project_id=<other>: code=%d body=%s; want only the other project's volume", code, body)
306306
}
307+
// OSC 7.0.0's --project sends BOTH parameters. The explicit filter must
308+
// still select only that project's volumes on both list endpoints.
309+
for _, path := range []string{"/v3/volumes", "/v3/volumes/detail"} {
310+
query := path + "?all_tenants=1&project_id=" + otherProject
311+
code, body = doReq(r, http.MethodGet, query, "", adminHdr)
312+
if code != http.StatusOK || !strings.Contains(body, otherVol) || strings.Contains(body, ownVol) {
313+
t.Errorf("admin %s: code=%d body=%s; want only the other project's volume", query, code, body)
314+
}
315+
code, body = doReq(r, http.MethodGet, query, "", memberHdr)
316+
if code != http.StatusOK || strings.Contains(body, otherVol) || !strings.Contains(body, ownVol) {
317+
t.Errorf("member %s: code=%d body=%s; want only the member's volume", query, code, body)
318+
}
319+
}
307320
// Admin + all_tenants: both appear.
308321
code, body = doReq(r, http.MethodGet, "/v3/volumes/detail?all_tenants", "", adminHdr)
309322
if code != http.StatusOK || !strings.Contains(body, otherVol) || !strings.Contains(body, ownVol) {

‎internal/cinder/volumes.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,10 @@ func volumeListScope(c *gin.Context) (tenant string, allTenants bool) {
692692
if !common.HasRole(c, common.RoleAdmin) {
693693
return "", false
694694
}
695-
if common.QueryFlag(c, "all_tenants") {
696-
return "", true
697-
}
698-
return c.Query("project_id"), false
695+
// OSC sends all_tenants together with project_id for --project. Keep
696+
// the explicit project filter: all_tenants enables cross-project access,
697+
// it does not discard the requested scope.
698+
return c.Query("project_id"), common.QueryFlag(c, "all_tenants")
699699
}
700700

701701
func (svc *Service) ListVolumes(c *gin.Context) {

0 commit comments

Comments
 (0)