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

Fixes in required fields and default testid for frontend #680

Merged
merged 10 commits into from
Jan 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
import com.akto.dao.context.Context;
import com.akto.dao.test_editor.TestConfigYamlParser;
import com.akto.dao.test_editor.YamlTemplateDao;
import com.akto.dao.test_editor.info.InfoParser;
import com.akto.dao.testing.TestingRunResultDao;
import com.akto.dto.AccountSettings;
import com.akto.dto.ApiInfo;
import com.akto.dto.CustomAuthType;
import com.akto.dto.User;
import com.akto.dto.test_editor.Category;
import com.akto.dto.test_editor.Info;
import com.akto.dto.test_editor.TestConfig;
import com.akto.dto.test_editor.TestLibrary;
import com.akto.dto.test_editor.YamlTemplate;
Expand All @@ -32,6 +35,7 @@
import com.akto.testing.TestExecutor;
import com.akto.util.Constants;
import com.akto.util.enums.GlobalEnums;
import com.akto.util.enums.GlobalEnums.YamlTemplateSource;
import com.akto.utils.GithubSync;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
Expand Down Expand Up @@ -102,7 +106,23 @@ public String saveTestEditorFile() {
Map<String, Object> config = mapper.readValue(content, Map.class);
Object info = config.get("info");
if (info == null) {
addActionError("Error in template: info key absent");
addActionError("info is null");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this to original

return ERROR.toUpperCase();
}

// adding all necessary fields check for info in editor
InfoParser parser = new InfoParser();
Info convertedInfo = parser.parse(info);

if (convertedInfo.getName() == null || convertedInfo.getDescription() == null
|| convertedInfo.getDetails() == null || convertedInfo.getCategory() == null
|| convertedInfo.getSeverity() == null || convertedInfo.getSubCategory() == null) {
addActionError("info information is not complete.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this error message more descriptive, this is unclear

return ERROR.toUpperCase();
}

Category category = convertedInfo.getCategory();
if (category.getName() == null || category.getDisplayName() == null || category.getShortName() == null) {
return ERROR.toUpperCase();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ const TestEditor = () => {
<TopBar secondaryMenu={headerComp} />
)

const defaultId = "REMOVE_TOKENS";

useEffect(() => {
const path = window.location.pathname;
const pathArr = path.split("test-editor")
if(pathArr[1].length < 2){
navigate(defaultId)
}
fetchAllTests()
}, [])

Expand Down
4 changes: 4 additions & 0 deletions apps/dashboard/web/polaris_web/web/src/apps/main/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ const router = createBrowserRouter([
path: "test-editor/:testId",
element: <TestEditor />
},
{
path: "test-editor",
element: <TestEditor />
},
{
path: "onboarding",
element: <Onboarding />
Expand Down
Loading