From 73482c3401d75261c997b34b14420a456c909353 Mon Sep 17 00:00:00 2001 From: midays <92722851+midays@users.noreply.github.com> Date: Wed, 25 Sep 2024 18:51:48 +0300 Subject: [PATCH] [RFR] Automate_TC MTA-3756 (#1228) * added TC for python custom rule analysis Signed-off-by: midays * PR requested changes Signed-off-by: midays --------- Signed-off-by: midays --- .../analysis/custom-rules.test.ts | 15 +++++++++++++++ cypress/fixtures/analysis.json | 6 ++++++ cypress/fixtures/application.json | 4 ++++ cypress/fixtures/yaml/python-rules.yaml | 17 +++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 cypress/fixtures/yaml/python-rules.yaml diff --git a/cypress/e2e/tests/migration/applicationinventory/analysis/custom-rules.test.ts b/cypress/e2e/tests/migration/applicationinventory/analysis/custom-rules.test.ts index 94595527a..8cea6189c 100644 --- a/cypress/e2e/tests/migration/applicationinventory/analysis/custom-rules.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/analysis/custom-rules.test.ts @@ -130,6 +130,21 @@ describe(["@tier2"], "Bug MTA-2015: Custom Rules in analyses", function () { app.verifyFileNotValidXML(); }); + it("Python custom rules file analysis", function () { + const app = new Analysis( + getRandomApplicationData("python-app-custom-rules", { + sourceData: this.appData["python-demo-app"], + }), + getRandomAnalysisData(this.analysisData["python_demo_application"]) + ); + tackleTestappName = app.name; + applications.push(app); + app.create(); + app.analyze(); + app.verifyAnalysisStatus(AnalysisStatuses.completed); + // TODO: add assertion to check if rules fired once obtained a rules file + }); + after("Clear test data", function () { deleteByList(applications); mavenCredential.delete(); diff --git a/cypress/fixtures/analysis.json b/cypress/fixtures/analysis.json index 1155cbeda..8a8bb8805 100644 --- a/cypress/fixtures/analysis.json +++ b/cypress/fixtures/analysis.json @@ -1225,5 +1225,11 @@ "appName": "bookserver-app", "source": "Source code", "target": ["Application server migration to"] + }, + "python_demo_application": { + "source": "Source code", + "target": [], + "appName": "python-app-custom-rules", + "customRule": ["python-rules.yaml"] } } diff --git a/cypress/fixtures/application.json b/cypress/fixtures/application.json index f2b8a815b..e04fed79d 100644 --- a/cypress/fixtures/application.json +++ b/cypress/fixtures/application.json @@ -75,5 +75,9 @@ "jmh-gradle-example": { "repoType": "Git", "sourceRepo": "https://github.com/melix/jmh-gradle-example" + }, + "python-demo-app": { + "repoType": "Git", + "sourceRepo": "https://github.com/Shopify/sample-django-app" } } diff --git a/cypress/fixtures/yaml/python-rules.yaml b/cypress/fixtures/yaml/python-rules.yaml new file mode 100644 index 000000000..9d50609d4 --- /dev/null +++ b/cypress/fixtures/yaml/python-rules.yaml @@ -0,0 +1,17 @@ +- message: python sample rule 001 + ruleID: python-sample-rule-001 + description: CUSTOM RULE FOR PYTHON + when: + python.referenced: + pattern: "hello_world" +- message: python sample rule 002 + ruleID: python-sample-rule-002 + when: + python.referenced: + pattern: "speak" +- message: python sample rule 003 + ruleID: python-sample-rule-003 + when: + python.referenced: + pattern: "create_custom_resource_definition" +