feat(foundry): support restricted subject aspects
This commit is contained in:
@@ -24,13 +24,29 @@ test("dynamic sensor readings are fail-closed until ids are explicitly classifie
|
||||
test("restricted fields and reading ids cannot be introduced through MCP profiles", () => {
|
||||
const restrictedField = structuredClone(registry.profiles[0]);
|
||||
restrictedField.tabs[0].sections[0].fields[0].field = "api_key";
|
||||
assert.throws(() => normalizeMapSubjectDetailProfile(restrictedField), /map_subject_detail_profile_restricted_field/);
|
||||
assert.throws(() => normalizeMapSubjectDetailProfile(restrictedField), /map_subject_detail_profile_secret_field/);
|
||||
|
||||
const restrictedReading = structuredClone(registry.profiles[0]);
|
||||
restrictedReading.tabs.find((tab) => tab.id === "telemetry").sections[0].fields[0].allowedReadingIds = ["sensor.imei"];
|
||||
assert.throws(() => normalizeMapSubjectDetailProfile(restrictedReading), /map_subject_detail_profile_restricted_reading_id/);
|
||||
});
|
||||
|
||||
test("restricted identifiers require an explicit restricted presentation class", () => {
|
||||
const profile = structuredClone(registry.profiles[0]);
|
||||
const field = profile.tabs[0].sections[0].fields[0];
|
||||
field.field = "device_phone_primary";
|
||||
field.label = "Телефон 1";
|
||||
assert.throws(
|
||||
() => normalizeMapSubjectDetailProfile(profile),
|
||||
/map_subject_detail_profile_restricted_field/,
|
||||
);
|
||||
field.dataClass = "restricted";
|
||||
assert.equal(
|
||||
normalizeMapSubjectDetailProfile(profile).tabs[0].sections[0].fields[0].dataClass,
|
||||
"restricted",
|
||||
);
|
||||
});
|
||||
|
||||
test("profiles reject unknown schema fields and duplicate presentation ids", () => {
|
||||
const unknown = structuredClone(registry.profiles[0]);
|
||||
unknown.provider = "gelios";
|
||||
|
||||
Reference in New Issue
Block a user