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

Fixing testing bugs #1531

Merged
merged 2 commits into from
Sep 21, 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
164 changes: 0 additions & 164 deletions apps/dashboard/web/polaris_web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions apps/dashboard/web/polaris_web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"@fortawesome/react-fontawesome": "^0.2.0",
"@mui/material": "^5.9.2",
"@mui/x-date-pickers": "^5.0.0",
"@sentry/cli": "^2.25.0",
"@sentry/react": "^7.93.0",
"@shopify/polaris": "^11.2.1",
"@stigg/react-sdk": "^4.8.0",
"@testing-library/jest-dom": "^5.16.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function TestRoleSettings() {
const [searchParams] = useSearchParams();
const systemRole = searchParams.get("system")

const isDataInState = location?.state != undefined && Object.keys(location?.state).length > 0
const isDataInState = location.state && location?.state !== undefined && Object.keys(location?.state).length > 0
const isDataInSearch = searchParams.get("name")
const isNew = !isDataInState && !isDataInSearch
const pageTitle = isNew ? "Add test role" : "Configure test role"
Expand Down Expand Up @@ -82,9 +82,7 @@ function TestRoleSettings() {
}
useEffect(() => {
if (!isNew) {

let newItems = initialItems

if (isDataInState) {
newItems = location.state
setInitialItems(location.state);
Expand Down Expand Up @@ -127,7 +125,6 @@ function TestRoleSettings() {
}

const saveAction = async (updatedAuth=false, authWithCondLists = null) => {
setRefresh(!refresh)
let andConditions = transform.filterContainsConditions(conditions, 'AND')
let orConditions = transform.filterContainsConditions(conditions, 'OR')
if (!(andConditions || orConditions) || roleName.length == 0) {
Expand Down Expand Up @@ -158,6 +155,9 @@ function TestRoleSettings() {
}
}
}
setTimeout(() => {
setRefresh(!refresh)
},200)
}

const handleTextChange = (val) => {
Expand Down
20 changes: 0 additions & 20 deletions apps/dashboard/web/polaris_web/web/src/apps/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,6 @@ import en from "@shopify/polaris/locales/en.json";
import { StiggProvider } from '@stigg/react-sdk';
import "@shopify/polaris/build/esm/styles.css";
import ExpiredApp from "./ExpiredApp"
import * as Sentry from "@sentry/react";

Sentry.init({
dsn: "https://ddf19fb1a875f83cfa3baa1a8efe35d0@o4506573945438208.ingest.sentry.io/4506574714306560",
integrations: [
new Sentry.BrowserTracing({
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ["*"],
}),
new Sentry.Replay({
maskAllText: false,
blockAllMedia: false,
}),
],
// Performance Monitoring
tracesSampleRate: 1.0, // Capture 100% of the transactions
// Session Replay
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
});

const container = document.getElementById("root");
const root = createRoot(container);
Expand Down
15 changes: 14 additions & 1 deletion apps/testing/src/main/java/com/akto/testing/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.akto.util.DashboardMode;
import com.akto.util.EmailAccountName;
import com.akto.util.enums.GlobalEnums;
import com.akto.util.enums.GlobalEnums.Severity;
import com.mongodb.BasicDBObject;
import com.mongodb.ConnectionString;
import com.mongodb.client.model.*;
Expand Down Expand Up @@ -70,6 +71,14 @@ public class Main {
public static boolean SKIP_SSRF_CHECK = ("true".equalsIgnoreCase(System.getenv("SKIP_SSRF_CHECK")) || !DashboardMode.isSaasDeployment());
public static final boolean IS_SAAS = "true".equalsIgnoreCase(System.getenv("IS_SAAS"));

private static Map<String, Integer> emptyCountIssuesMap = new HashMap<>();

static {
emptyCountIssuesMap.put(Severity.HIGH.toString(), 0);
emptyCountIssuesMap.put(Severity.MEDIUM.toString(), 0);
emptyCountIssuesMap.put(Severity.LOW.toString(), 0);
}

private static TestingRunResultSummary createTRRSummaryIfAbsent(TestingRun testingRun, int start){
ObjectId testingRunId = new ObjectId(testingRun.getHexId());

Expand All @@ -80,7 +89,9 @@ private static TestingRunResultSummary createTRRSummaryIfAbsent(TestingRun testi
),
Updates.combine(
Updates.set(TestingRunResultSummary.STATE, TestingRun.State.RUNNING),
Updates.setOnInsert(TestingRunResultSummary.START_TIMESTAMP, start)
Updates.setOnInsert(TestingRunResultSummary.START_TIMESTAMP, start),
Updates.set(TestingRunResultSummary.TEST_RESULTS_COUNT, 0),
Updates.set(TestingRunResultSummary.COUNT_ISSUES, emptyCountIssuesMap)
),
new FindOneAndUpdateOptions().upsert(true).returnDocument(ReturnDocument.AFTER)
);
Expand Down Expand Up @@ -371,6 +382,8 @@ public void run() {
trrs.setId(new ObjectId());
trrs.setStartTimestamp(start);
trrs.setState(State.RUNNING);
trrs.setTestResultsCount(0);
trrs.setCountIssues(emptyCountIssuesMap);
TestingRunResultSummariesDao.instance.insertOne(trrs);
summaryId = trrs.getId();
} else {
Expand Down
Loading