Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev to Main Merge 9/12 #222

Merged
merged 7 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ It has the following features -
- [FCA URL deployed and available in the S3](#fca-url-deployed-and-available-in-the-s3)
- [Below are the steps to run FCA in local system](#below-are-the-steps-to-run-fca-in-local-system)
- [Supported ways of Execution](#supported-ways-of-execution)
- [Sanity Suite Flow](./docs/index.md)
- [Supported targets](#supported-targets)
- [Supported Modes of execution](#supported-modes-of-execution)
- [Supported validations](#supported-validations)
Expand Down
Binary file added docs/images/generateAPIValidaionResult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/testRunnerFlow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Sanity Suite Flow chart

## Implementation
![Implementation Diagram](./images/testRunnerFlow.png)

## Generating Report Logs
![Manual Trigger Diagram](./images/generateAPIValidaionResult.png)
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"version": "1.2.0",
"version": "1.3.0",
"name": "firebolt-certification",
"description": "Reference App to demonstrate Firebolt APIs and Lifecycle",
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^9.0.9",
"@firebolt-js/discovery-sdk": "1.2.0",
"@firebolt-js/manage-sdk": "1.2.0",
"@firebolt-js/sdk": "1.2.0",
"@firebolt-js/discovery-sdk": "1.3.0",
"@firebolt-js/manage-sdk": "1.3.0",
"@firebolt-js/sdk": "1.3.0",
"@lightningjs/core": "2.11.0",
"@lightningjs/sdk": "^5.0.1",
"@lightningjs/ui-components": "^2.2.2",
Expand Down
4 changes: 2 additions & 2 deletions src/EventInvocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class EventInvocation {
let schemaValidationResult = {};
let schemaValidationStatus = CONSTANTS.PASS;
if (message.params.isNotSupportedApi == true) {
schemaValidationResult = errorSchemaCheck(listenerResponse, process.env.COMMUNICATION_MODE);
schemaValidationResult = errorSchemaCheck(listenerResponse);
schemaValidationStatus = CONSTANTS.FAIL;
}
registrationResponse['eventListenerSchemaResult'] = {
Expand All @@ -153,7 +153,7 @@ export class EventInvocation {
}
registrationResponse['eventListenerResponse'] = { result: null, error: listenerResponse };
// In case of error, validate error against errorschema
const schemaValidationResult = errorSchemaCheck(listenerResponse, process.env.COMMUNICATION_MODE);
const schemaValidationResult = errorSchemaCheck(listenerResponse);
if (schemaValidationResult && schemaValidationResult.errors && schemaValidationResult.errors.length > 0) {
registrationResponse['eventListenerSchemaResult'] = {
status: CONSTANTS.FAIL,
Expand Down
4 changes: 2 additions & 2 deletions src/MethodInvoker.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class MethodInvoker {
if (process.env.STANDALONE == true) {
// if the method is not supported and it gives a valid response, validate against errorschema instead of api schema
if (message.params.isNotSupportedApi == true && response != undefined) {
schemaValidationResult = errorSchemaCheck(response, process.env.COMMUNICATION_MODE);
schemaValidationResult = errorSchemaCheck(response);
}
}
} catch (error) {
Expand Down Expand Up @@ -135,7 +135,7 @@ export class MethodInvoker {
let apiResponse, responseCode, schemaValidationStatus;
if (err) {
apiResponse = { result: null, error: err };
schemaValidationResult = errorSchemaCheck(err, process.env.COMMUNICATION_MODE);
schemaValidationResult = errorSchemaCheck(err);
if (schemaValidationResult && schemaValidationResult.errors && schemaValidationResult.errors.length > 0) {
if (err.message != undefined && CONSTANTS.ERROR_LIST.includes(err.message)) {
responseCode = CONSTANTS.STATUS_CODE[3];
Expand Down
533 changes: 165 additions & 368 deletions src/Test_Runner.js

Large diffs are not rendered by default.

30 changes: 12 additions & 18 deletions src/ValidationView.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default class ValidationView extends lng.Component {
},
color: 0xff123456,
},
ContentValidationStateText: {
Message: {
x: 530,
y: 200,
w: 1920 - 700,
Expand Down Expand Up @@ -198,7 +198,7 @@ export default class ValidationView extends lng.Component {
this.tag('UpdateText').text = CONSTANTS.VALIDATION_SCROLLMESSAGE;
this.tag('ApititleText').text = '';
this.tag('SchemaValidationStateText').text = '';
this.tag('ContentValidationStateText').text = '';
this.tag('Message').text = '';
this.tag('ValidationData').text = '';
}
} else {
Expand Down Expand Up @@ -230,45 +230,39 @@ export default class ValidationView extends lng.Component {
const { err, fail, code } = _displayparms;
this.tag('ValidationData').color = 0xff123456;
let schemaValidationStateText = null,
contentValidationStateText = null,
message = null,
validationData = null;
if (code != undefined) {
let codeObject = null,
isCodeTypeObject = true,
messageString = null;
try {
codeObject = JSON.parse(_displayparms.code);
messageString = codeObject.Message;
if (typeof codeObject.Message != 'string') {
messageString = JSON.stringify(codeObject.Message, null, 1);
messageString = codeObject.Response;
if (typeof codeObject.Response != 'string') {
messageString = JSON.stringify(codeObject.Response, null, 1);
}
isCodeTypeObject = true;
} catch (err) {
isCodeTypeObject = false;
}
if (isCodeTypeObject) {
schemaValidationStateText = CONSTANTS.SCHEMA_VALIDATION_STATUSMESSAGE + codeObject.Schema;
contentValidationStateText = CONSTANTS.CONTENT_VALIDATION_STATUSMESSAGE + codeObject.Content;
if (fail) {
validationData = CONSTANTS.ERROR_MESSAGE + messageString;
} else {
validationData = CONSTANTS.API_RESPONSE + messageString;
}
schemaValidationStateText = CONSTANTS.SCHEMA_VALIDATION_STATUSMESSAGE + codeObject['Schema Validation'];
message = 'Message: ' + codeObject.Message;
validationData = CONSTANTS.API_RESPONSE + messageString;
} else {
schemaValidationStateText = CONSTANTS.SCHEMA_VALIDATION_STATUSMESSAGE + CONSTANTS.SCHEMA_CONTENT_SKIPPED;
contentValidationStateText = CONSTANTS.CONTENT_VALIDATION_STATUSMESSAGE + CONSTANTS.SCHEMA_CONTENT_SKIPPED;
validationData = CONSTANTS.ERROR_MESSAGE + 'JSON parse failed (ValidationView)';
validationData = CONSTANTS.API_RESPONSE + 'JSON parse failed (ValidationView)';
}
} else {
// Remove if not needed after testing
schemaValidationStateText = CONSTANTS.SCHEMA_VALIDATION_STATUSMESSAGE + CONSTANTS.SCHEMA_CONTENT_SKIPPED;
contentValidationStateText = CONSTANTS.CONTENT_VALIDATION_STATUSMESSAGE + CONSTANTS.SCHEMA_CONTENT_SKIPPED;
validationData = CONSTANTS.ERROR_MESSAGE + 'Received response as undefined';
validationData = CONSTANTS.API_RESPONSE + 'Received response as undefined';
}
// Updating values in UI
this.tag('ApititleText').text = CONSTANTS.API_TITLE + _displayparms.fullTitle;
this.tag('SchemaValidationStateText').text = schemaValidationStateText;
this.tag('ContentValidationStateText').text = contentValidationStateText;
this.tag('Message').text = message;

/*
Schema data for some APIs are large enough to break the render engine.
Expand Down
6 changes: 3 additions & 3 deletions src/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const CONSTANTS = {
CONTENT_ERROR: 'Content Error',
RDK_SERVICES: 'org.rdk.',
API_TITLE: 'API TITLE: ',
API_RESPONSE: 'API Response: ',
API_RESPONSE: 'Response: ',
INVOKE_TEST_MESSAGE: '**** Click Invoke to run tests ****',
VALIDATION_MESSAGE: '***** Validation Started ******',
VALIDATION_SCROLLMESSAGE: "Scroll down through the menu's to view the result",
Expand Down Expand Up @@ -172,6 +172,6 @@ export const CONSTANTS = {
EXCLUDED_METHODS_FOR_MFOS: [],
...CONFIG_CONSTANTS,
VERSIONS: 'Versions',
ERROR_SCHEMA_TRANSPORT: 'errorSchemaTransport',
ERROR_SCHEMA_SDK: 'errorSchemaSDK',
NO_RESULT_OR_ERROR_MESSAGE: 'No result or error in response. eg: {jsonrpc: "2.0", id: x }',
SCHEMA_VALIDATION: 'Schema Validation',
};
2 changes: 1 addition & 1 deletion src/pubsub/handlers/RunTestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class RunTestHandler extends BaseHandler {

async getValidationReport(message) {
const sdkMode = message.action;
process.env.COMMUNICATION_MODE = message.context.communicationMode;
process.env.COMMUNICATION_MODE = message.context.communicationMode ? message.context.communicationMode : CONSTANTS.TRANSPORT;

const sdkInvokerInfo = new Test_Runner();
let validatedMenu;
Expand Down
76 changes: 21 additions & 55 deletions src/source/errorSchema.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,23 @@
{
"errorSchemaSDK": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"code",
"message"
],
"properties": {
"code": {
"title": "errorObjectCode",
"description": "A Number that indicates the error type that occurred. This MUST be an integer. The error codes from and including -32768 to -32000 are reserved for pre-defined errors. These pre-defined errors SHOULD be assumed to be returned from any JSON-RPC api.",
"type": "integer"
},
"message": {
"title": "errorObjectMessage",
"description": "A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.",
"type": "string"
},
"data": {
"title": "errorObjectData",
"description": "A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.)."
}
}
},
{
"type": "string"
}
]
},
"errorSchemaTransport": {
"type": "object",
"additionalProperties": false,
"required": [
"code",
"message"
],
"properties": {
"code": {
"title": "errorObjectCode",
"description": "A Number that indicates the error type that occurred. This MUST be an integer. The error codes from and including -32768 to -32000 are reserved for pre-defined errors. These pre-defined errors SHOULD be assumed to be returned from any JSON-RPC api.",
"type": "integer"
},
"message": {
"title": "errorObjectMessage",
"description": "A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.",
"type": "string"
},
"data": {
"title": "errorObjectData",
"description": "A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.)."
}
}
"errorSchema": {
"type": "object",
"additionalProperties": false,
"required": ["code", "message"],
"properties": {
"code": {
"title": "errorObjectCode",
"description": "A Number that indicates the error type that occurred. This MUST be an integer. The error codes from and including -32768 to -32000 are reserved for pre-defined errors. These pre-defined errors SHOULD be assumed to be returned from any JSON-RPC api.",
"type": "integer"
},
"message": {
"title": "errorObjectMessage",
"description": "A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.",
"type": "string"
},
"data": {
"title": "errorObjectData",
"description": "A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.)."
}
}
}
}
}
10 changes: 4 additions & 6 deletions src/utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import { CONSTANTS } from '../constant';
import FireboltExampleInvoker from '../FireboltExampleInvoker';
import errorSchema from '../source/errorSchema.json';
import errorSchemaObject from '../source/errorSchema.json';
import censorDataJson from 'CensorData';

const { v4: uuidv4 } = require('uuid');
Expand Down Expand Up @@ -117,7 +117,6 @@ async function getschemaValidationDone(name, response, sdkType) {
* @param response - response of the method
*/
function censorData(methodName, response) {
let json;
try {
const json = censorDataJson;
if (methodName in json) {
Expand Down Expand Up @@ -292,11 +291,10 @@ function filterExamples(programlist, programType, offeringType) {
return offeringList;
}

function errorSchemaCheck(err, communicationMode) {
function errorSchemaCheck(err) {
let schemaValidationResult;
if (errorSchema) {
const errorSchemaBasedOnMode = communicationMode == CONSTANTS.TRANSPORT ? errorSchema[CONSTANTS.ERROR_SCHEMA_TRANSPORT] : errorSchema[CONSTANTS.ERROR_SCHEMA_SDK];
schemaValidationResult = validator.validate(err, errorSchemaBasedOnMode);
if (errorSchemaObject) {
schemaValidationResult = validator.validate(err, errorSchemaObject.errorSchema);
}
return schemaValidationResult;
}
Expand Down
Loading
Loading