feat(hub): issue trusted Device Core session claims
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
isInternalRequestTokenAuthorized,
|
||||
isInternalRequestTokenConfigured,
|
||||
} from "./internal-request-auth.mjs";
|
||||
|
||||
describe("scoped internal request authorization", () => {
|
||||
it("accepts the Device Core key only for Device Core handoff calls", () => {
|
||||
const base = {
|
||||
authorization: "Bearer device-core-file-token",
|
||||
globalToken: "broad-platform-token",
|
||||
scopedToken: "device-core-file-token",
|
||||
};
|
||||
expect(isInternalRequestTokenAuthorized({ ...base, serviceSlug: "device-core" })).toBe(true);
|
||||
expect(isInternalRequestTokenAuthorized({ ...base, serviceSlug: "module-foundry" })).toBe(false);
|
||||
expect(isInternalRequestTokenAuthorized(base)).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps the existing global token valid for existing internal callers", () => {
|
||||
expect(isInternalRequestTokenAuthorized({
|
||||
authorization: "Bearer broad-platform-token",
|
||||
globalToken: "broad-platform-token",
|
||||
scopedToken: "device-core-file-token",
|
||||
serviceSlug: "module-foundry",
|
||||
})).toBe(true);
|
||||
});
|
||||
|
||||
it("reports scoped configuration only for the bound service", () => {
|
||||
expect(isInternalRequestTokenConfigured({
|
||||
scopedToken: "device-core-file-token",
|
||||
serviceSlug: "device-core",
|
||||
})).toBe(true);
|
||||
expect(isInternalRequestTokenConfigured({
|
||||
scopedToken: "device-core-file-token",
|
||||
serviceSlug: "operational-core",
|
||||
})).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user