Support user consent flow (#1293)
* Introduce user consent flow * Add permissions to confirmation management * rename from consent to confirmation * Reformat code. Remove unused imports. Change and add permission checks when configuring auto-confirmation. * Do not include null values for DDI confirmation base endpoint * fix confirmation required checkbox id * Remove unused import. Fix consume/produce type of new API's. * Change term processing to proceeding when activating user consent flow * Align formatting and extend integration test cases for DMF and DDI. * Extend DMF test cases to consider auto-confirmation * Refactor action management to fix problem of handling action status updates on closed actions. * remove unsupported validation * use new confirmation api for DMF. Extend test cases., * Remove unnecessary fields. * Extend API documentation for DDI and MGMT API. * adapt ddi api docs adoc file * Fixed the duplicate migration version for db files * fix method to support confirmation * Fixed PR comments * Addressed PR comments * Fixed after merge compilation issue * Fixed after merge compilation issue * Fix failing tests in MgmtRolloutResourceTest * Fixed the permissions issue reflected by integration tests * Added back the missing line of code lost during merge * Fix the failing test on Jenkins Signed-off-by: Stanislav Trailov <stanislav.trailov@bosch.io> Signed-off-by: Dimitar Shterev <dimitar.shterev@bosch.io> Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io> Signed-off-by: Shruthi Manavalli Ramanna <shruthimanavalli.ramanna@bosch-si.com> Co-authored-by: Shruthi Manavalli Ramanna <shruthimanavalli.ramanna@bosch-si.com>
This commit is contained in:
@@ -26,6 +26,7 @@ public class MgmtTargetAssignmentRequestBody {
|
||||
private MgmtActionType type;
|
||||
private MgmtMaintenanceWindowRequestBody maintenanceWindow;
|
||||
private Integer weight;
|
||||
private Boolean confirmationRequired;
|
||||
|
||||
/**
|
||||
* JsonCreator Constructor
|
||||
@@ -77,4 +78,12 @@ public class MgmtTargetAssignmentRequestBody {
|
||||
public void setMaintenanceWindow(final MgmtMaintenanceWindowRequestBody maintenanceWindow) {
|
||||
this.maintenanceWindow = maintenanceWindow;
|
||||
}
|
||||
|
||||
public Boolean isConfirmationRequired() {
|
||||
return confirmationRequired;
|
||||
}
|
||||
|
||||
public void setConfirmationRequired(final boolean confirmationRequired) {
|
||||
this.confirmationRequired = confirmationRequired;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package org.eclipse.hawkbit.mgmt.json.model.rollout;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroup;
|
||||
@@ -38,6 +39,9 @@ public class MgmtRolloutRestRequestBody extends AbstractMgmtRolloutConditionsEnt
|
||||
@JsonProperty(required = false)
|
||||
private Integer weight;
|
||||
|
||||
@JsonProperty(required = false)
|
||||
private Boolean confirmationRequired;
|
||||
|
||||
private MgmtActionType type;
|
||||
|
||||
private List<MgmtRolloutGroup> groups;
|
||||
@@ -161,4 +165,21 @@ public class MgmtRolloutRestRequestBody extends AbstractMgmtRolloutConditionsEnt
|
||||
public void setWeight(final Integer weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only considered if confirmation flow active
|
||||
*
|
||||
* @return if the confirmation is required for this rollout
|
||||
*/
|
||||
public Boolean isConfirmationRequired() {
|
||||
return confirmationRequired;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param confirmationRequired
|
||||
* if the confirmation is required for this rollout
|
||||
*/
|
||||
public void setConfirmationRequired(final boolean confirmationRequired) {
|
||||
this.confirmationRequired = confirmationRequired;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public class MgmtRolloutGroup extends AbstractMgmtRolloutConditionsEntity {
|
||||
|
||||
private String targetFilterQuery;
|
||||
private Float targetPercentage;
|
||||
private Boolean confirmationRequired;
|
||||
|
||||
public String getTargetFilterQuery() {
|
||||
return targetFilterQuery;
|
||||
@@ -38,4 +39,12 @@ public class MgmtRolloutGroup extends AbstractMgmtRolloutConditionsEntity {
|
||||
public void setTargetPercentage(Float targetPercentage) {
|
||||
this.targetPercentage = targetPercentage;
|
||||
}
|
||||
|
||||
public Boolean isConfirmationRequired() {
|
||||
return confirmationRequired;
|
||||
}
|
||||
|
||||
public void setConfirmationRequired(final Boolean confirmationRequired) {
|
||||
this.confirmationRequired = confirmationRequired;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ public class MgmtDistributionSetAssignment extends MgmtId {
|
||||
private long forcetime;
|
||||
@JsonProperty(required = false)
|
||||
private Integer weight;
|
||||
@JsonProperty(required = false)
|
||||
private Boolean confirmationRequired;
|
||||
private MgmtActionType type;
|
||||
private MgmtMaintenanceWindowRequestBody maintenanceWindow;
|
||||
|
||||
@@ -77,4 +79,12 @@ public class MgmtDistributionSetAssignment extends MgmtId {
|
||||
public void setMaintenanceWindow(final MgmtMaintenanceWindowRequestBody maintenanceWindow) {
|
||||
this.maintenanceWindow = maintenanceWindow;
|
||||
}
|
||||
|
||||
public Boolean isConfirmationRequired() {
|
||||
return confirmationRequired;
|
||||
}
|
||||
|
||||
public void setConfirmationRequired(final Boolean confirmationRequired) {
|
||||
this.confirmationRequired = confirmationRequired;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,9 @@ public class MgmtTarget extends MgmtNamedEntity {
|
||||
@JsonProperty
|
||||
private String targetTypeName;
|
||||
|
||||
@JsonProperty
|
||||
private Boolean autoConfirmActive;
|
||||
|
||||
/**
|
||||
* @return Target type ID
|
||||
*/
|
||||
@@ -221,4 +224,13 @@ public class MgmtTarget extends MgmtNamedEntity {
|
||||
public void setRequestAttributes(final boolean requestAttributes) {
|
||||
this.requestAttributes = requestAttributes;
|
||||
}
|
||||
|
||||
public Boolean getAutoConfirmActive() {
|
||||
return autoConfirmActive;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setAutoConfirmActive(final boolean autoConfirmActive) {
|
||||
this.autoConfirmActive = autoConfirmActive;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* Copyright (c) 2022 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.json.model.target;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Response representing the current state of auto-confirmation for a specific target
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonPropertyOrder({ "active", "initiator", "remark", "activatedAt" })
|
||||
public class MgmtTargetAutoConfirm extends RepresentationModel<MgmtTargetAutoConfirm> {
|
||||
@NotNull
|
||||
private boolean active;
|
||||
private String initiator;
|
||||
private String remark;
|
||||
private Long activatedAt;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public MgmtTargetAutoConfirm() {
|
||||
// needed for json create.
|
||||
}
|
||||
|
||||
public static MgmtTargetAutoConfirm active(final long activatedAt) {
|
||||
final MgmtTargetAutoConfirm state = new MgmtTargetAutoConfirm();
|
||||
state.setActive(true);
|
||||
state.setActivatedAt(activatedAt);
|
||||
return state;
|
||||
}
|
||||
|
||||
public static MgmtTargetAutoConfirm disabled() {
|
||||
return new MgmtTargetAutoConfirm();
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(final boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public Long getActivatedAt() {
|
||||
return activatedAt;
|
||||
}
|
||||
|
||||
public void setActivatedAt(final long activatedAt) {
|
||||
this.activatedAt = activatedAt;
|
||||
}
|
||||
|
||||
public String getInitiator() {
|
||||
return initiator;
|
||||
}
|
||||
|
||||
public void setInitiator(final String initiator) {
|
||||
this.initiator = initiator;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(final String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (c) 2022 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.json.model.target;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Payload to activate the auto-confirmation by given initiator and remark.
|
||||
*/
|
||||
public class MgmtTargetAutoConfirmUpdate {
|
||||
@JsonProperty(required = false)
|
||||
private final String initiator;
|
||||
|
||||
@JsonProperty(required = false)
|
||||
private final String remark;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param initiator
|
||||
* can be null
|
||||
* @param remark
|
||||
* can be null
|
||||
*/
|
||||
@JsonCreator
|
||||
public MgmtTargetAutoConfirmUpdate(@JsonProperty(value = "initiator") final String initiator,
|
||||
@JsonProperty(value = "remark") final String remark) {
|
||||
this.initiator = initiator;
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getInitiator() {
|
||||
return initiator;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MgmtTargetAutoConfirm [initiator=" + initiator + ", remark=" + remark + ", toString()="
|
||||
+ super.toString() + "]";
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,9 @@ public class MgmtDistributionSetAutoAssignment extends MgmtId {
|
||||
@JsonProperty(required = false)
|
||||
private Integer weight;
|
||||
|
||||
@JsonProperty(required = false)
|
||||
private Boolean confirmationRequired;
|
||||
|
||||
public MgmtActionType getType() {
|
||||
return type;
|
||||
}
|
||||
@@ -40,4 +43,12 @@ public class MgmtDistributionSetAutoAssignment extends MgmtId {
|
||||
public void setWeight(final Integer weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public Boolean isConfirmationRequired() {
|
||||
return confirmationRequired;
|
||||
}
|
||||
|
||||
public void setConfirmationRequired(final Boolean confirmationRequired) {
|
||||
this.confirmationRequired = confirmationRequired;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ public class MgmtTargetFilterQuery extends MgmtBaseEntity {
|
||||
@JsonProperty
|
||||
private Integer autoAssignWeight;
|
||||
|
||||
@JsonProperty
|
||||
private Boolean confirmationRequired;
|
||||
|
||||
public Long getFilterId() {
|
||||
return filterId;
|
||||
}
|
||||
@@ -90,4 +93,12 @@ public class MgmtTargetFilterQuery extends MgmtBaseEntity {
|
||||
public void setAutoAssignWeight(final Integer autoAssignWeight) {
|
||||
this.autoAssignWeight = autoAssignWeight;
|
||||
}
|
||||
|
||||
public Boolean getConfirmationRequired() {
|
||||
return confirmationRequired;
|
||||
}
|
||||
|
||||
public void setConfirmationRequired(final Boolean confirmationRequired) {
|
||||
this.confirmationRequired = confirmationRequired;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,21 @@ public final class MgmtRestConstants {
|
||||
*/
|
||||
public static final String TARGET_V1_ASSIGNED_TARGET_TYPE = "targetType";
|
||||
|
||||
/**
|
||||
* The target URL mapping, href link for autoConfirm state of a target.
|
||||
*/
|
||||
public static final String TARGET_V1_AUTO_CONFIRM = "autoConfirm";
|
||||
|
||||
/**
|
||||
* The target URL mapping, href link activate auto-confirm on a target.
|
||||
*/
|
||||
public static final String TARGET_V1_ACTIVATE_AUTO_CONFIRM = "activate";
|
||||
|
||||
/**
|
||||
* The target URL mapping, href link deactivate auto-confirm on a target.
|
||||
*/
|
||||
public static final String TARGET_V1_DEACTIVATE_AUTO_CONFIRM = "deactivate";
|
||||
|
||||
/**
|
||||
* The target URL mapping, href link for assigned distribution set.
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentR
|
||||
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtDistributionSetAssignments;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAttributes;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirm;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirmUpdate;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -31,6 +33,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@@ -396,12 +399,47 @@ public interface MgmtTargetRestApi {
|
||||
* the ID of the targetId to create meta data for
|
||||
* @param metadataRest
|
||||
* the list of meta data entries to create
|
||||
* @return status created if post request is successful with the value of
|
||||
* the created meta data
|
||||
* @return status created if post request is successful with the value of the
|
||||
* created meta data
|
||||
*/
|
||||
@PostMapping(value = "/{targetId}/metadata", consumes = { MediaType.APPLICATION_JSON_VALUE,
|
||||
MediaTypes.HAL_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<List<MgmtMetadata>> createMetadata(@PathVariable("targetId") String targetId,
|
||||
List<MgmtMetadata> metadataRest);
|
||||
|
||||
/**
|
||||
* Get the current auto-confirm state for a specific target.
|
||||
*
|
||||
* @param targetId
|
||||
* to check the state for
|
||||
* @return the current state as {@link MgmtTargetAutoConfirm}
|
||||
*/
|
||||
@GetMapping(value = "/{targetId}/autoConfirm", produces = { MediaTypes.HAL_JSON_VALUE,
|
||||
MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<MgmtTargetAutoConfirm> getAutoConfirmStatus(@PathVariable("targetId") String targetId);
|
||||
|
||||
/**
|
||||
* Activate auto-confirm on a specific target.
|
||||
*
|
||||
* @param targetId
|
||||
* to activate auto-confirm on
|
||||
* @param update
|
||||
* properties to update
|
||||
* @return {@link org.springframework.http.HttpStatus#OK} in case of a success
|
||||
*/
|
||||
@PostMapping(value = "/{targetId}/autoConfirm/activate")
|
||||
ResponseEntity<Void> activateAutoConfirm(@PathVariable("targetId") String targetId,
|
||||
@RequestBody(required = false) MgmtTargetAutoConfirmUpdate update);
|
||||
|
||||
/**
|
||||
* Deactivate auto-confirm on a specific target.
|
||||
*
|
||||
* @param targetId
|
||||
* to deactivate auto-confirm on
|
||||
*
|
||||
* @return {@link org.springframework.http.HttpStatus#OK} in case of a success
|
||||
*/
|
||||
@PostMapping(value = "/{targetId}/autoConfirm/deactivate")
|
||||
ResponseEntity<Void> deactivateAutoConfirm(@PathVariable("targetId") String targetId);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user