Details
Description
All queries to the REST geoserver/rest/workspaces/{workspace}/wmsstores/{wmsstore}/wmslayers and geoserver/rest/workspaces/{workspace}/coveragestores/{coveragestore}/coverages endpoints return results in the default workspace if such a store exists there.
This means that if you have a store in the default workspace and a different store with the same name in another workspace, querying for layers in the second store will actually return layers from the first store.
Steps to reproduce:
Assume ws1 is the default workspace and ws2 is some other workspace.
Create a cascaded WMS store named foo in ws1 and a different cascaded wms store in ws2 with the same name.
Query localhost:8080/geoserver/rest/workspaces/ws2/wmsstores/foo/wmslayers. The result will list the layers from the store in ws1 instead of the store in ws2.