From 7e04509f4c3962e491eaeb87bd4414bbaa03101b Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Sun, 5 Dec 2021 19:31:19 -0500 Subject: [PATCH] add test for authorization --- .../interceptor/auth/OperationRule.java | 36 ++++++++++++++++++- .../interceptor/auth/OperationRuleUtil.java | 16 +++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRuleUtil.java diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRule.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRule.java index 3afa2ae992e..0fefd7397e5 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRule.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRule.java @@ -33,7 +33,6 @@ import java.util.List; import java.util.Set; class OperationRule extends BaseRule implements IAuthRule { - private String myOperationName; private boolean myAppliesToServer; private HashSet> myAppliesToTypes; @@ -210,4 +209,39 @@ class OperationRule extends BaseRule implements IAuthRule { myOperationName = theOperationName; } + String getOperationName() { + return myOperationName; + } + + boolean isAppliesToServer() { + return myAppliesToServer; + } + + HashSet> getAppliesToTypes() { + return myAppliesToTypes; + } + + List getAppliesToIds() { + return myAppliesToIds; + } + + HashSet> getAppliesToInstancesOfType() { + return myAppliesToInstancesOfType; + } + + boolean isAppliesToAnyType() { + return myAppliesToAnyType; + } + + boolean isAppliesToAnyInstance() { + return myAppliesToAnyInstance; + } + + boolean isAppliesAtAnyLevel() { + return myAppliesAtAnyLevel; + } + + boolean isAllowAllResponses() { + return myAllowAllResponses; + } } diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRuleUtil.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRuleUtil.java new file mode 100644 index 00000000000..7112df080eb --- /dev/null +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRuleUtil.java @@ -0,0 +1,16 @@ +package ca.uhn.fhir.rest.server.interceptor.auth; + +public final class OperationRuleUtil { + private OperationRuleUtil() {} + public static String getOperationName(IAuthRule theRule) { + return ((OperationRule)theRule).getOperationName(); + } + + public static boolean isAppliesToServer(IAuthRule theRule) { + return ((OperationRule)theRule).isAppliesToServer(); + } + + public static boolean isAllowAllResponses(IAuthRule theRule) { + return ((OperationRule)theRule).isAllowAllResponses(); + } +}