Skip to content

Commit

Permalink
Asset storage improved, implemented asset service logic + more #3553
Browse files Browse the repository at this point in the history
- formatted code
- wrote unit tests
- wrote integration test
- wrote DB tests
- implemented logic inside asset service
- wrote DAUI actions
- added missing license headers
  • Loading branch information
de-jcup committed Nov 7, 2024
1 parent d5795e6 commit 6e1dacb
Show file tree
Hide file tree
Showing 58 changed files with 1,287 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.domain.administration.project;

import static org.assertj.core.api.Assertions.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SecHubStorageUtil {
public static String createStoragePathForProject(String projectId) {
return "jobstorage/" + projectId;
}

public static String createAssetStoragePath() {
return "assets";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.commons.model.template;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.mercedesbenz.sechub.commons.model.JSONable;

@JsonPropertyOrder({ "id", "type", "variables", "assets" })
public class TemplateDefinition implements JSONable<TemplateDefinition> {

private static TemplateDefinition IMPORTER = new TemplateDefinition();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.commons.model.template;

import com.mercedesbenz.sechub.commons.core.MustBeKeptStable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.commons.model.template;

import static com.mercedesbenz.sechub.commons.model.template.TemplateIdenifierConstants.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.commons.model.template;

import static org.assertj.core.api.Assertions.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.mercedesbenz.sechub.commons.pds.PDSDefaultParameterKeyConstants;
import com.mercedesbenz.sechub.developertools.admin.ui.ConfigurationSetup;
import com.mercedesbenz.sechub.developertools.admin.ui.UIContext;
import com.mercedesbenz.sechub.domain.scan.asset.AssetDetailData;
import com.mercedesbenz.sechub.domain.scan.product.pds.PDSProductExecutorKeyConstants;
import com.mercedesbenz.sechub.domain.scan.product.pds.SecHubProductExecutionPDSKeyProvider;
import com.mercedesbenz.sechub.integrationtest.api.AsPDSUser;
Expand Down Expand Up @@ -821,4 +822,40 @@ public void createOrUpdateTemplate(String templateId, TemplateDefinition templat
asTestUser().createOrUpdateTemplate(templateId, templateDefinition);
}

public void assignTemplateToProject(String templateId, String projectId) {
asTestUser().assignTemplateToProject(templateId, new FixedTestProject(projectId));
}

public void unassignTemplateFromProject(String templateId, String projectId) {
asTestUser().unassignTemplateFromProject(templateId, new FixedTestProject(projectId));
}

public List<String> fetchAllTemplateIdentifiers() {
return asTestUser().fetchTemplateList();
}

public List<String> fetchAllAssetIdentifiers() {
return asTestUser().fetchAllAssetIds();
}

public void uploadAssetFile(String assetId, File file) {
asTestUser().uploadAssetFile(assetId, file);
}

public AssetDetailData fetchAssetDetails(String assetId) {
return asTestUser().fetchAssetDetails(assetId);
}

public void deleteAsset(String assetId) {
asTestUser().deleteAsset(assetId);
}

public void deleteAssetFile(String assetId, String fileName) {
asTestUser().deleteAssetFile(assetId, fileName);
}

public File downloadAssetFile(String assetId, String fileName) {
return asTestUser().downloadAssetFile(assetId, fileName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.mercedesbenz.sechub.developertools.admin.ui.action.ActionSupport;
import com.mercedesbenz.sechub.developertools.admin.ui.action.adapter.ShowProductExecutorTemplatesDialogAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.asset.ManageAssetsAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.client.TriggerSecHubClientSynchronousScanAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.config.ConfigureAutoCleanupAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.config.ConfigurePDSAutoCleanupAction;
Expand Down Expand Up @@ -96,7 +97,10 @@
import com.mercedesbenz.sechub.developertools.admin.ui.action.scheduler.RefreshSchedulerStatusAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.status.CheckStatusAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.status.ListStatusEntriesAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.template.AssignTemplateToProjectAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.template.CreateOrUpdateTemplateAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.template.FetchAllTemplateIdentifiersAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.template.UnassignTemplateFromProjectAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.user.AcceptUserSignupAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.user.AnonymousRequestNewAPITokenUserAction;
import com.mercedesbenz.sechub.developertools.admin.ui.action.user.AnonymousSigninNewUserAction;
Expand Down Expand Up @@ -255,6 +259,12 @@ public void createConfigMenu() {
JMenu templatesMenu = new JMenu("Templates");
menu.add(templatesMenu);
add(templatesMenu, new CreateOrUpdateTemplateAction(context));
add(templatesMenu, new FetchAllTemplateIdentifiersAction(context));

add(templatesMenu, new AssignTemplateToProjectAction(context));
add(templatesMenu, new UnassignTemplateFromProjectAction(context));

menu.add(new ManageAssetsAction(context));

}

Expand Down
Loading

0 comments on commit 6e1dacb

Please sign in to comment.