Skip to content
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3626eaa
default medusa policies
carlos-r-l-rodrigues Jan 14, 2026
3f1bb59
rm non used import
carlos-r-l-rodrigues Jan 14, 2026
87ab7ec
check ff to wrap
carlos-r-l-rodrigues Jan 14, 2026
f206dce
types
carlos-r-l-rodrigues Jan 15, 2026
3d825b5
Merge branch 'develop' into chore/apply-middleware-policies
carlos-r-l-rodrigues Jan 15, 2026
73e06a0
wip
carlos-r-l-rodrigues Jan 15, 2026
806c7ea
post endpoints
carlos-r-l-rodrigues Jan 15, 2026
8112f8c
Merge branch 'develop' into chore/apply-middleware-policies
carlos-r-l-rodrigues Jan 15, 2026
658fd93
Merge branch 'chore/apply-middleware-policies' of https://github.com/…
carlos-r-l-rodrigues Jan 15, 2026
df414a7
Merge branch 'chore/apply-middleware-policies' of https://github.com/…
carlos-r-l-rodrigues Jan 15, 2026
c45d80d
POST policies
carlos-r-l-rodrigues Jan 16, 2026
1c60ebb
Merge branch 'chore/apply-middleware-policies' of https://github.com/…
carlos-r-l-rodrigues Jan 16, 2026
f7c1368
remove method all
carlos-r-l-rodrigues Jan 18, 2026
1521c6f
Merge branch 'chore/apply-middleware-policies' of https://github.com/…
carlos-r-l-rodrigues Jan 18, 2026
9fe4b98
create policy
carlos-r-l-rodrigues Jan 19, 2026
54afd6f
Merge branch 'chore/apply-middleware-policies' of https://github.com/…
carlos-r-l-rodrigues Jan 19, 2026
887bb46
missing entity
carlos-r-l-rodrigues Jan 19, 2026
89cc7f0
Merge branch 'chore/apply-middleware-policies' of https://github.com/…
carlos-r-l-rodrigues Jan 19, 2026
951c33d
field alias parse
carlos-r-l-rodrigues Jan 20, 2026
7fb1a48
wrap middleware with policies only
carlos-r-l-rodrigues Jan 20, 2026
62c0e7e
rm log
carlos-r-l-rodrigues Jan 20, 2026
845f9f1
tests
carlos-r-l-rodrigues Jan 20, 2026
48de7d3
rm from rbac
carlos-r-l-rodrigues Jan 20, 2026
72890fe
Merge branch 'develop' into chore/apply-middleware-policies
carlos-r-l-rodrigues Jan 21, 2026
497ff7c
Merge branch 'chore/apply-middleware-policies' into feat/filter-query…
carlos-r-l-rodrigues Jan 21, 2026
6a128dc
update missing policies
carlos-r-l-rodrigues Jan 21, 2026
13afa19
Merge branch 'chore/apply-middleware-policies' into feat/filter-query…
carlos-r-l-rodrigues Jan 21, 2026
eda0ee7
rm policy
carlos-r-l-rodrigues Jan 21, 2026
bc44469
rm duplicate
carlos-r-l-rodrigues Jan 21, 2026
56e17db
Merge branch 'chore/apply-middleware-policies' into feat/filter-query…
carlos-r-l-rodrigues Jan 21, 2026
94a2ae0
Merge branch 'develop' into chore/apply-middleware-policies
carlos-r-l-rodrigues Jan 22, 2026
a6fa291
Merge branch 'chore/apply-middleware-policies' into feat/filter-query…
carlos-r-l-rodrigues Jan 22, 2026
4f44160
Merge branch 'develop' into chore/apply-middleware-policies
carlos-r-l-rodrigues Jan 22, 2026
2cc50b6
Merge branch 'chore/apply-middleware-policies' into feat/filter-query…
carlos-r-l-rodrigues Jan 22, 2026
3b31002
Merge branch 'develop' of https://github.com/medusajs/medusa into fea…
carlos-r-l-rodrigues Jan 22, 2026
780bf31
* resources
carlos-r-l-rodrigues Jan 22, 2026
186026e
rm policis from rbac
carlos-r-l-rodrigues Jan 22, 2026
f14fe3a
chore(): cleanup and improvements
adrien2p Jan 23, 2026
dc014ab
Merge branch 'develop' into feat/filter-query-fields
carlos-r-l-rodrigues Jan 23, 2026
9e11451
new feature flag and better test expectations
carlos-r-l-rodrigues Jan 23, 2026
6e8dd7c
cart route
carlos-r-l-rodrigues Jan 23, 2026
4576745
Merge branch 'develop' into feat/filter-query-fields
carlos-r-l-rodrigues Jan 23, 2026
51b295a
!entity
carlos-r-l-rodrigues Jan 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { dynamicImport, PolicyResource } from "@medusajs/framework/utils"
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
import { readdir } from "fs/promises"
import { isObject } from "lodash"
import { join } from "path"

jest.setTimeout(60000)

medusaIntegrationTestRunner({
env: {
MEDUSA_FF_RBAC: true,
},
testSuite: ({ getContainer }) => {
describe("RBAC - Endpoint entities match policy resources", () => {
it("should have all endpoint entities present in policy resources", async () => {
const adminEndpointEntities = await collectAdminEndpointEntities()
const policyResourceEntities = collectPolicyResourceEntities()

const missingInPolicies = [...adminEndpointEntities].filter(
(entity) => !policyResourceEntities.has(entity)
)

if (missingInPolicies.length > 0) {
console.log(
`\n❌ Missing in policy resources (${missingInPolicies.length}):\n` +
missingInPolicies.sort().join(", ")
)
}

expect(adminEndpointEntities.size).toBeGreaterThan(0)
expect(missingInPolicies).toEqual([])
expect(policyResourceEntities.size).toBeGreaterThan(0)
})
})
},
})

/**
* Collect all Entities from admin endpoint query-config files
*/
async function collectAdminEndpointEntities(): Promise<Set<string>> {
let entities = new Set<string>()
const adminApiPath = join(__dirname, "../../../packages/medusa/src/api/admin")

try {
const directories = await readdir(adminApiPath, { withFileTypes: true })

for (const dir of directories) {
if (!dir.isDirectory()) continue

const queryConfigPath = join(adminApiPath, dir.name, "query-config.ts")

try {
// Use dynamicImport to load the module and access the Entities enum
const moduleExports = await dynamicImport(queryConfigPath)

if (isObject(moduleExports.Entities)) {
entities = new Set(
Array.from(
Object.values(moduleExports.Entities as Record<string, string>)
)
)
}
} catch (error) {
continue
}
}
} catch (error) {
console.error("Error reading admin API directory:", error)
}

return entities
}

/**
* Collect all entities from global PolicyResource registry
*/
function collectPolicyResourceEntities(): Set<string> {
const entities = new Set<string>()

for (const resource of Object.values(PolicyResource)) {
entities.add(resource)
}

return entities
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe("Middleware file loader", () => {
},
]
`)

expect(loader.getMiddlewares()).toMatchInlineSnapshot(`
[
{
Expand Down
Loading