fix authorization hierarchy in postman import (#4686)

Co-authored-by: nivedin <nivedinp@gmail.com>
This commit is contained in:
Anwarul Islam 2025-01-29 14:02:57 +06:00 committed by GitHub
parent e22fbecb56
commit fa1159da53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -197,12 +197,17 @@ type PMRequestAuthDef<
const getVariableValue = (defs: VariableDefinition[], key: string) =>
defs.find((param) => param.key === key)?.value as string | undefined
const getHoppReqAuth = (hoppAuth: Item["request"]["auth"]): HoppRESTAuth => {
if (!hoppAuth) return { authType: "none", authActive: true }
const getHoppReqAuth = (
hoppAuth: Item["request"]["auth"] | null
): HoppRESTAuth => {
if (!hoppAuth) return { authType: "inherit", authActive: false }
// Cast to the type for more stricter checking down the line
const auth = hoppAuth as unknown as PMRequestAuthDef
if (auth.type === "noauth") {
return { authType: "none", authActive: true }
}
if (auth.type === "basic") {
return {
authType: "basic",
@ -269,7 +274,7 @@ const getHoppReqAuth = (hoppAuth: Item["request"]["auth"]): HoppRESTAuth => {
}
}
return { authType: "none", authActive: true }
return { authType: "inherit", authActive: true }
}
const getHoppReqBody = ({
@ -413,7 +418,7 @@ const getHoppFolder = (ig: ItemGroup<Item>): HoppCollection =>
A.map(getHoppFolder)
),
requests: pipe(ig.items.all(), A.filter(isPMItem), A.map(getHoppRequest)),
auth: { authType: "inherit", authActive: true },
auth: getHoppReqAuth(ig.auth),
headers: [],
})