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:
@@ -299,9 +299,237 @@ include::{snippets}/rootcontroller/post-basedeployment-action-feedback/request-f
|
||||
include::../errors/400.adoc[]
|
||||
include::../errors/401.adoc[]
|
||||
include::../errors/403.adoc[]
|
||||
include::../errors/404.adoc[]
|
||||
include::../errors/405.adoc[]
|
||||
include::../errors/406.adoc[]
|
||||
include::../errors/409.adoc[]
|
||||
include::../errors/410.adoc[]
|
||||
include::../errors/415.adoc[]
|
||||
include::../errors/429.adoc[]
|
||||
|===
|
||||
|
||||
== GET /{tenant}/controller/v1/{controllerid}/confirmationBase
|
||||
|
||||
=== Implementation notes
|
||||
|
||||
Core resource for confirmation related operations. While active actions awaiting confirmation will be referenced, the current auto-confirmation status will be shown. In case auto-confirmation is active, details like the initiator, remark and date of activation (as unix timestamp) will be provided. Reference links to switch the auto-confirmation state are exposed as well.
|
||||
|
||||
=== Resource to request confirmation specific information for the controller
|
||||
|
||||
==== Curl
|
||||
|
||||
include::{snippets}/rootcontroller/get-confirmation-base-with-auto-confirm-active/curl-request.adoc[]
|
||||
|
||||
==== Request URL
|
||||
|
||||
include::{snippets}/rootcontroller/get-confirmation-base-with-auto-confirm-active/http-request.adoc[]
|
||||
|
||||
==== Request path parameter
|
||||
|
||||
include::{snippets}/rootcontroller/get-confirmation-base-with-auto-confirm-active/path-parameters.adoc[]
|
||||
|
||||
==== Response example (auto-confirmation is active)
|
||||
|
||||
The response body in case auto-confirmation is active.
|
||||
|
||||
include::{snippets}/rootcontroller/get-confirmation-base-with-auto-confirm-active/http-response.adoc[]
|
||||
|
||||
==== Response example (auto-confirmation is not active)
|
||||
|
||||
The response body references a link to activate auto-confirmation as well as a link to an open action waiting for confirmation (if present).
|
||||
|
||||
include::{snippets}/rootcontroller/get-confirmation-base-with-auto-confirm-deactivated/http-response.adoc[]
|
||||
|
||||
=== Error responses
|
||||
|
||||
|===
|
||||
| HTTP Status Code | Reason | Response Model
|
||||
|
||||
include::../errors/400.adoc[]
|
||||
include::../errors/401.adoc[]
|
||||
include::../errors/403.adoc[]
|
||||
include::../errors/404.adoc[]
|
||||
include::../errors/405.adoc[]
|
||||
include::../errors/406.adoc[]
|
||||
include::../errors/409.adoc[]
|
||||
include::../errors/415.adoc[]
|
||||
include::../errors/429.adoc[]
|
||||
|===
|
||||
|
||||
== POST /{tenant}/controller/v1/{controllerid}/confirmationBase/activateAutoConfirm
|
||||
|
||||
=== Implementation notes
|
||||
|
||||
The device can use this resource to activate auto-confirmation. As a result all current active as well as future actions will automatically be confirmed by mentioning the initiator as triggered person. Actions will be automatically confirmed, as long as auto-confirmation is active.
|
||||
|
||||
=== Interface to activate auto-confirmation for a specific device
|
||||
|
||||
==== Curl
|
||||
|
||||
include::{snippets}/rootcontroller/activate-auto-confirmation/curl-request.adoc[]
|
||||
|
||||
==== Request URL
|
||||
|
||||
include::{snippets}/rootcontroller/activate-auto-confirmation/http-request.adoc[]
|
||||
|
||||
==== Request path parameter
|
||||
|
||||
include::{snippets}/rootcontroller/activate-auto-confirmation/path-parameters.adoc[]
|
||||
|
||||
==== Request fields
|
||||
|
||||
include::{snippets}/rootcontroller/activate-auto-confirmation/request-fields.adoc[]
|
||||
|
||||
=== Response (Status 200)
|
||||
|
||||
=== Error responses
|
||||
|
||||
|===
|
||||
| HTTP Status Code | Reason | Response Model
|
||||
|
||||
include::../errors/400.adoc[]
|
||||
include::../errors/401.adoc[]
|
||||
include::../errors/403.adoc[]
|
||||
include::../errors/404.adoc[]
|
||||
include::../errors/405.adoc[]
|
||||
include::../errors/406.adoc[]
|
||||
include::../errors/409.adoc[]
|
||||
include::../errors/415.adoc[]
|
||||
include::../errors/429.adoc[]
|
||||
|===
|
||||
|
||||
== POST /{tenant}/controller/v1/{controllerid}/confirmationBase/deactivateAutoConfirm
|
||||
|
||||
=== Implementation notes
|
||||
|
||||
The device can use this resource to deactivate auto-confirmation. All active actions will remain unchanged while all future actions need to be confirmed, before processing with the deployment.
|
||||
|
||||
=== Interface to deactivate auto-confirmation for a specific controller
|
||||
|
||||
==== Curl
|
||||
|
||||
include::{snippets}/rootcontroller/deactivate-auto-confirmation/curl-request.adoc[]
|
||||
|
||||
==== Request URL
|
||||
|
||||
include::{snippets}/rootcontroller/deactivate-auto-confirmation/http-request.adoc[]
|
||||
|
||||
==== Request path parameter
|
||||
|
||||
include::{snippets}/rootcontroller/deactivate-auto-confirmation/path-parameters.adoc[]
|
||||
|
||||
=== Response (Status 200)
|
||||
|
||||
=== Error responses
|
||||
|
||||
|===
|
||||
| HTTP Status Code | Reason | Response Model
|
||||
|
||||
include::../errors/400.adoc[]
|
||||
include::../errors/401.adoc[]
|
||||
include::../errors/403.adoc[]
|
||||
include::../errors/404.adoc[]
|
||||
include::../errors/405.adoc[]
|
||||
include::../errors/406.adoc[]
|
||||
include::../errors/409.adoc[]
|
||||
include::../errors/415.adoc[]
|
||||
include::../errors/429.adoc[]
|
||||
|===
|
||||
|
||||
== GET /{tenant}/controller/v1/{controllerid}/confirmationBase/{actionId}
|
||||
|
||||
=== Implementation notes
|
||||
|
||||
Resource to receive information about a pending confirmation.
|
||||
The response will be of the same format as the deploymentBase operation.
|
||||
The controller should provide feedback about the confirmation first, before processing the deployment.
|
||||
|
||||
Keep in mind that the provided download links for the artifacts are generated dynamically by the update server.
|
||||
Host, port and path are not guaranteed to be similar to the provided examples below but will be defined at runtime.
|
||||
|
||||
=== Confirmation status of an action
|
||||
|
||||
==== Curl
|
||||
|
||||
include::{snippets}/rootcontroller/get-confirmation-base-action/curl-request.adoc[]
|
||||
|
||||
==== Request URL
|
||||
|
||||
include::{snippets}/rootcontroller/get-confirmation-base-action/http-request.adoc[]
|
||||
|
||||
==== Request path parameter
|
||||
|
||||
include::{snippets}/rootcontroller/get-confirmation-base-action/path-parameters.adoc[]
|
||||
|
||||
==== Request query parameter
|
||||
|
||||
include::{snippets}/rootcontroller/get-confirmation-base-action/request-parameters.adoc[]
|
||||
|
||||
=== Response (Status 200)
|
||||
|
||||
==== Response fields
|
||||
|
||||
include::{snippets}/rootcontroller/get-confirmation-base-action/response-fields.adoc[]
|
||||
|
||||
==== Response example
|
||||
|
||||
The response body includes the detailed information about the action awaiting confirmation in the same format as for the deploymentBase operation.
|
||||
|
||||
include::{snippets}/rootcontroller/get-confirmation-base-action/http-response.adoc[]
|
||||
|
||||
=== Error responses
|
||||
|
||||
|===
|
||||
| HTTP Status Code | Reason | Response Model
|
||||
|
||||
include::../errors/400.adoc[]
|
||||
include::../errors/401.adoc[]
|
||||
include::../errors/403.adoc[]
|
||||
include::../errors/404_target_action.adoc[]
|
||||
include::../errors/405.adoc[]
|
||||
include::../errors/406.adoc[]
|
||||
include::../errors/429.adoc[]
|
||||
|===
|
||||
|
||||
== POST /{tenant}/controller/v1/{controllerid}/confirmationBase/{actionId}/feedback
|
||||
|
||||
=== Implementation notes
|
||||
|
||||
The device will use this resource to either confirm or deny an action which is waiting for confirmation. The action will be transferred into the RUNNING state in case the device is confirming it. Afterwards it will be exposed by the deploymentBase.
|
||||
|
||||
=== Feedback channel for actions waiting for confirmation
|
||||
|
||||
==== Curl
|
||||
|
||||
include::{snippets}/rootcontroller/post-confirmation-feedback/curl-request.adoc[]
|
||||
|
||||
==== Request URL
|
||||
|
||||
include::{snippets}/rootcontroller/post-confirmation-feedback/http-request.adoc[]
|
||||
|
||||
==== Request path parameter
|
||||
|
||||
include::{snippets}/rootcontroller/post-confirmation-feedback/path-parameters.adoc[]
|
||||
|
||||
==== Request fields
|
||||
|
||||
include::{snippets}/rootcontroller/post-confirmation-feedback/request-fields.adoc[]
|
||||
|
||||
=== Response (Status 200)
|
||||
|
||||
=== Error responses
|
||||
|
||||
|===
|
||||
| HTTP Status Code | Reason | Response Model
|
||||
|
||||
include::../errors/400.adoc[]
|
||||
include::../errors/401.adoc[]
|
||||
include::../errors/403.adoc[]
|
||||
include::../errors/404_target_action.adoc[]
|
||||
include::../errors/405.adoc[]
|
||||
include::../errors/406.adoc[]
|
||||
include::../errors/409.adoc[]
|
||||
include::../errors/410.adoc[]
|
||||
include::../errors/415.adoc[]
|
||||
include::../errors/429.adoc[]
|
||||
|===
|
||||
|
||||
@@ -245,6 +245,152 @@ include::../errors/429.adoc[]
|
||||
|===
|
||||
|
||||
|
||||
== GET /rest/v1/targets/{targetId}/autoConfirm
|
||||
|
||||
=== Implementation Notes
|
||||
|
||||
Handles the GET request to check the current auto-confirmation state of a target. Required Permission: READ_TARGET
|
||||
|
||||
=== Request auto-confirmation state for a specific target
|
||||
|
||||
==== Curl
|
||||
|
||||
include::{snippets}/targets/get-target-auto-confirm-state-active/curl-request.adoc[]
|
||||
|
||||
==== Request URL
|
||||
|
||||
include::{snippets}/targets/get-target-auto-confirm-state-active/http-request.adoc[]
|
||||
|
||||
==== Request path parameter
|
||||
|
||||
include::{snippets}/targets/get-target-auto-confirm-state-active/path-parameters.adoc[]
|
||||
|
||||
=== Response in case auto-confirmation is active (Status 200)
|
||||
|
||||
In case auto-confirmation is active, details like the initiator, remark and date of activation (as unix timestamp) will be provided. Reference links to switch the auto-confirmation state are exposed as well.
|
||||
|
||||
==== Response fields
|
||||
|
||||
include::{snippets}/targets/get-target-auto-confirm-state-active/response-fields.adoc[]
|
||||
|
||||
==== Response example
|
||||
|
||||
include::{snippets}/targets/get-target-auto-confirm-state-active/http-response.adoc[]
|
||||
|
||||
=== Response in case auto-confirmation is not active (Status 200)
|
||||
|
||||
The response body references a link to activate auto-confirmation.
|
||||
|
||||
==== Response fields
|
||||
|
||||
include::{snippets}/targets/get-target-auto-confirm-state-not-active/response-fields.adoc[]
|
||||
|
||||
==== Response example
|
||||
|
||||
include::{snippets}/targets/get-target-auto-confirm-state-not-active/http-response.adoc[]
|
||||
|
||||
=== Error responses
|
||||
|
||||
|===
|
||||
| HTTP Status Code | Reason | Response Model
|
||||
|
||||
include::../errors/400.adoc[]
|
||||
include::../errors/401.adoc[]
|
||||
include::../errors/403.adoc[]
|
||||
include::../errors/404.adoc[]
|
||||
include::../errors/405.adoc[]
|
||||
include::../errors/406.adoc[]
|
||||
include::../errors/429.adoc[]
|
||||
|===
|
||||
|
||||
|
||||
== POST /rest/v1/targets/{targetId}/autoConfirm/activate
|
||||
|
||||
=== Implementation Notes
|
||||
|
||||
Handles the POST request to activate auto-confirmation for a specific target.
|
||||
As a result all current active as well as future actions will automatically be confirmed by mentioning the initiator as triggered person.
|
||||
Actions will be automatically confirmed, as long as auto-confirmation is active.
|
||||
Required Permission: UPDATE_TARGET
|
||||
|
||||
=== Activate auto-confirmation for a target
|
||||
|
||||
==== Curl
|
||||
|
||||
include::{snippets}/targets/post-activate-auto-confirm/curl-request.adoc[]
|
||||
|
||||
==== Request URL
|
||||
|
||||
include::{snippets}/targets/post-activate-auto-confirm/http-request.adoc[]
|
||||
|
||||
==== Request path parameter
|
||||
|
||||
include::{snippets}/targets/post-activate-auto-confirm/path-parameters.adoc[]
|
||||
|
||||
==== Request fields
|
||||
|
||||
include::{snippets}/targets/post-activate-auto-confirm/request-fields.adoc[]
|
||||
|
||||
=== Response (Status 200)
|
||||
|
||||
=== Error responses
|
||||
|
||||
|===
|
||||
| HTTP Status Code | Reason | Response Model
|
||||
|
||||
include::../errors/400.adoc[]
|
||||
include::../errors/401.adoc[]
|
||||
include::../errors/403.adoc[]
|
||||
include::../errors/404.adoc[]
|
||||
include::../errors/405.adoc[]
|
||||
include::../errors/406.adoc[]
|
||||
include::../errors/409.adoc[]
|
||||
include::../errors/415.adoc[]
|
||||
include::../errors/429.adoc[]
|
||||
|===
|
||||
|
||||
|
||||
== POST /rest/v1/targets/{targetId}/autoConfirm/deactivate
|
||||
|
||||
=== Implementation Notes
|
||||
|
||||
Handles the POST request to deactivate auto-confirmation for a specific target.
|
||||
All active actions will remain unchanged while all future actions need to be confirmed, before processing with the deployment.
|
||||
Required Permission: UPDATE_TARGET
|
||||
|
||||
=== Deactivate auto-confirmation for a target
|
||||
|
||||
==== Curl
|
||||
|
||||
include::{snippets}/targets/post-deactivate-auto-confirm/curl-request.adoc[]
|
||||
|
||||
==== Request URL
|
||||
|
||||
include::{snippets}/targets/post-deactivate-auto-confirm/http-request.adoc[]
|
||||
|
||||
==== Request path parameter
|
||||
|
||||
include::{snippets}/targets/post-deactivate-auto-confirm/path-parameters.adoc[]
|
||||
|
||||
=== Response (Status 200)
|
||||
|
||||
=== Error responses
|
||||
|
||||
|===
|
||||
| HTTP Status Code | Reason | Response Model
|
||||
|
||||
include::../errors/400.adoc[]
|
||||
include::../errors/401.adoc[]
|
||||
include::../errors/403.adoc[]
|
||||
include::../errors/404.adoc[]
|
||||
include::../errors/405.adoc[]
|
||||
include::../errors/406.adoc[]
|
||||
include::../errors/409.adoc[]
|
||||
include::../errors/415.adoc[]
|
||||
include::../errors/429.adoc[]
|
||||
|===
|
||||
|
||||
|
||||
== GET /rest/v1/targets/{targetId}/actions
|
||||
|
||||
=== Implementation Notes
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
| `404 Not Found`
|
||||
| Not Found Target.
|
||||
| Target not found.
|
||||
| See <<error-body>>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
| `404 Not Found`
|
||||
| Target or Action not found.
|
||||
| See <<error-body>>
|
||||
2
hawkbit-rest/hawkbit-rest-docs/src/main/errors/410.adoc
Normal file
2
hawkbit-rest/hawkbit-rest-docs/src/main/errors/410.adoc
Normal file
@@ -0,0 +1,2 @@
|
||||
| `410 Gone`
|
||||
| Action is not active anymore.
|
||||
@@ -96,6 +96,8 @@ final class DdiApiModelProperties {
|
||||
|
||||
static final String DEPLOYMENT = "Detailed deployment operation";
|
||||
|
||||
static final String CONFIRMATION = "Deployment confirmation operation";
|
||||
|
||||
static final String CANCEL = "Detailed cancel operation of a deployment";
|
||||
|
||||
static final String INSTALLED = "Detailed operation of last successfully finished action";
|
||||
@@ -137,4 +139,29 @@ final class DdiApiModelProperties {
|
||||
static final String UPDATE_MODE = "Optional parameter to specify the update mode that should be applied when updating target attributes. "
|
||||
+ "Valid values are 'merge', 'replace', and 'remove'. Defaults to 'merge'.";
|
||||
|
||||
static final String TARGET_CONFIRMATION_STATE = "action confirmation state";
|
||||
|
||||
static final String TARGET_CONFIRMATION_CODE = "optional individual status code";
|
||||
|
||||
static final String TARGET_CONFIRMATION_DETAILS = "List of detailed message information";
|
||||
|
||||
static final String TARGET_AUTO_CONFIRM = "id of the action";
|
||||
|
||||
static final String TARGET_AUTO_CONFIRM_STATE = "flag if auto confirm is active";
|
||||
|
||||
static final String TARGET_AUTO_CONFIRM_INITIATOR_RESPONSE = "(optional) initiator set on activation";
|
||||
|
||||
static final String TARGET_AUTO_CONFIRM_REMARK_RESPONSE = "(optional) remark set on activation";
|
||||
|
||||
static final String TARGET_AUTO_CONFIRM_ACTIVATED_AT = "timestamp of the activation";
|
||||
|
||||
static final String TARGET_AUTO_CONFIRM_REFERENCE_ACTIVATE_AUTO_CONFIRM = "reference link to activate auto confirm";
|
||||
|
||||
static final String TARGET_AUTO_CONFIRM_REFERENCE_DEACTIVATE_AUTO_CONFIRM = "reference link to deactivate auto confirm";
|
||||
|
||||
static final String TARGET_AUTO_CONFIRM_REFERENCE_CONFIRMATION_BASE_ACTION = "reference link in case an action with open confirmation is present";
|
||||
|
||||
static final String TARGET_AUTO_CONFIRM_ACTIVATE_INITIATOR = "individual value (e.g. username) stored as initiator and automatically used as confirmed user in future actions";
|
||||
static final String TARGET_AUTO_CONFIRM_ACTIVATE_REMARK = "individual value to attach a remark which will be persisted when automatically confirming future actions";
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiActionFeedback;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiActivateAutoConfirmation;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiConfirmationFeedback;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiProgress;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiResult;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiStatus;
|
||||
@@ -194,14 +196,13 @@ public class RootControllerDocumentationTest extends AbstractApiRestDocumentatio
|
||||
tenantAware.getCurrentTenant(), target.getControllerId(), cancelAction.getId())
|
||||
.content(objectMapper.writeValueAsString(feedback))
|
||||
.contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andDo(this.document
|
||||
.document(
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andDo(this.document.document(
|
||||
pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT),
|
||||
parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID),
|
||||
parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID_CANCELED)),
|
||||
requestFields(
|
||||
optionalRequestFieldWithPath("id")
|
||||
.description(DdiApiModelProperties.FEEDBACK_ACTION_ID)
|
||||
optionalRequestFieldWithPath("id").description(DdiApiModelProperties.FEEDBACK_ACTION_ID)
|
||||
.type(JsonFieldType.NUMBER),
|
||||
optionalRequestFieldWithPath("time")
|
||||
.description(DdiApiModelProperties.FEEDBACK_ACTION_TIME),
|
||||
@@ -409,14 +410,14 @@ public class RootControllerDocumentationTest extends AbstractApiRestDocumentatio
|
||||
+ DdiRestConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}/feedback", tenantAware.getCurrentTenant(),
|
||||
target.getControllerId(), actionId).content(objectMapper.writeValueAsString(feedback))
|
||||
.contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaTypes.HAL_JSON_VALUE))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andDo(this.document.document(
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andDo(this.document.document(
|
||||
pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT),
|
||||
parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID),
|
||||
parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID)),
|
||||
|
||||
requestFields(
|
||||
optionalRequestFieldWithPath("id")
|
||||
.description(DdiApiModelProperties.FEEDBACK_ACTION_ID)
|
||||
optionalRequestFieldWithPath("id").description(DdiApiModelProperties.FEEDBACK_ACTION_ID)
|
||||
.type(JsonFieldType.NUMBER),
|
||||
optionalRequestFieldWithPath("time")
|
||||
.description(DdiApiModelProperties.FEEDBACK_ACTION_TIME),
|
||||
@@ -580,4 +581,234 @@ public class RootControllerDocumentationTest extends AbstractApiRestDocumentatio
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Resource to retrieve the current state of auto confirmation. In case auto-confirm is active a reference to disable it will be provided.")
|
||||
@WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true)
|
||||
public void getConfirmationBaseWithAutoConfirmActive() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID));
|
||||
confirmationManagement.activateAutoConfirmation(target.getControllerId(), "exampleUserId", "exampleRemark");
|
||||
assignDistributionSetWithMaintenanceWindow(set.getId(), target.getControllerId(), getTestSchedule(-5),
|
||||
getTestDuration(10), getTestTimeZone());
|
||||
|
||||
mockMvc.perform(
|
||||
get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE,
|
||||
tenantAware.getCurrentTenant(), target.getControllerId()).accept(MediaTypes.HAL_JSON_VALUE))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaTypes.HAL_JSON))
|
||||
.andDo(this.document.document(
|
||||
pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT),
|
||||
parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)),
|
||||
responseFields(
|
||||
fieldWithPath("autoConfirm").description(DdiApiModelProperties.TARGET_AUTO_CONFIRM),
|
||||
fieldWithPath("autoConfirm.active")
|
||||
.description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_STATE),
|
||||
fieldWithPath("autoConfirm.initiator")
|
||||
.description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_INITIATOR_RESPONSE),
|
||||
fieldWithPath("autoConfirm.remark")
|
||||
.description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_REMARK_RESPONSE),
|
||||
fieldWithPath("autoConfirm.activatedAt")
|
||||
.description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_ACTIVATED_AT),
|
||||
fieldWithPath("_links.deactivateAutoConfirm").description(
|
||||
DdiApiModelProperties.TARGET_AUTO_CONFIRM_REFERENCE_DEACTIVATE_AUTO_CONFIRM))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Resource to retrieve the current state of auto confirmation. In case actions are waiting for a confirmation, they will be referenced.")
|
||||
@WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true)
|
||||
public void getConfirmationBaseWithAutoConfirmDeactivated() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID));
|
||||
assignDistributionSetWithMaintenanceWindow(set.getId(), target.getControllerId(), getTestSchedule(-5),
|
||||
getTestDuration(10), getTestTimeZone());
|
||||
|
||||
mockMvc.perform(
|
||||
get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE,
|
||||
tenantAware.getCurrentTenant(), target.getControllerId()).accept(MediaTypes.HAL_JSON_VALUE))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaTypes.HAL_JSON))
|
||||
.andDo(this.document.document(
|
||||
pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT),
|
||||
parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)),
|
||||
responseFields(
|
||||
fieldWithPath("autoConfirm").description(DdiApiModelProperties.TARGET_AUTO_CONFIRM),
|
||||
fieldWithPath("autoConfirm.active")
|
||||
.description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_STATE),
|
||||
fieldWithPath("_links.activateAutoConfirm").description(
|
||||
DdiApiModelProperties.TARGET_AUTO_CONFIRM_REFERENCE_ACTIVATE_AUTO_CONFIRM),
|
||||
fieldWithPath("_links.confirmationBase").description(
|
||||
DdiApiModelProperties.TARGET_AUTO_CONFIRM_REFERENCE_CONFIRMATION_BASE_ACTION))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Core resource for confirmation of actions. Contains all necessary information for confirmation.")
|
||||
@WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true)
|
||||
public void getConfirmationBaseAction() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
|
||||
set.getModules().forEach(module -> {
|
||||
final byte[] random = RandomStringUtils.random(5).getBytes();
|
||||
|
||||
artifactManagement.create(
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "binary.tgz", false, 0));
|
||||
artifactManagement.create(
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "file.signature", false, 0));
|
||||
});
|
||||
|
||||
softwareModuleManagement.createMetaData(
|
||||
entityFactory.softwareModuleMetadata().create(set.getModules().iterator().next().getId())
|
||||
.key("aMetadataKey").value("Metadata value as defined in software module").targetVisible(true));
|
||||
|
||||
final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID));
|
||||
final Long actionId = getFirstAssignedActionId(assignDistributionSetWithMaintenanceWindow(set.getId(),
|
||||
target.getControllerId(), getTestSchedule(-5), getTestDuration(10), getTestTimeZone()));
|
||||
|
||||
mockMvc.perform(get(
|
||||
DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE
|
||||
+ "/{actionId}?actionHistory=10",
|
||||
tenantAware.getCurrentTenant(), target.getControllerId(), actionId).accept(MediaTypes.HAL_JSON_VALUE))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaTypes.HAL_JSON))
|
||||
.andDo(this.document.document(
|
||||
pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT),
|
||||
parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID),
|
||||
parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID)),
|
||||
requestParameters(
|
||||
parameterWithName("actionHistory").description(DdiApiModelProperties.ACTION_HISTORY)),
|
||||
responseFields(fieldWithPath("id").description(DdiApiModelProperties.ACTION_ID),
|
||||
fieldWithPath("confirmation").description(DdiApiModelProperties.CONFIRMATION),
|
||||
fieldWithPath("confirmation.download")
|
||||
.description(DdiApiModelProperties.HANDLING_DOWNLOAD).type("enum")
|
||||
.attributes(key("value").value("['skip', 'attempt', 'forced']")),
|
||||
fieldWithPath("confirmation.update").description(DdiApiModelProperties.HANDLING_UPDATE)
|
||||
.type("enum").attributes(key("value").value("['skip', 'attempt', 'forced']")),
|
||||
fieldWithPath("confirmation.maintenanceWindow")
|
||||
.description(DdiApiModelProperties.MAINTENANCE_WINDOW).type("enum")
|
||||
.attributes(key("value").value("['available', 'unavailable']")),
|
||||
fieldWithPath("confirmation.chunks").description(DdiApiModelProperties.CHUNK),
|
||||
fieldWithPath("confirmation.chunks[].metadata")
|
||||
.description(DdiApiModelProperties.CHUNK_META_DATA).optional(),
|
||||
fieldWithPath("confirmation.chunks[].metadata[].key")
|
||||
.description(DdiApiModelProperties.CHUNK_META_DATA_KEY).optional(),
|
||||
fieldWithPath("confirmation.chunks[].metadata[].value")
|
||||
.description(DdiApiModelProperties.CHUNK_META_DATA_VALUE).optional(),
|
||||
fieldWithPath("confirmation.chunks[].part")
|
||||
.description(DdiApiModelProperties.CHUNK_TYPE),
|
||||
fieldWithPath("confirmation.chunks[].name")
|
||||
.description(DdiApiModelProperties.CHUNK_NAME),
|
||||
fieldWithPath("confirmation.chunks[].version")
|
||||
.description(DdiApiModelProperties.CHUNK_VERSION),
|
||||
fieldWithPath("confirmation.chunks[].artifacts")
|
||||
.description(DdiApiModelProperties.ARTIFACTS),
|
||||
fieldWithPath("confirmation.chunks[].artifacts[].filename")
|
||||
.description(DdiApiModelProperties.ARTIFACTS),
|
||||
fieldWithPath("confirmation.chunks[].artifacts[].hashes")
|
||||
.description(DdiApiModelProperties.ARTIFACTS),
|
||||
fieldWithPath("confirmation.chunks[].artifacts[].hashes.sha1")
|
||||
.description(DdiApiModelProperties.ARTIFACT_HASHES_SHA1),
|
||||
fieldWithPath("confirmation.chunks[].artifacts[].hashes.md5")
|
||||
.description(DdiApiModelProperties.ARTIFACT_HASHES_MD5),
|
||||
fieldWithPath("confirmation.chunks[].artifacts[].hashes.sha256")
|
||||
.description(DdiApiModelProperties.ARTIFACT_HASHES_SHA256),
|
||||
fieldWithPath("confirmation.chunks[].artifacts[].size")
|
||||
.description(DdiApiModelProperties.ARTIFACT_SIZE),
|
||||
fieldWithPath("confirmation.chunks[].artifacts[]._links.download")
|
||||
.description(DdiApiModelProperties.ARTIFACT_HTTPS_DOWNLOAD_LINK_BY_CONTROLLER),
|
||||
fieldWithPath("confirmation.chunks[].artifacts[]._links.md5sum")
|
||||
.description(DdiApiModelProperties.ARTIFACT_HTTPS_HASHES_MD5SUM_LINK),
|
||||
fieldWithPath("confirmation.chunks[].artifacts[]._links.download-http")
|
||||
.description(DdiApiModelProperties.ARTIFACT_HTTP_DOWNLOAD_LINK_BY_CONTROLLER),
|
||||
fieldWithPath("confirmation.chunks[].artifacts[]._links.md5sum-http")
|
||||
.description(DdiApiModelProperties.ARTIFACT_HTTP_HASHES_MD5SUM_LINK),
|
||||
fieldWithPath("actionHistory").description(DdiApiModelProperties.ACTION_HISTORY_RESP),
|
||||
fieldWithPath("actionHistory.status")
|
||||
.description(DdiApiModelProperties.ACTION_HISTORY_RESP_STATUS),
|
||||
fieldWithPath("actionHistory.messages")
|
||||
.description(DdiApiModelProperties.ACTION_HISTORY_RESP_MESSAGES))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Feedback channel for confirming an action")
|
||||
@WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true)
|
||||
public void postConfirmationFeedback() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
|
||||
final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID));
|
||||
final Long actionId = getFirstAssignedActionId(assignDistributionSet(set.getId(), target.getControllerId()));
|
||||
|
||||
final DdiConfirmationFeedback feedback = new DdiConfirmationFeedback(
|
||||
DdiConfirmationFeedback.Confirmation.CONFIRMED, 33, List.of("Feedback message"));
|
||||
|
||||
mockMvc.perform(
|
||||
post(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE
|
||||
+ "/{actionId}/feedback", tenantAware.getCurrentTenant(), target.getControllerId(), actionId)
|
||||
.content(objectMapper.writeValueAsString(feedback))
|
||||
.contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaTypes.HAL_JSON_VALUE))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(
|
||||
status().isOk())
|
||||
.andDo(this.document.document(
|
||||
pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT),
|
||||
parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID),
|
||||
parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID)),
|
||||
|
||||
requestFields(
|
||||
requestFieldWithPath("confirmation")
|
||||
.description(DdiApiModelProperties.TARGET_CONFIRMATION_STATE).type("enum")
|
||||
.attributes(key("value").value("['confirmed', 'denied']")),
|
||||
|
||||
optionalRequestFieldWithPath("code")
|
||||
.description(DdiApiModelProperties.TARGET_CONFIRMATION_CODE),
|
||||
|
||||
optionalRequestFieldWithPath("details")
|
||||
.description(DdiApiModelProperties.TARGET_CONFIRMATION_DETAILS))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Resource to activate auto-confirmation on a target.")
|
||||
@WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true)
|
||||
public void activateAutoConfirmation() throws Exception {
|
||||
final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID));
|
||||
|
||||
final DdiActivateAutoConfirmation body = new DdiActivateAutoConfirmation("exampleUser", "exampleRemark");
|
||||
|
||||
mockMvc.perform(post(
|
||||
DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE + "/"
|
||||
+ DdiRestConstants.AUTO_CONFIRM_ACTIVATE,
|
||||
tenantAware.getCurrentTenant(), target.getControllerId()).content(objectMapper.writeValueAsString(body))
|
||||
.contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andDo(this.document.document(
|
||||
pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT),
|
||||
parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)),
|
||||
requestFields(
|
||||
optionalRequestFieldWithPath("initiator")
|
||||
.description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_ACTIVATE_INITIATOR),
|
||||
optionalRequestFieldWithPath("remark")
|
||||
.description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_ACTIVATE_REMARK))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Resource to deactivate auto-confirmation on a target.")
|
||||
@WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true)
|
||||
public void deactivateAutoConfirmation() throws Exception {
|
||||
final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID));
|
||||
|
||||
mockMvc.perform(post(
|
||||
DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE + "/"
|
||||
+ DdiRestConstants.AUTO_CONFIRM_DEACTIVATE,
|
||||
tenantAware.getCurrentTenant(), target.getControllerId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk())
|
||||
.andDo(this.document.document(
|
||||
pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT),
|
||||
parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public abstract class AbstractApiRestDocumentation extends AbstractRestIntegrati
|
||||
|
||||
final Rollout rollout = testdataFactory.createRolloutByVariables("rollout", "rollout desc", 1,
|
||||
"name==" + name, distributionSet, "50", "5", timeforced ? ActionType.TIMEFORCED : ActionType.FORCED,
|
||||
isMultiAssignmentsEnabled() ? 600 : null);
|
||||
isMultiAssignmentsEnabled() ? 600 : null, isConfirmationFlowActive());
|
||||
|
||||
// start the rollout and handle it
|
||||
rolloutManagement.start(rollout.getId());
|
||||
@@ -280,6 +280,8 @@ public abstract class AbstractApiRestDocumentation extends AbstractRestIntegrati
|
||||
fieldWithPath(fieldArrayPrefix + "securityToken").description(MgmtApiModelProperties.SECURITY_TOKEN),
|
||||
fieldWithPath(fieldArrayPrefix + "requestAttributes")
|
||||
.description(MgmtApiModelProperties.REQUEST_ATTRIBUTES),
|
||||
fieldWithPath(fieldArrayPrefix + "autoConfirmActive")
|
||||
.description(MgmtApiModelProperties.AUTO_CONFIRM_ACTIVE),
|
||||
fieldWithPath(fieldArrayPrefix + "installedAt").description(MgmtApiModelProperties.INSTALLED_AT),
|
||||
fieldWithPath(fieldArrayPrefix + "lastModifiedAt")
|
||||
.description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"),
|
||||
@@ -314,7 +316,9 @@ public abstract class AbstractApiRestDocumentation extends AbstractRestIntegrati
|
||||
.description(MgmtApiModelProperties.LINKS_ACTIONS),
|
||||
fieldWithPath(fieldArrayPrefix + "_links.metadata").description(MgmtApiModelProperties.META_DATA),
|
||||
fieldWithPath(fieldArrayPrefix + "_links.targetType")
|
||||
.description(MgmtApiModelProperties.LINK_TO_TARGET_TYPE)));
|
||||
.description(MgmtApiModelProperties.LINK_TO_TARGET_TYPE),
|
||||
fieldWithPath(fieldArrayPrefix + "_links.autoConfirm")
|
||||
.description(MgmtApiModelProperties.LINK_TO_AUTO_CONFIRM)));
|
||||
|
||||
}
|
||||
fields.addAll(Arrays.asList(descriptors));
|
||||
@@ -364,7 +368,12 @@ public abstract class AbstractApiRestDocumentation extends AbstractRestIntegrati
|
||||
|
||||
protected boolean isMultiAssignmentsEnabled() {
|
||||
return Boolean.TRUE.equals(tenantConfigurationManagement
|
||||
.getConfigurationValue(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED, Boolean.class).getValue());
|
||||
.getConfigurationValue(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED, Boolean.class).getValue());
|
||||
}
|
||||
|
||||
protected boolean isConfirmationFlowActive() {
|
||||
return Boolean.TRUE.equals(tenantConfigurationManagement
|
||||
.getConfigurationValue(TenantConfigurationKey.USER_CONFIRMATION_ENABLED, Boolean.class).getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ public final class MgmtApiModelProperties {
|
||||
public static final String LINK_TO_TARGET_TYPE = "The link to the target type.";
|
||||
public static final String LINK_TO_TARGET = "The link to the target.";
|
||||
|
||||
public static final String LINK_TO_AUTO_CONFIRM = "The link to the detailed auto confirm state.";
|
||||
|
||||
// software module types
|
||||
public static final String SMT_TYPE = "The type of the software module identified by its key.";
|
||||
public static final String SMT_VENDOR = "The software vendor of the entity.";
|
||||
@@ -93,6 +95,8 @@ public final class MgmtApiModelProperties {
|
||||
|
||||
// rollout
|
||||
public static final String ROLLOUT_FILTER_QUERY = "target filter query language expression";
|
||||
public static final String ROLLOUT_CONFIRMATION_REQUIRED = "(available with user consent flow active) if the confirmation is required for this rollout. Value will be used if confirmation options are missing in the rollout group definitions. Confirmation is required per default";
|
||||
public static final String ROLLOUT_GROUP_CONFIRMATION_REQUIRED = "(available with user consent flow active) if the confirmation is required for this rollout group. Confirmation is required per default.";
|
||||
public static final String ROLLOUT_GROUP_FILTER_QUERY = "target filter query language expression that selects a subset of targets which match the target filter of the Rollout";
|
||||
public static final String ROLLOUT_GROUP_TARGET_PERCENTAGE = "percentage of remaining and matching targets that should be added to this group";
|
||||
public static final String ROLLOUT_DS_ID = "the ID of distributionset of this rollout";
|
||||
@@ -144,6 +148,8 @@ public final class MgmtApiModelProperties {
|
||||
|
||||
public static final String ACTION_FORCE_TYPE = "Force type of the action that provides a hint if the controller should apply the action immediately or whenever possible.";
|
||||
|
||||
public static final String ACTION_CONFIRMATION_REQUIRED = "(Available with user consent flow active) Defines, if the confirmation is required for an action. Confirmation is required per default.";
|
||||
|
||||
public static final String ACTION_FORCE_TIME = "In case of timeforced mode the difference, measured in milliseconds, between the time the action should switch to forced and midnight, January 1, 1970 UTC.";
|
||||
|
||||
public static final String ACTION_FORCED = "Set to forced in order to switch action to forced mode.";
|
||||
@@ -178,6 +184,8 @@ public final class MgmtApiModelProperties {
|
||||
|
||||
public static final String REQUEST_ATTRIBUTES = "Request re-transmission of target attributes.";
|
||||
|
||||
public static final String AUTO_CONFIRM_ACTIVE = "Present if user consent flow active. Indicates if auto-confirm is active";
|
||||
|
||||
public static final String META_DATA = "List of metadata.";
|
||||
|
||||
public static final String META_DATA_KEY = "Metadata property key.";
|
||||
@@ -186,6 +194,21 @@ public final class MgmtApiModelProperties {
|
||||
|
||||
public static final String SM_META_DATA_TARGET_VISIBLE = "Metadata property is visible to targets as part of software update action.";
|
||||
|
||||
public static final String AUTO_CONFIRM_STATE_ACTIVE = "Flag if auto confirm is active";
|
||||
|
||||
public static final String AUTO_CONFIRM_STATE_INITIATOR = "(Optional) initiator set on activation";
|
||||
|
||||
public static final String AUTO_CONFIRM_STATE_REMARK = "(Optional) remark set on activation";
|
||||
|
||||
public static final String AUTO_CONFIRM_STATE_ACTIVATED_AT = "timestamp of the activation";
|
||||
|
||||
public static final String AUTO_CONFIRM_STATE_REFERENCE_ACTIVATE_AUTO_CONFIRM = "reference link to activate auto confirm (present if not active)";
|
||||
|
||||
public static final String AUTO_CONFIRM_STATE_REFERENCE_DEACTIVATE_AUTO_CONFIRM = "reference link to deactivate auto confirm (present if active)";
|
||||
|
||||
public static final String AUTO_CONFIRM_ACTIVATE_INITIATOR = "individual value (e.g. username) stored as initiator and automatically used as confirmed user in future actions";
|
||||
public static final String AUTO_CONFIRM_ACTIVATE_REMARK = "individual value to attach a remark which will be persisted when automatically confirming future actions";
|
||||
|
||||
public static final String SM_TYPE_KEY = "Key that can be interpreted by the target.";
|
||||
|
||||
public static final String SM_MAX_ASSIGNMENTS = "Maximum number of assignments to a distribution set/target, e.g. only one firmware but multiple applications.";
|
||||
@@ -225,6 +248,7 @@ public final class MgmtApiModelProperties {
|
||||
public static final String FORCETIME = "Forcetime in milliseconds.";
|
||||
public static final String FORCE = "Force as boolean.";
|
||||
public static final String ASSIGNMENT_WEIGHT = "Importance of the assignment.";
|
||||
public static final String ASSIGNMENT_CONFIRMATION_REQUIRED = "(Available with user consent flow active) Specifies if the confirmation by the device is required for this action.";
|
||||
public static final String ASSIGNMENT_TYPE = "The type of the assignment.";
|
||||
public static final String TARGET_ASSIGNED = "The number of targets that have been assigned as part of this operation.";
|
||||
public static final String TARGET_ASSIGNED_ALREADY = "The number of targets which already had been the assignment.";
|
||||
|
||||
@@ -354,6 +354,8 @@ public class DistributionSetsDocumentationTest extends AbstractApiRestDocumentat
|
||||
@Description("Handles the POST request for assigning multiple targets to a distribution set.The request body must always be a list of target IDs."
|
||||
+ " Required Permission: " + SpPermission.READ_REPOSITORY + " and " + SpPermission.UPDATE_TARGET)
|
||||
public void createAssignedTarget() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final DistributionSet set = testdataFactory.createUpdatedDistributionSet();
|
||||
|
||||
// prepare targets
|
||||
@@ -396,7 +398,10 @@ public class DistributionSetsDocumentationTest extends AbstractApiRestDocumentat
|
||||
.description(MgmtApiModelProperties.MAINTENANCE_WINDOW_TIMEZONE),
|
||||
optionalRequestFieldWithPath("[].type")
|
||||
.description(MgmtApiModelProperties.ASSIGNMENT_TYPE).attributes(
|
||||
key("value").value("['soft', 'forced','timeforced', 'downloadonly']"))),
|
||||
key("value").value("['soft', 'forced','timeforced', 'downloadonly']")),
|
||||
optionalRequestFieldWithPath("[].confirmationRequired")
|
||||
.description(MgmtApiModelProperties.ACTION_CONFIRMATION_REQUIRED)
|
||||
.type(JsonFieldType.BOOLEAN.toString())),
|
||||
responseFields(
|
||||
fieldWithPath("assigned").description(MgmtApiModelProperties.DS_NEW_ASSIGNED_TARGETS),
|
||||
fieldWithPath("alreadyAssigned").type(JsonFieldType.NUMBER)
|
||||
|
||||
@@ -51,8 +51,6 @@ import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.restdocs.payload.JsonFieldType;
|
||||
import org.springframework.restdocs.snippet.Snippet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
@@ -181,6 +179,7 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
@Test
|
||||
@Description("Handles the POST request of creating a rollout. Required Permission: " + SpPermission.CREATE_ROLLOUT)
|
||||
public void createRollout() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
testdataFactory.createTargets(20, "targets-");
|
||||
|
||||
@@ -212,6 +211,9 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
requestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME),
|
||||
optionalRequestFieldWithPath("type").description(MgmtApiModelProperties.ROLLOUT_TYPE)
|
||||
.attributes(key("value").value("['soft', 'forced', 'timeforced', 'downloadonly']")),
|
||||
optionalRequestFieldWithPath("confirmationRequired")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_CONFIRMATION_REQUIRED)
|
||||
.type(JsonFieldType.BOOLEAN.toString()),
|
||||
requestFieldWithPath("distributionSetId").description(MgmtApiModelProperties.ROLLOUT_DS_ID),
|
||||
requestFieldWithPath("targetFilterQuery")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_FILTER_QUERY),
|
||||
@@ -254,6 +256,7 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
@Description("Handles the POST request of creating a rollout with a groups definition. Required Permission: "
|
||||
+ SpPermission.CREATE_ROLLOUT)
|
||||
public void createRolloutWithGroupsDefinition() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final int amountTargets = 10;
|
||||
testdataFactory.createTargets(amountTargets, "targets-", "rollout");
|
||||
@@ -285,11 +288,11 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
.successAction(RolloutGroupSuccessAction.NEXTGROUP, "")
|
||||
.errorCondition(RolloutGroupErrorCondition.THRESHOLD, "80")
|
||||
.errorAction(RolloutGroupErrorAction.PAUSE, "").build();
|
||||
mockMvc.perform(
|
||||
post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING)
|
||||
.content(JsonBuilder.rollout(name, description, null, dsId, targetFilter,
|
||||
rolloutGroupConditions, rolloutGroups))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaTypes.HAL_JSON_VALUE))
|
||||
mockMvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING)
|
||||
.content(JsonBuilder.rolloutWithGroups(name, description, null, dsId, targetFilter,
|
||||
rolloutGroupConditions, rolloutGroups, null, null, true))
|
||||
.contentType(
|
||||
MediaType.APPLICATION_JSON).accept(MediaTypes.HAL_JSON_VALUE))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
||||
.andExpect(content().contentType(MediaTypes.HAL_JSON))
|
||||
.andDo(this.document.document(
|
||||
@@ -302,6 +305,8 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
.description(MgmtApiModelProperties.ROLLOUT_DS_ID),
|
||||
requestFieldWithPath("targetFilterQuery")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_FILTER_QUERY),
|
||||
requestFieldWithPath("confirmationRequired")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_CONFIRMATION_REQUIRED),
|
||||
optionalRequestFieldWithPath("description")
|
||||
.description(ApiModelPropertiesGeneric.DESCRPTION),
|
||||
optionalRequestFieldWithPath("successCondition")
|
||||
@@ -338,6 +343,8 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
.description(ApiModelPropertiesGeneric.DESCRPTION),
|
||||
optionalRequestFieldWithPath("groups[].targetFilterQuery")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_GROUP_FILTER_QUERY),
|
||||
optionalRequestFieldWithPath("groups[].confirmationRequired")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_GROUP_CONFIRMATION_REQUIRED),
|
||||
optionalRequestFieldWithPath("groups[].targetPercentage")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_GROUP_TARGET_PERCENTAGE)
|
||||
.attributes(key("value").value("0..100")),
|
||||
@@ -467,6 +474,8 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
@Description("Handles the GET request of retrieving the deploy groups of a rollout. Required Permission: "
|
||||
+ SpPermission.READ_ROLLOUT)
|
||||
public void getRolloutDeployGroups() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final Rollout rollout = createRolloutEntity();
|
||||
|
||||
mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups", rollout.getId())
|
||||
@@ -485,6 +494,8 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
@Description("Handles the GET request of retrieving a deploy group of a rollout. Required Permission: "
|
||||
+ SpPermission.READ_ROLLOUT)
|
||||
public void getRolloutDeployGroup() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final Rollout rollout = createRolloutEntity();
|
||||
final RolloutGroup firstRolloutGroup = rolloutGroupManagement.findByRollout(PAGE, rollout.getId()).getContent()
|
||||
.get(0);
|
||||
@@ -499,7 +510,7 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
}
|
||||
|
||||
private Snippet getRolloutDeployGroupResponseFields(final boolean isArray, final boolean withDetails,
|
||||
final FieldDescriptor... descriptors) throws JsonProcessingException {
|
||||
final FieldDescriptor... descriptors) {
|
||||
final String arrayPrefix = getArrayPrefix(isArray);
|
||||
final List<FieldDescriptor> allFieldDescriptor = new ArrayList<>();
|
||||
allFieldDescriptor.addAll(Arrays.asList(descriptors));
|
||||
@@ -534,6 +545,9 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
allFieldDescriptor.add(fieldWithPath(arrayPrefix + "targetPercentage")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_GROUP_TARGET_PERCENTAGE));
|
||||
|
||||
allFieldDescriptor.add(fieldWithPath(arrayPrefix + "confirmationRequired")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_GROUP_CONFIRMATION_REQUIRED));
|
||||
|
||||
allFieldDescriptor.add(fieldWithPath(arrayPrefix + "successCondition")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION));
|
||||
allFieldDescriptor.add(fieldWithPath(arrayPrefix + "successCondition.condition")
|
||||
@@ -663,7 +677,7 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
if (isMultiAssignmentsEnabled()) {
|
||||
rolloutCreate.weight(400);
|
||||
}
|
||||
final Rollout rollout = rolloutManagement.create(rolloutCreate, 5, new RolloutGroupConditionBuilder()
|
||||
final Rollout rollout = rolloutManagement.create(rolloutCreate, 5, false, new RolloutGroupConditionBuilder()
|
||||
.withDefaults().successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
||||
|
||||
// Run here, because Scheduler is disabled during tests
|
||||
|
||||
@@ -61,7 +61,6 @@ public class TargetFilterQueriesResourceDocumentationTest extends AbstractApiRes
|
||||
@Test
|
||||
@Description("Handles the GET request of retrieving all target filter queries within SP. Required Permission: READ_TARGET.")
|
||||
public void getTargetFilterQueries() throws Exception {
|
||||
|
||||
createTargetFilterQueryWithDS(createDistributionSet());
|
||||
|
||||
mockMvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)).andExpect(status().isOk())
|
||||
@@ -80,6 +79,12 @@ public class TargetFilterQueriesResourceDocumentationTest extends AbstractApiRes
|
||||
.description(MgmtApiModelProperties.ACTION_FORCE_TYPE)
|
||||
.type(JsonFieldType.STRING.toString())
|
||||
.attributes(key("value").value("['forced', 'soft', 'downloadonly']")),
|
||||
fieldWithPath("content[].autoAssignWeight")
|
||||
.description(MgmtApiModelProperties.RESULTING_ACTIONS_WEIGHT)
|
||||
.type(JsonFieldType.NUMBER.toString()),
|
||||
fieldWithPath("content[].confirmationRequired")
|
||||
.description(MgmtApiModelProperties.ACTION_CONFIRMATION_REQUIRED)
|
||||
.type(JsonFieldType.BOOLEAN.toString()),
|
||||
fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT),
|
||||
fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY),
|
||||
fieldWithPath("content[].lastModifiedAt")
|
||||
@@ -182,6 +187,8 @@ public class TargetFilterQueriesResourceDocumentationTest extends AbstractApiRes
|
||||
@Description("Handles the POST request of setting a distribution set for auto assignment within SP. Required Permission: CREATE_TARGET.")
|
||||
public void postAutoAssignDS() throws Exception {
|
||||
enableMultiAssignments();
|
||||
enableConfirmationFlow();
|
||||
|
||||
final TargetFilterQuery tfq = createTargetFilterQuery();
|
||||
final DistributionSet distributionSet = createDistributionSet();
|
||||
final String autoAssignBody = new JSONObject().put("id", distributionSet.getId())
|
||||
@@ -201,7 +208,10 @@ public class TargetFilterQueriesResourceDocumentationTest extends AbstractApiRes
|
||||
.attributes(key("value").value("['forced', 'soft', 'downloadonly']")),
|
||||
requestFieldWithPathMandatoryInMultiAssignMode("weight")
|
||||
.description(MgmtApiModelProperties.RESULTING_ACTIONS_WEIGHT)
|
||||
.attributes(key("value").value("0 - 1000"))),
|
||||
.attributes(key("value").value("0 - 1000")),
|
||||
optionalRequestFieldWithPath("confirmationRequired")
|
||||
.description(MgmtApiModelProperties.ACTION_CONFIRMATION_REQUIRED)
|
||||
.type(JsonFieldType.BOOLEAN.toString())),
|
||||
getResponseFieldTargetFilterQuery(false)));
|
||||
}
|
||||
|
||||
@@ -232,6 +242,9 @@ public class TargetFilterQueriesResourceDocumentationTest extends AbstractApiRes
|
||||
fieldWithPath(arrayPrefix + "autoAssignWeight")
|
||||
.description(MgmtApiModelProperties.RESULTING_ACTIONS_WEIGHT)
|
||||
.type(JsonFieldType.NUMBER.toString()),
|
||||
fieldWithPath(arrayPrefix + "confirmationRequired")
|
||||
.description(MgmtApiModelProperties.ACTION_CONFIRMATION_REQUIRED)
|
||||
.type(JsonFieldType.BOOLEAN.toString()),
|
||||
fieldWithPath(arrayPrefix + "createdAt").description(ApiModelPropertiesGeneric.CREATED_AT),
|
||||
fieldWithPath(arrayPrefix + "createdBy").description(ApiModelPropertiesGeneric.CREATED_BY),
|
||||
fieldWithPath(arrayPrefix + "lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT),
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
package org.eclipse.hawkbit.rest.mgmt.documentation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_V1_ACTIVATE_AUTO_CONFIRM;
|
||||
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_V1_AUTO_CONFIRM;
|
||||
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_V1_DEACTIVATE_AUTO_CONFIRM;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete;
|
||||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
|
||||
@@ -31,6 +34,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirmUpdate;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.ActionStatusFields;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
@@ -78,6 +82,8 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
@Test
|
||||
@Description("Handles the GET request of retrieving all targets within SP. Required Permission: READ_TARGET.")
|
||||
public void getTargets() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
createTargetByGivenNameWithAttributes(targetId, createDistributionSet());
|
||||
|
||||
mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)).andExpect(status().isOk())
|
||||
@@ -98,9 +104,11 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
fieldWithPath("content[].securityToken").description(MgmtApiModelProperties.SECURITY_TOKEN),
|
||||
fieldWithPath("content[].requestAttributes")
|
||||
.description(MgmtApiModelProperties.REQUEST_ATTRIBUTES),
|
||||
fieldWithPath("content[].autoConfirmActive")
|
||||
.description(MgmtApiModelProperties.AUTO_CONFIRM_ACTIVE),
|
||||
fieldWithPath("content[].installedAt").description(MgmtApiModelProperties.INSTALLED_AT),
|
||||
fieldWithPath("content[].lastModifiedAt")
|
||||
.description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"),
|
||||
fieldWithPath("content[].lastModifiedAt").description(
|
||||
ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"),
|
||||
fieldWithPath("content[].lastModifiedBy")
|
||||
.description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"),
|
||||
fieldWithPath("content[].ipAddress").description(MgmtApiModelProperties.IP_ADDRESS)
|
||||
@@ -125,6 +133,8 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
@Test
|
||||
@Description("Handles the POST request of creating new targets within SP. The request body must always be a list of targets. Required Permission: CREATE_TARGET.")
|
||||
public void postTargets() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final TargetType defaultType = testdataFactory.createTargetType("defaultType", Collections.emptyList());
|
||||
final String target = createTargetJsonForPostRequest("123456", "controllerId", "test", defaultType);
|
||||
|
||||
@@ -157,6 +167,8 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
fieldWithPath("[]securityToken").description(MgmtApiModelProperties.SECURITY_TOKEN),
|
||||
fieldWithPath("[]requestAttributes")
|
||||
.description(MgmtApiModelProperties.REQUEST_ATTRIBUTES),
|
||||
fieldWithPath("[]autoConfirmActive")
|
||||
.description(MgmtApiModelProperties.AUTO_CONFIRM_ACTIVE),
|
||||
fieldWithPath("[]targetType").description(MgmtApiModelProperties.TARGETTYPE_ID),
|
||||
fieldWithPath("[]targetTypeName").description(MgmtApiModelProperties.TARGETTYPE_NAME),
|
||||
fieldWithPath("[]_links.self").ignored())));
|
||||
@@ -175,6 +187,8 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
@Test
|
||||
@Description("Handles the GET request of retrieving a single target within SP. Required Permission: READ_TARGET.")
|
||||
public void getTarget() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final Target target = createTargetByGivenNameWithAttributes(targetId, createDistributionSet());
|
||||
|
||||
mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", target.getControllerId()))
|
||||
@@ -187,6 +201,8 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
@Test
|
||||
@Description("Handles the PUT request of updating a target within SP. Required Permission: UPDATE_TARGET.")
|
||||
public void putTarget() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final Target target = createTargetByGivenNameWithAttributes(targetId, createDistributionSet());
|
||||
final String targetAsJson = createJsonTarget(targetId, "newTargetName", "I've been updated");
|
||||
|
||||
@@ -504,7 +520,9 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
.description(MgmtApiModelProperties.ACTION_STATUS_CODE).type("Integer"),
|
||||
fieldWithPath("content[].type").description(MgmtApiModelProperties.ACTION_STATUS_TYPE)
|
||||
.attributes(key("value").value(
|
||||
"['finished', 'error', 'warning', 'pending', 'running', 'canceled', 'retrieved', 'canceling']")))));
|
||||
"['finished', 'error', 'warning', 'running', 'canceled', 'canceling', " //
|
||||
+ "'retrieved', 'download', 'scheduled', 'cancel_rejected', " //
|
||||
+ "'downloaded', 'wait_for_confirmation']")))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -565,6 +583,9 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
.description(MgmtApiModelProperties.ASSIGNMENT_WEIGHT)
|
||||
.type(JsonFieldType.NUMBER).attributes(key("value").value("0 - 1000")),
|
||||
optionalRequestFieldWithPath("forcetime").description(MgmtApiModelProperties.FORCETIME),
|
||||
optionalRequestFieldWithPath("[].confirmationRequired")
|
||||
.description(MgmtApiModelProperties.ASSIGNMENT_CONFIRMATION_REQUIRED)
|
||||
.type(JsonFieldType.BOOLEAN.toString()),
|
||||
optionalRequestFieldWithPath("maintenanceWindow")
|
||||
.description(MgmtApiModelProperties.MAINTENANCE_WINDOW),
|
||||
optionalRequestFieldWithPath("maintenanceWindow.schedule")
|
||||
@@ -594,7 +615,8 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
new JSONObject().put("schedule", getTestSchedule(100))
|
||||
.put("duration", getTestDuration(10)).put("timezone", getTestTimeZone())))
|
||||
.toString();
|
||||
body.put(new JSONObject().put("id", sets.get(0).getId()).put("type", "forced").put("weight", 800));
|
||||
body.put(new JSONObject().put("id", sets.get(0).getId()).put("type", "forced").put("weight", 800)
|
||||
.put("confirmationRequired", true));
|
||||
|
||||
enableMultiAssignments();
|
||||
mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/"
|
||||
@@ -611,6 +633,9 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
.attributes(key("value").value("0 - 1000")),
|
||||
optionalRequestFieldWithPath("[].forcetime")
|
||||
.description(MgmtApiModelProperties.FORCETIME),
|
||||
optionalRequestFieldWithPath("[].confirmationRequired")
|
||||
.description(MgmtApiModelProperties.ASSIGNMENT_CONFIRMATION_REQUIRED)
|
||||
.type(JsonFieldType.BOOLEAN.toString()),
|
||||
optionalRequestFieldWithPath("[].maintenanceWindow")
|
||||
.description(MgmtApiModelProperties.MAINTENANCE_WINDOW),
|
||||
optionalRequestFieldWithPath("[].maintenanceWindow.schedule")
|
||||
@@ -869,6 +894,76 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Handles the GET request of retrieving the auto-confirm state of a target. In this case auto-confirm is active for the requested target. Required Permission: READ_TARGET.")
|
||||
public void getTargetAutoConfirmStateActive() throws Exception {
|
||||
final Target testTarget = testdataFactory.createTarget(targetId);
|
||||
confirmationManagement.activateAutoConfirmation(testTarget.getControllerId(), "custom_initiator_value",
|
||||
"custom_remark");
|
||||
|
||||
mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM,
|
||||
testTarget.getControllerId())).andExpect(status().isOk()).andDo(MockMvcResultPrinter.print())
|
||||
.andDo(this.document.document(
|
||||
pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)),
|
||||
responseFields(
|
||||
fieldWithPath("active").description(MgmtApiModelProperties.AUTO_CONFIRM_STATE_ACTIVE),
|
||||
fieldWithPath("initiator")
|
||||
.description(MgmtApiModelProperties.AUTO_CONFIRM_STATE_INITIATOR),
|
||||
fieldWithPath("remark").description(MgmtApiModelProperties.AUTO_CONFIRM_STATE_REMARK),
|
||||
fieldWithPath("activatedAt")
|
||||
.description(MgmtApiModelProperties.AUTO_CONFIRM_STATE_ACTIVATED_AT),
|
||||
fieldWithPath("_links.deactivate").optional().description(
|
||||
MgmtApiModelProperties.AUTO_CONFIRM_STATE_REFERENCE_DEACTIVATE_AUTO_CONFIRM))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Handles the GET request of retrieving the auto-confirm state of a target. In this case auto-confirm is not active for the requested target. Required Permission: READ_TARGET.")
|
||||
public void getTargetAutoConfirmStateNotActive() throws Exception {
|
||||
final Target testTarget = testdataFactory.createTarget(targetId);
|
||||
|
||||
mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM,
|
||||
testTarget.getControllerId())).andExpect(status().isOk()).andDo(MockMvcResultPrinter.print())
|
||||
.andDo(this.document.document(
|
||||
pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)),
|
||||
responseFields(
|
||||
fieldWithPath("active").description(MgmtApiModelProperties.AUTO_CONFIRM_STATE_ACTIVE),
|
||||
fieldWithPath("_links.activate").optional().description(
|
||||
MgmtApiModelProperties.AUTO_CONFIRM_STATE_REFERENCE_ACTIVATE_AUTO_CONFIRM))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Handles the POST request to activate auto-confirm on a target. Payload can be provided to specify more details about the operation. Required Permission: UPDATE_TARGET.")
|
||||
public void postActivateAutoConfirm() throws Exception {
|
||||
final Target testTarget = testdataFactory.createTarget(targetId);
|
||||
|
||||
final MgmtTargetAutoConfirmUpdate body = new MgmtTargetAutoConfirmUpdate("custom_initiator_value",
|
||||
"custom_remark_value");
|
||||
|
||||
mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM + "/"
|
||||
+ TARGET_V1_ACTIVATE_AUTO_CONFIRM, testTarget.getControllerId())
|
||||
.content(this.objectMapper.writeValueAsString(body)).contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk()).andDo(MockMvcResultPrinter.print())
|
||||
.andDo(this.document.document(
|
||||
pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)),
|
||||
requestFields(
|
||||
optionalRequestFieldWithPath("initiator")
|
||||
.description(MgmtApiModelProperties.AUTO_CONFIRM_ACTIVATE_INITIATOR),
|
||||
optionalRequestFieldWithPath("remark")
|
||||
.description(MgmtApiModelProperties.AUTO_CONFIRM_ACTIVATE_REMARK))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Handles the POST request to deactivate auto-confirm on a target. Required Permission: UPDATE_TARGET.")
|
||||
public void postDeactivateAutoConfirm() throws Exception {
|
||||
final Target testTarget = testdataFactory.createTarget(targetId);
|
||||
confirmationManagement.activateAutoConfirmation(testTarget.getControllerId(), null, null);
|
||||
|
||||
mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM + "/"
|
||||
+ TARGET_V1_DEACTIVATE_AUTO_CONFIRM, testTarget.getControllerId())).andExpect(status().isOk())
|
||||
.andDo(MockMvcResultPrinter.print()).andDo(this.document.document(
|
||||
pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID))));
|
||||
}
|
||||
|
||||
private String createTargetJsonForPostRequest(final String controllerId, final String name,
|
||||
final String description, final TargetType targetType) throws JsonProcessingException {
|
||||
final Map<String, Object> target = new HashMap<>();
|
||||
|
||||
@@ -153,6 +153,8 @@ public class TargetTagResourceDocumentationTest extends AbstractApiRestDocumenta
|
||||
@Test
|
||||
@Description("Handles the GET request of retrieving all assigned targets by the given")
|
||||
public void getAssignedTargets() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final TargetTag tag = createTargetTagEntitiy();
|
||||
final Target target = createTargetByGivenNameWithAttributes("Target1", distributionSet);
|
||||
targetManagement.assignTag(Arrays.asList(target.getControllerId()), tag.getId());
|
||||
@@ -200,6 +202,8 @@ public class TargetTagResourceDocumentationTest extends AbstractApiRestDocumenta
|
||||
@Test
|
||||
@Description("Handles the POST request to assign targets to the given tag id")
|
||||
public void assignTargets() throws Exception {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final Long tagId = createTargetTagId();
|
||||
final MgmtAssignedTargetRequestBody assignedTargetRequestBody1 = new MgmtAssignedTargetRequestBody();
|
||||
assignedTargetRequestBody1
|
||||
|
||||
@@ -91,6 +91,8 @@ public class TenantResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
"if multiple distribution sets can be assigned to the same targets.");
|
||||
CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.BATCH_ASSIGNMENTS_ENABLED,
|
||||
"if distribution set can be assigned to multiple targets in a single batch message.");
|
||||
CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.USER_CONFIRMATION_ENABLED,
|
||||
"if confirmation is required when distribution set is assigned to target.");
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user