--- policy: /ce/ca/aws/apigateway/rest-api-stage-ssl-certificate logic: /ce/ca/aws/apigateway/rest-api-stage-ssl-certificate/prod.logic.yaml executionTime: 2026-06-06T12:02:29.373203806Z generationMs: 74 executionMs: 1375 rows: - id: test1 match: true status: expected: DISAPPEARED actual: DISAPPEARED conditionIndex: expected: 99 actual: 99 conditionText: expected: isDisappeared(CA10__disappearanceTime__c) actual: isDisappeared(CA10__disappearanceTime__c) runtimeError: {} - id: test2 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: "not(setOfText(['restApiStage']).contains(RecordType.DeveloperName))" actual: "not(setOfText(['restApiStage']).contains(RecordType.DeveloperName))" runtimeError: {} - id: test3 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__restApi__r.CA10__endpointType__c') == 'PRIVATE' actual: extract('CA10__restApi__r.CA10__endpointType__c') == 'PRIVATE' runtimeError: {} - id: test4 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 399 actual: 399 conditionText: expected: CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.hasNo(COMPLIANT) actual: CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.hasNo(COMPLIANT) runtimeError: {} - id: test5 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: isEmptyLookup('CA10__clientCertificate__r') actual: isEmptyLookup('CA10__clientCertificate__r') runtimeError: {} - id: test6 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: isEmptyLookup('CA10__clientCertificate__r') actual: isEmptyLookup('CA10__clientCertificate__r') runtimeError: {} - id: test7 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: isEmptyLookup('CA10__clientCertificate__r') actual: isEmptyLookup('CA10__clientCertificate__r') runtimeError: {} - id: test8 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 599 actual: 599 conditionText: expected: notEmptyLookup('CA10__clientCertificate__r') actual: notEmptyLookup('CA10__clientCertificate__r') runtimeError: {} usedFiles: - path: /ce/ca/aws/apigateway/rest-api-stage-ssl-certificate/policy.yaml md5Hash: 957C0CA199DCADB864DF43A078249281 content: "---\nnames:\n full: AWS API Gateway REST API Stage is not configured\ \ to use an SSL certificate for authentication\n contextual: REST API Stage\ \ is not configured to use an SSL certificate for authentication\ndescription:\ \ >\n Ensure that the REST API Stage in AWS API Gateway is configured to use\ \ an SSL \n certificate for authentication. This ensures secure communication\ \ between \n backend systems and the API Gateway.\ncategories:\n - \"SECURITY\"\ \ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n - \"/frameworks/cloudaware/secret-and-certificate-governance/cryptographic-configuration\"\ \n - \"/frameworks/aws-fsbp-v1.0.0/api-gateway/02\"\nsimilarPolicies:\n internal:\n\ \ - \"dec-x-d9d39f21\"" - path: /ce/ca/aws/apigateway/rest-api-stage-ssl-certificate/prod.logic.yaml md5Hash: 2D4E40A822058B52700DF88C0F84BF44 content: | --- inputType: "CA10__CaAwsApiGatewayStage__c" importExtracts: - file: "/types/CA10__CaAwsApiGatewayRestApi__c/object.extracts.yaml" testData: - file: test-data.json recordTypes: - "restApiStage" conditions: - status: "INAPPLICABLE" currentStateMessage: "The stage belongs to a private API endpoint." check: IS_EQUAL: left: EXTRACT: "CA10__restApi__r.CA10__endpointType__c" right: TEXT: "PRIVATE" - status: "INAPPLICABLE" currentStateMessage: "The stage does not have HTTP integrations." check: RELATED_LIST_HAS_NO: status: "COMPLIANT" relationshipName: "CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r" - status: "INCOMPLIANT" currentStateMessage: "The stage is not configured to use an SSL certificate." remediationMessage: "Generate an SSL certificate for authentication." check: IS_EMPTY_LOOKUP: "CA10__clientCertificate__r" - status: "COMPLIANT" currentStateMessage: "The stage is configured to use an SSL certificate." check: NOT_EMPTY_LOOKUP: "CA10__clientCertificate__r" otherwise: status: "UNDETERMINED" currentStateMessage: "Unexpected values in the fields." relatedLists: - relationshipName: "CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r" importExtracts: - file: "/types/CA10A1__CaAwsApiGatewayMethod__c/object.extracts.yaml" conditions: - status: "COMPLIANT" currentStateMessage: "This is an HTTP integration." check: OR: args: - IS_EQUAL: left: EXTRACT: "CA10A1__integrationType__c" right: TEXT: "HTTP" - IS_EQUAL: left: EXTRACT: "CA10A1__integrationType__c" right: TEXT: "HTTP_PROXY" otherwise: status: "INAPPLICABLE" currentStateMessage: "This is not an HTTP integration." - path: /ce/ca/aws/apigateway/rest-api-stage-ssl-certificate/test-data.json md5Hash: 5D239AF4482967939B29CD5D5E5307DF content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2024-12-10T20:07:16Z" }, "Id": "test1", "RecordTypeId": "RecordTypeId", "CA10__disappearanceTime__c": "2024-12-10T20:07:16Z", "CA10__restApi__c": "restApi1", "CA10__restApiId__c": "restApiId1", "CA10__clientCertificate__c": "clientCertificate1", "CA10__clientCertificateId__c": "clientCertificateId1", "RecordType": { "DeveloperName": "restApiStage", "Id": "RecordTypeId" }, "CA10__restApi__r": { "Id": "restApi1", "CA10__disappearanceTime__c": null, "CA10__endpointType__c": "REGIONAL", "CA10A1__AWS_API_Gateway_Methods__r": [ { "Id": "test1_1", "CA10A1__disappearanceTime__c": null, "CA10A1__integrationType__c": "HTTP", "CA10A1__restApi__c": "restApi1" } ] }, "CA10__clientCertificate__r": { "Id": "clientCertificate1", "CA10__disappearanceTime__c": null } }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "not(setOfText(['restApiStage']).contains(RecordType.DeveloperName))", "runtimeError": null }, "context": { "snapshotTime": "2024-12-10T20:07:16Z" }, "Id": "test2", "RecordTypeId": "RecordTypeId2", "CA10__disappearanceTime__c": null, "CA10__restApi__c": "restApi2", "CA10__restApiId__c": "restApiId2", "CA10__clientCertificate__c": "clientCertificate2", "CA10__clientCertificateId__c": "clientCertificateId2", "RecordType": { "DeveloperName": "httpApiStage", "Id": "RecordTypeId2" }, "CA10__restApi__r": { "Id": "restApi2", "CA10__disappearanceTime__c": null, "CA10__endpointType__c": "REGIONAL", "CA10A1__AWS_API_Gateway_Methods__r": [ { "Id": "test2_1", "CA10A1__disappearanceTime__c": null, "CA10A1__integrationType__c": "HTTP", "CA10A1__restApi__c": "restApi2" } ] }, "CA10__clientCertificate__r": { "Id": "clientCertificate2", "CA10__disappearanceTime__c": null } }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "299", "conditionText": "extract('CA10__restApi__r.CA10__endpointType__c') == 'PRIVATE'", "runtimeError": null }, "context": { "snapshotTime": "2024-12-10T20:07:16Z" }, "Id": "test3", "RecordTypeId": "RecordTypeId", "CA10__disappearanceTime__c": null, "CA10__restApi__c": "restApi3", "CA10__restApiId__c": "restApiId3", "CA10__clientCertificate__c": "clientCertificate3", "CA10__clientCertificateId__c": "clientCertificateId3", "RecordType": { "DeveloperName": "restApiStage", "Id": "RecordTypeId" }, "CA10__restApi__r": { "Id": "restApi3", "CA10__disappearanceTime__c": null, "CA10__endpointType__c": "PRIVATE", "CA10A1__AWS_API_Gateway_Methods__r": [ { "Id": "test3_1", "CA10A1__disappearanceTime__c": null, "CA10A1__integrationType__c": "HTTP", "CA10A1__restApi__c": "restApi3" } ] }, "CA10__clientCertificate__r": { "Id": "clientCertificate3", "CA10__disappearanceTime__c": null } }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "399", "conditionText": "CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.hasNo(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2024-12-10T20:07:16Z" }, "Id": "test4", "RecordTypeId": "RecordTypeId", "CA10__disappearanceTime__c": null, "CA10__restApi__c": "restApi4", "CA10__restApiId__c": "restApiId4", "CA10__clientCertificate__c": "clientCertificate4", "CA10__clientCertificateId__c": "clientCertificateId4", "RecordType": { "DeveloperName": "restApiStage", "Id": "RecordTypeId" }, "CA10__restApi__r": { "Id": "restApi4", "CA10__disappearanceTime__c": null, "CA10__endpointType__c": "REGIONAL", "CA10A1__AWS_API_Gateway_Methods__r": [ { "Id": "test4_1", "CA10A1__disappearanceTime__c": null, "CA10A1__integrationType__c": "AWS", "CA10A1__restApi__c": "restApi4" } ] }, "CA10__clientCertificate__r": { "Id": "clientCertificate4", "CA10__disappearanceTime__c": null } }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "499", "conditionText": "isEmptyLookup('CA10__clientCertificate__r')", "runtimeError": null }, "context": { "snapshotTime": "2024-12-10T20:07:16Z" }, "Id": "test5", "RecordTypeId": "RecordTypeId", "CA10__disappearanceTime__c": null, "CA10__restApi__c": "restApi5", "CA10__restApiId__c": "restApiId5", "CA10__clientCertificate__c": "clientCertificate5", "CA10__clientCertificateId__c": "clientCertificateId5", "RecordType": { "DeveloperName": "restApiStage", "Id": "RecordTypeId" }, "CA10__restApi__r": { "Id": "restApi5", "CA10__disappearanceTime__c": null, "CA10__endpointType__c": "REGIONAL", "CA10A1__AWS_API_Gateway_Methods__r": [ { "Id": "test5_1", "CA10A1__disappearanceTime__c": null, "CA10A1__integrationType__c": "HTTP", "CA10A1__restApi__c": "restApi5" } ] }, "CA10__clientCertificate__r": { "Id": "clientCertificate5", "CA10__disappearanceTime__c": "2024-12-10T20:07:16Z" } }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "499", "conditionText": "isEmptyLookup('CA10__clientCertificate__r')", "runtimeError": null }, "context": { "snapshotTime": "2024-12-10T20:07:16Z" }, "Id": "test6", "RecordTypeId": "RecordTypeId", "CA10__disappearanceTime__c": null, "CA10__restApi__c": "restApi6", "CA10__restApiId__c": "restApiId6", "CA10__clientCertificate__c": "", "CA10__clientCertificateId__c": "clientCertificateId6", "RecordType": { "DeveloperName": "restApiStage", "Id": "RecordTypeId" }, "CA10__restApi__r": { "Id": "restApi6", "CA10__disappearanceTime__c": null, "CA10__endpointType__c": "REGIONAL", "CA10A1__AWS_API_Gateway_Methods__r": [ { "Id": "test6_1", "CA10A1__disappearanceTime__c": null, "CA10A1__integrationType__c": "HTTP_PROXY", "CA10A1__restApi__c": "restApi6" } ] }, "CA10__clientCertificate__r": { "Id": null, "CA10__disappearanceTime__c": null } }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "499", "conditionText": "isEmptyLookup('CA10__clientCertificate__r')", "runtimeError": null }, "context": { "snapshotTime": "2024-12-10T20:07:16Z" }, "Id": "test7", "RecordTypeId": "RecordTypeId", "CA10__disappearanceTime__c": null, "CA10__restApi__c": "restApi7", "CA10__restApiId__c": "restApiId7", "CA10__clientCertificate__c": "", "CA10__clientCertificateId__c": "", "RecordType": { "DeveloperName": "restApiStage", "Id": "RecordTypeId" }, "CA10__restApi__r": { "Id": "restApi7", "CA10__disappearanceTime__c": null, "CA10__endpointType__c": "REGIONAL", "CA10A1__AWS_API_Gateway_Methods__r": [ { "Id": "test7_1", "CA10A1__disappearanceTime__c": null, "CA10A1__integrationType__c": "HTTP_PROXY", "CA10A1__restApi__c": "restApi7" } ] }, "CA10__clientCertificate__r": { "Id": null, "CA10__disappearanceTime__c": null } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "599", "conditionText": "notEmptyLookup('CA10__clientCertificate__r')", "runtimeError": null }, "context": { "snapshotTime": "2024-12-10T20:07:16Z" }, "Id": "test8", "RecordTypeId": "RecordTypeId", "CA10__disappearanceTime__c": null, "CA10__restApi__c": "restApi8", "CA10__restApiId__c": "restApiId8", "CA10__clientCertificate__c": "clientCertificateId8", "CA10__clientCertificateId__c": "clientCertificateId8", "RecordType": { "DeveloperName": "restApiStage", "Id": "RecordTypeId" }, "CA10__restApi__r": { "Id": "restApi8", "CA10__disappearanceTime__c": null, "CA10__endpointType__c": "REGIONAL", "CA10A1__AWS_API_Gateway_Methods__r": [ { "Id": "test8_1", "CA10A1__disappearanceTime__c": null, "CA10A1__integrationType__c": "HTTP_PROXY", "CA10A1__restApi__c": "restApi8" } ] }, "CA10__clientCertificate__r": { "Id": "clientCertificateId8", "CA10__disappearanceTime__c": null } } ] - path: /types/CA10__CaAwsApiGatewayRestApi__c/object.extracts.yaml md5Hash: 746F09341E8149BAD88C53E274DB1DD5 content: "---\nextracts:\n# Values: HTTP | WEBSOCKET. Nullable. Can't have no\ \ access, retrieved via apigateway:GetApis.\n# Null value indicates REST type\n\ \ - name: CA10__protocolType__c\n value: \n FIELD:\n path: CA10__protocolType__c\n\ # Values: REGIONAL | EDGE | PRIVATE. Not Nullable. Can't have no access, retrieved\ \ via apigateway:GetRestApis.\n - name: CA10__endpointType__c\n value: \n\ \ FIELD:\n path: CA10__endpointType__c" - path: /types/CA10A1__CaAwsApiGatewayMethod__c/object.extracts.yaml md5Hash: E28695D16341F6C70D3B2EE06BCEB425 content: "---\nextracts:\n#Values: HTTP | AWS | MOCK | HTTP_PROXY | AWS_PROXY.\ \ Not Nullable. Can't have no access, retrieved via apigateway:GetMethod.\n\ \ - name: CA10A1__integrationType__c\n value: \n FIELD:\n path:\ \ CA10A1__integrationType__c\n undeterminedIf:\n isEmpty: \"\ Integration Type cannot be empty. Possibly corrupted data.\"" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "DISAPPEARED", "conditionIndex" : "99", "conditionText" : "isDisappeared(CA10__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "not(setOfText(['restApiStage']).contains(RecordType.DeveloperName))", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "299", "conditionText" : "extract('CA10__restApi__r.CA10__endpointType__c') == 'PRIVATE'", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "399", "conditionText" : "CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.hasNo(COMPLIANT)", "runtimeError" : null } }, { "Id" : "test5", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "499", "conditionText" : "isEmptyLookup('CA10__clientCertificate__r')", "runtimeError" : null } }, { "Id" : "test6", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "499", "conditionText" : "isEmptyLookup('CA10__clientCertificate__r')", "runtimeError" : null } }, { "Id" : "test7", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "499", "conditionText" : "isEmptyLookup('CA10__clientCertificate__r')", "runtimeError" : null } }, { "Id" : "test8", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "599", "conditionText" : "notEmptyLookup('CA10__clientCertificate__r')", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayStage__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10__disappearanceTime__c" : new Date("2024-12-10T20:07:16Z"), "CA10__restApi__c" : "restApi1", "CA10__restApiId__c" : "restApiId1", "CA10__clientCertificate__c" : "clientCertificate1", "CA10__clientCertificateId__c" : "clientCertificateId1", "Id" : "test1", "RecordTypeId" : "RecordTypeId" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10__restApi__c" : "restApi2", "CA10__restApiId__c" : "restApiId2", "CA10__clientCertificate__c" : "clientCertificate2", "CA10__clientCertificateId__c" : "clientCertificateId2", "Id" : "test2", "RecordTypeId" : "RecordTypeId2" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10__restApi__c" : "restApi3", "CA10__restApiId__c" : "restApiId3", "CA10__clientCertificate__c" : "clientCertificate3", "CA10__clientCertificateId__c" : "clientCertificateId3", "Id" : "test3", "RecordTypeId" : "RecordTypeId" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10__restApi__c" : "restApi4", "CA10__restApiId__c" : "restApiId4", "CA10__clientCertificate__c" : "clientCertificate4", "CA10__clientCertificateId__c" : "clientCertificateId4", "Id" : "test4", "RecordTypeId" : "RecordTypeId" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10__restApi__c" : "restApi5", "CA10__restApiId__c" : "restApiId5", "CA10__clientCertificate__c" : "clientCertificate5", "CA10__clientCertificateId__c" : "clientCertificateId5", "Id" : "test5", "RecordTypeId" : "RecordTypeId" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10__restApi__c" : "restApi6", "CA10__restApiId__c" : "restApiId6", "CA10__clientCertificate__c" : "", "CA10__clientCertificateId__c" : "clientCertificateId6", "Id" : "test6", "RecordTypeId" : "RecordTypeId" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10__restApi__c" : "restApi7", "CA10__restApiId__c" : "restApiId7", "CA10__clientCertificate__c" : "", "CA10__clientCertificateId__c" : "", "Id" : "test7", "RecordTypeId" : "RecordTypeId" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10__restApi__c" : "restApi8", "CA10__restApiId__c" : "restApiId8", "CA10__clientCertificate__c" : "clientCertificateId8", "CA10__clientCertificateId__c" : "clientCertificateId8", "Id" : "test8", "RecordTypeId" : "RecordTypeId" } ]; """; CREATE TEMP FUNCTION mock_RecordType() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "DeveloperName" : "restApiStage", "Id" : "RecordTypeId" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "DeveloperName" : "httpApiStage", "Id" : "RecordTypeId2" } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayRestApi__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "restApi1", "CA10__endpointType__c" : "REGIONAL" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "restApi2", "CA10__endpointType__c" : "REGIONAL" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "restApi3", "CA10__endpointType__c" : "PRIVATE" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "restApi4", "CA10__endpointType__c" : "REGIONAL" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "restApi5", "CA10__endpointType__c" : "REGIONAL" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "restApi6", "CA10__endpointType__c" : "REGIONAL" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "restApi7", "CA10__endpointType__c" : "REGIONAL" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "restApi8", "CA10__endpointType__c" : "REGIONAL" } ]; """; CREATE TEMP FUNCTION mock_CA10A1__CaAwsApiGatewayMethod__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10A1__integrationType__c" : "HTTP", "CA10A1__restApi__c" : "restApi1", "Id" : "test1_1" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10A1__integrationType__c" : "HTTP", "CA10A1__restApi__c" : "restApi2", "Id" : "test2_1" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10A1__integrationType__c" : "HTTP", "CA10A1__restApi__c" : "restApi3", "Id" : "test3_1" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10A1__integrationType__c" : "AWS", "CA10A1__restApi__c" : "restApi4", "Id" : "test4_1" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10A1__integrationType__c" : "HTTP", "CA10A1__restApi__c" : "restApi5", "Id" : "test5_1" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10A1__integrationType__c" : "HTTP_PROXY", "CA10A1__restApi__c" : "restApi6", "Id" : "test6_1" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10A1__integrationType__c" : "HTTP_PROXY", "CA10A1__restApi__c" : "restApi7", "Id" : "test7_1" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "CA10A1__integrationType__c" : "HTTP_PROXY", "CA10A1__restApi__c" : "restApi8", "Id" : "test8_1" } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayClientCertificate__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "clientCertificate1" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "clientCertificate2" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "clientCertificate3" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "clientCertificate4" }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "clientCertificate5", "CA10__disappearanceTime__c" : new Date("2024-12-10T20:07:16Z") }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : null }, { "context" : { "snapshotTime" : new Date("2024-12-10T20:07:16Z") }, "Id" : "clientCertificateId8" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsApiGatewayStage__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, RecordType STRUCT< DeveloperName STRING, Id STRING >, CA10__restApi__r STRUCT< Id STRING, CA10__disappearanceTime__c TIMESTAMP, CA10__endpointType__c STRING, CA10A1__AWS_API_Gateway_Methods__r ARRAY >> >, CA10__restApi__c STRING, CA10__restApiId__c STRING, CA10__clientCertificate__r STRUCT< Id STRING, CA10__disappearanceTime__c TIMESTAMP >, CA10__clientCertificate__c STRING, CA10__clientCertificateId__c STRING, Id STRING, RecordTypeId STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var CollectionLib = new function () { this.parse = function(arg, separator, skipEmpty, skipDuplicates, sort, normalize) { if (arg == null) return []; let parts = arg.split(separator); return this.fromArray(parts, skipEmpty, skipDuplicates, sort, normalize); }; this.fromArray = function(arr, skipEmpty, skipDuplicates, sort, normalize) { if (arr == null) return []; let result = []; let seen = new Set(); arr.forEach(el => { let normalized = normalize ? TextLib.normalize(el) : BytesLib.normalize(el); if (!skipEmpty || (normalize ? TextLib.isNotEmpty(el) : BytesLib.isNotEmpty(el))) { if (!skipDuplicates || !seen.has(normalized)) { if (skipDuplicates) seen.add(normalized); result.push(normalized); } } }); if (sort) result.sort(); return result; }; this.equal = function(left, right) { left = left == null ? [] : left; right = right == null ? [] : right; if (left.length !== right.length) return false; for (let i = 0; i < left.length; i++) { if (left[i] !== right[i]) return false; } return true; }; this.notEqual = function(left, right) { return !this.equal(left, right); }; this.size = function(collection) { return collection == null ? 0 : collection.length; }; this.startsWith = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; let normalizedSearch = normalize ? TextLib.normalize(search) : BytesLib.normalize(search); return collection[0] === normalizedSearch; }; this.endsWith = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; let normalizedSearch = normalize ? TextLib.normalize(search) : BytesLib.normalize(search); return collection[collection.length - 1] === normalizedSearch; }; this.contains = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; return collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search)); }; this.containsAll = function(collection, searchArray, normalize) { if (collection == null || collection.length === 0 || searchArray == null || searchArray.length === 0) return false; return searchArray.every(search => collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search))); }; this.containsAny = function(collection, searchArray, normalize) { if (collection == null || collection.length === 0 || searchArray == null || searchArray.length === 0) return false; return searchArray.some(search => collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search))); }; }(); var BytesLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg; }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var TextLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase(); }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c); if (obj.CA10__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[1], conditionIndex:[100..199] references1.push('Record Type Name [obj.RecordType.DeveloperName]: ' + obj.RecordType.DeveloperName); if (!CollectionLib.contains(CollectionLib.fromArray(['restApiStage'], true, true, true, true), obj.RecordType.DeveloperName, true)) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "not(setOfText(['restApiStage']).contains(RecordType.DeveloperName))", currentStateMessage: "Object record type is not applicable", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extractChecked3() { if (TextLib.isEmpty(obj.CA10__restApiId__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "extractCheck(obj.CA10__restApiId__c)", currentStateMessage: "Related object via CA10__restApiId__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } if (TextLib.isEmpty(obj.CA10__restApi__c)) { throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extractCheck(obj.CA10__restApi__c)", currentStateMessage: "Related object via CA10__restApi__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } if (obj.CA10__restApi__r.CA10__disappearanceTime__c != null) { throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extractCheck(obj.CA10__restApi__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__restApi__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return extract4.call(extract4); } function extract4() { if (!this.out) { this.out = obj.CA10__restApi__r.CA10__endpointType__c; } return this.out; }; references1.push('Endpoint Type [obj.CA10__restApi__r.CA10__endpointType__c]: ' + obj.CA10__restApi__r.CA10__endpointType__c); try { if (TextLib.equal(extractChecked3(), 'PRIVATE')) { return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10__restApi__r.CA10__endpointType__c') == 'PRIVATE'", currentStateMessage: "The stage belongs to a private API endpoint.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } var count_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r_COMPLIANT6 = 0; if (obj.CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r != null) { for (var i7 = 0; i7 < obj.CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.length; i7++) { if (typeof(obj.CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r[i7].status) !== 'undefined') { if (obj.CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r[i7].status == 'COMPLIANT') { count_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r_COMPLIANT6 += obj.CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r[i7].count; } } else { if (obj.CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r[i7].result.status == 'COMPLIANT') { count_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r_COMPLIANT6 += 1; } } } } // condition[3], conditionIndex:[300..399] references1.push('Related list [CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r] ' + (count_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r_COMPLIANT6 == 0 ? 'does not have' : 'has') + ' objects in COMPLIANT status'); if (count_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r_COMPLIANT6 == 0) { return {status: 'INAPPLICABLE', conditionIndex: 399, conditionText: "CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.hasNo(COMPLIANT)", currentStateMessage: "The stage does not have HTTP integrations.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[4], conditionIndex:[400..499] if (TextLib.isEmpty(obj.CA10__clientCertificateId__c) || TextLib.isEmpty(obj.CA10__clientCertificate__c) || obj.CA10__clientCertificate__r.CA10__disappearanceTime__c != null) { return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "isEmptyLookup('CA10__clientCertificate__r')", currentStateMessage: "The stage is not configured to use an SSL certificate.", currentStateReferences: references1.join('\n'), remediation: "Generate an SSL certificate for authentication.", runtimeError: null}; } // condition[5], conditionIndex:[500..599] if (TextLib.isNotEmpty(obj.CA10__clientCertificateId__c) && TextLib.isNotEmpty(obj.CA10__clientCertificate__c) && obj.CA10__clientCertificate__r.CA10__disappearanceTime__c == null) { return {status: 'COMPLIANT', conditionIndex: 599, conditionText: "notEmptyLookup('CA10__clientCertificate__r')", currentStateMessage: "The stage is configured to use an SSL certificate.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'UNDETERMINED', conditionIndex: 600, conditionText: "otherwise", currentStateMessage: "Unexpected values in the fields.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r( obj STRUCT< CA10A1__disappearanceTime__c TIMESTAMP, CA10A1__integrationType__c STRING, CA10A1__restApi__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var TextLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase(); }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From AWS [CA10A1__disappearanceTime__c]: ' + obj.CA10A1__disappearanceTime__c); if (obj.CA10A1__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10A1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[1], conditionIndex:[100..199] function fieldChecked4() { if (TextLib.isEmpty(obj.CA10A1__integrationType__c)) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10A1__integrationType__c.isEmpty()", currentStateMessage: "Integration Type cannot be empty. Possibly corrupted data.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10A1__integrationType__c; } function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; }; references1.push('Integration Type [obj.CA10A1__integrationType__c]: ' + obj.CA10A1__integrationType__c); try { if (TextLib.equal(extract3.call(extract3), 'HTTP') || TextLib.equal(extract3.call(extract3), 'HTTP_PROXY')) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10A1__integrationType__c') == 'HTTP' || extract('CA10A1__integrationType__c') == 'HTTP_PROXY'", currentStateMessage: "This is an HTTP integration.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'INAPPLICABLE', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "This is not an HTTP integration.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; SELECT expectedResult.Id as Id, IF ( IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '') AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1) AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '') AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''), "MATCH", "FAIL" ) as match, expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus, expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex, expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText, expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError FROM UNNEST(mock_ExpectedResult()) expectedResult LEFT JOIN ( SELECT sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, STRUCT ( `CA10__restApi__r`.Id AS Id, `CA10__restApi__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, `CA10__restApi__r`.CA10__endpointType__c AS CA10__endpointType__c, `CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r`.arr AS CA10A1__AWS_API_Gateway_Methods__r ) AS CA10__restApi__r, sObject.CA10__restApi__c AS CA10__restApi__c, sObject.CA10__restApiId__c AS CA10__restApiId__c, STRUCT ( `CA10__clientCertificate__r`.Id AS Id, `CA10__clientCertificate__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c ) AS CA10__clientCertificate__r, sObject.CA10__clientCertificate__c AS CA10__clientCertificate__c, sObject.CA10__clientCertificateId__c AS CA10__clientCertificateId__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, process_CA10__CaAwsApiGatewayStage__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, STRUCT ( `CA10__restApi__r`.Id AS Id, `CA10__restApi__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, `CA10__restApi__r`.CA10__endpointType__c AS CA10__endpointType__c, `CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r`.arr AS CA10A1__AWS_API_Gateway_Methods__r ) AS CA10__restApi__r, sObject.CA10__restApi__c AS CA10__restApi__c, sObject.CA10__restApiId__c AS CA10__restApiId__c, STRUCT ( `CA10__clientCertificate__r`.Id AS Id, `CA10__clientCertificate__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c ) AS CA10__clientCertificate__r, sObject.CA10__clientCertificate__c AS CA10__clientCertificate__c, sObject.CA10__clientCertificateId__c AS CA10__clientCertificateId__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsApiGatewayStage__c()) AS sObject LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType` ON sObject.RecordTypeId = `RecordType`.Id LEFT JOIN UNNEST(mock_CA10__CaAwsApiGatewayRestApi__c()) AS `CA10__restApi__r` ON sObject.CA10__restApi__c = `CA10__restApi__r`.Id LEFT JOIN UNNEST(mock_CA10__CaAwsApiGatewayClientCertificate__c()) AS `CA10__clientCertificate__r` ON sObject.CA10__clientCertificate__c = `CA10__clientCertificate__r`.Id LEFT JOIN ( SELECT sObject.CA10A1__restApi__c, ARRAY_AGG( STRUCT( sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__integrationType__c AS CA10A1__integrationType__c, sObject.CA10A1__restApi__c AS CA10A1__restApi__c, sObject.Id AS Id, process_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r( STRUCT( sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__integrationType__c AS CA10A1__integrationType__c, sObject.CA10A1__restApi__c AS CA10A1__restApi__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10A1__CaAwsApiGatewayMethod__c()) AS sObject GROUP BY sObject.CA10A1__restApi__c ) AS `CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r` ON `CA10__restApi__r`.Id = `CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r`.CA10A1__restApi__c ) sObject ON sObject.Id = expectedResult.Id;