summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/api/swagger/policy-executor/openapi.yaml2
-rw-r--r--policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java18
-rw-r--r--policy-executor-stub/src/test/groovy/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubControllerSpec.groovy6
3 files changed, 15 insertions, 11 deletions
diff --git a/docs/api/swagger/policy-executor/openapi.yaml b/docs/api/swagger/policy-executor/openapi.yaml
index 5becd9a39e..98c5b1e79a 100644
--- a/docs/api/swagger/policy-executor/openapi.yaml
+++ b/docs/api/swagger/policy-executor/openapi.yaml
@@ -214,7 +214,7 @@ components:
authorizationInHeader:
name: Authorization
in: header
- required: true
+ description: "Bearer token may be used to identify client as part of a policy"
schema:
type: string
diff --git a/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java b/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java
index 7989c3fc8c..a5ec6dcac9 100644
--- a/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java
+++ b/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java
@@ -41,9 +41,9 @@ public class PolicyExecutorStubController implements PolicyExecutorApi {
@Override
public ResponseEntity<PolicyExecutionResponse> executePolicyAction(
- final String authorization,
final String action,
- final PolicyExecutionRequest policyExecutionRequest) {
+ final PolicyExecutionRequest policyExecutionRequest,
+ final String authorization) {
if (policyExecutionRequest.getPayload().isEmpty()) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
@@ -56,15 +56,19 @@ public class PolicyExecutorStubController implements PolicyExecutorApi {
return new ResponseEntity<>(HttpStatusCode.valueOf(errorCode));
}
- final PolicyExecutionResponse policyExecutionResponse = new PolicyExecutionResponse();
- policyExecutionResponse.setDecisionId(String.valueOf(++decisionCounter));
+ final String decisionId = String.valueOf(++decisionCounter);
+ final String decision;
+ final String message;
if (firstTargetFdn.toLowerCase(Locale.getDefault()).contains("cps-is-great")) {
- policyExecutionResponse.setDecision("permit");
+ decision = "permit";
+ message = "All good";
} else {
- policyExecutionResponse.setDecision("deny");
- policyExecutionResponse.setMessage("Only FDNs containing 'cps-is-great' are permitted");
+ decision = "deny";
+ message = "Only FDNs containing 'cps-is-great' are permitted";
}
+ final PolicyExecutionResponse policyExecutionResponse =
+ new PolicyExecutionResponse(decisionId, decision, message);
return ResponseEntity.ok(policyExecutionResponse);
}
}
diff --git a/policy-executor-stub/src/test/groovy/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubControllerSpec.groovy b/policy-executor-stub/src/test/groovy/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubControllerSpec.groovy
index 593394fdc7..871db81ac8 100644
--- a/policy-executor-stub/src/test/groovy/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubControllerSpec.groovy
+++ b/policy-executor-stub/src/test/groovy/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubControllerSpec.groovy
@@ -66,7 +66,7 @@ class PolicyExecutorStubControllerSpec extends Specification {
where: 'the following targets are used'
targetFdn || expectedDecsisonId | expectedDecsison | expectedMessage
'some fdn' || '1' | 'deny' | "Only FDNs containing 'cps-is-great' are permitted"
- 'fdn with cps-is-great' || '2' | 'permit' | null
+ 'fdn with cps-is-great' || '2' | 'permit' | "All good"
}
def 'Execute Policy Action with a HTTP Error Code.'() {
@@ -94,8 +94,8 @@ class PolicyExecutorStubControllerSpec extends Specification {
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.andReturn().response
- then: 'response status is Bad Request'
- assert response.status == HttpStatus.BAD_REQUEST.value()
+ then: 'response status is OK'
+ assert response.status == HttpStatus.OK.value()
}
def 'Execute Policy Action with Empty Payload.'() {