Skip to content

Commit

Permalink
Merge branch 'main' into feature/add_objects_to_inconsistency_log
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jan 8, 2025
2 parents 2288b32 + b25d1cc commit 6dff53f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/runtime/src/modules/DeciderModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,13 @@ function checkCompatibility(requestConfigElement: RequestConfig, requestOrReques
let compatible = true;
for (const property in requestConfigElement) {
const unformattedRequestConfigProperty = requestConfigElement[property as keyof RequestConfig];
if (!unformattedRequestConfigProperty) {
if (typeof unformattedRequestConfigProperty === "undefined") {
continue;
}
const requestConfigProperty = makeObjectsToStrings(unformattedRequestConfigProperty);

const unformattedRequestProperty = getNestedProperty(requestOrRequestItem, property);
if (!unformattedRequestProperty) {
if (typeof unformattedRequestProperty === "undefined") {
compatible = false;
break;
}
Expand Down
2 changes: 0 additions & 2 deletions packages/runtime/src/modules/decide/RequestConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export interface FreeTextRequestItemConfig extends RequestItemConfig {
export interface ProposeAttributeRequestItemConfig extends RequestItemConfig {
"content.item.@type": "ProposeAttributeRequestItem";
"content.item.attribute.@type"?: "IdentityAttribute" | "RelationshipAttribute";
"content.item.attribute.owner"?: string | string[];
"content.item.attribute.validFrom"?: string | string[];
"content.item.attribute.validTo"?: string | string[];
"content.item.attribute.tags"?: string[];
Expand All @@ -73,7 +72,6 @@ export interface ProposeAttributeRequestItemConfig extends RequestItemConfig {
"content.item.query.valueType"?: string | string[];
"content.item.query.tags"?: string[];
"content.item.query.key"?: string | string[];
"content.item.query.owner"?: string | string[];
"content.item.query.queryString"?: string | string[];
"content.item.query.attributeCreationHints.title"?: string | string[];
"content.item.query.attributeCreationHints.description"?: string | string[];
Expand Down
45 changes: 40 additions & 5 deletions packages/runtime/test/modules/DeciderModule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ describe("DeciderModule", () => {
]
};
const recipient = (await runtimeServiceProvider.launch(1, { enableDeciderModule: true, configureDeciderModule: deciderConfig }))[0];
await establishRelationship(sender.transport, recipient.transport);

const request = Request.from({
expiresAt: requestExpirationDate.toString(),
Expand Down Expand Up @@ -437,7 +436,7 @@ describe("DeciderModule", () => {
);
});

test("cannot decide a Request given with an expiration date too high", async () => {
test("cannot decide a Request given a GeneralRequestConfig with an expiration date too high", async () => {
const requestExpirationDate = CoreDate.utc().add({ days: 1 }).toString();
const deciderConfig: DeciderModuleConfigurationOverwrite = {
automationConfig: [
Expand Down Expand Up @@ -467,7 +466,7 @@ describe("DeciderModule", () => {
);
});

test("cannot decide a Request given with an expiration date too low", async () => {
test("cannot decide a Request given a GeneralRequestConfig with an expiration date too low", async () => {
const requestExpirationDate = CoreDate.utc().add({ days: 1 }).toString();
const deciderConfig: DeciderModuleConfigurationOverwrite = {
automationConfig: [
Expand Down Expand Up @@ -885,6 +884,44 @@ describe("DeciderModule", () => {
);
});

test("cannot decide a RequestItem given a RequestItemConfig that doesn't fit the RequestItem regarding a boolean property", async () => {
const deciderConfig: DeciderModuleConfigurationOverwrite = {
automationConfig: [
{
requestConfig: {
"content.item.mustBeAccepted": false
},
responseConfig: {
accept: false
}
}
]
};
const recipient = (await runtimeServiceProvider.launch(1, { enableDeciderModule: true, configureDeciderModule: deciderConfig }))[0];
await establishRelationship(sender.transport, recipient.transport);

const message = await exchangeMessage(sender.transport, recipient.transport);
const receivedRequestResult = await recipient.consumption.incomingRequests.received({
receivedRequest: {
"@type": "Request",
items: [
{
"@type": "AuthenticationRequestItem",
mustBeAccepted: true,
title: "Title of RequestItem"
}
]
},
requestSourceId: message.id
});
await recipient.consumption.incomingRequests.checkPrerequisites({ requestId: receivedRequestResult.value.id });

await expect(recipient.eventBus).toHavePublished(
MessageProcessedEvent,
(e) => e.data.result === MessageProcessedResult.ManualRequestDecisionRequired && e.data.message.id === message.id
);
});

test("cannot decide a RequestItem given a RequestItemConfig with arrays that doesn't fit the RequestItem", async () => {
const deciderConfig: DeciderModuleConfigurationOverwrite = {
automationConfig: [
Expand Down Expand Up @@ -1429,7 +1466,6 @@ describe("DeciderModule", () => {
requestConfig: {
"content.item.@type": "ProposeAttributeRequestItem",
"content.item.attribute.@type": "RelationshipAttribute",
"content.item.attribute.owner": "",
"content.item.attribute.validFrom": attributeValidFrom,
"content.item.attribute.validTo": attributeValidTo,
"content.item.attribute.key": "A key",
Expand All @@ -1443,7 +1479,6 @@ describe("DeciderModule", () => {
"content.item.query.validFrom": attributeValidFrom,
"content.item.query.validTo": attributeValidTo,
"content.item.query.key": "A key",
"content.item.query.owner": "",
"content.item.query.attributeCreationHints.title": "Title of Attribute",
"content.item.query.attributeCreationHints.description": "Description of Attribute",
"content.item.query.attributeCreationHints.valueType": "ProprietaryString",
Expand Down

0 comments on commit 6dff53f

Please sign in to comment.