Merge remote-tracking branch 'remotes/origin/master' into ks-20191206-migration-nullable-failure

This commit is contained in:
Ken Stevens 2019-12-08 14:40:28 -05:00
commit 6ddabaef5c
4 changed files with 55 additions and 1 deletions

View File

@ -423,7 +423,7 @@ public class AuthorizationInterceptor implements IRuleApplier {
private final IAuthRule myDecidingRule; private final IAuthRule myDecidingRule;
private final PolicyEnum myDecision; private final PolicyEnum myDecision;
Verdict(PolicyEnum theDecision, IAuthRule theDecidingRule) { public Verdict(PolicyEnum theDecision, IAuthRule theDecidingRule) {
Validate.notNull(theDecision); Validate.notNull(theDecision);
myDecision = theDecision; myDecision = theDecision;

View File

@ -0,0 +1,48 @@
package ca.uhn.fhir.rest.server;
import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationFlagsEnum;
import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor.Verdict;
import ca.uhn.fhir.rest.server.interceptor.auth.IAuthRule;
import ca.uhn.fhir.rest.server.interceptor.auth.IRuleApplier;
import ca.uhn.fhir.rest.server.interceptor.auth.PolicyEnum;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.Test;
import java.util.Set;
/**
* Tests for {@link Verdict}
*
* @author Jafer Khan Shamshad
*/
public class VerdictTest {
/**
* Implementers should be able to instantiate {@link Verdict} outside the package where it has been defined.
*/
@Test
public void testInstantiationFromAnotherPackage() {
Verdict verdict = new Verdict(PolicyEnum.ALLOW, new CustomRule());
}
/**
* Existing implementations of {@link IAuthRule} are inaccessible from this package.
* This test class is a sample implementation of {@link IAuthRule}.
*/
public static class CustomRule implements IAuthRule {
@Override
public Verdict applyRule(RestOperationTypeEnum theOperation, RequestDetails theRequestDetails, IBaseResource theInputResource, IIdType theInputResourceId, IBaseResource theOutputResource, IRuleApplier theRuleApplier, Set<AuthorizationFlagsEnum> theFlags, Pointcut thePointcut) {
return new Verdict(PolicyEnum.ALLOW, this);
}
@Override
public String getName() {
return "Custom rule";
}
}
}

View File

@ -1,9 +1,11 @@
package ca.uhn.fhir.rest.server.interceptor.auth; package ca.uhn.fhir.rest.server.interceptor.auth;
import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor.Verdict; import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor.Verdict;
import org.junit.Test;
public class VerdictTest { public class VerdictTest {
@Test
public void testToString() { public void testToString() {
Verdict v = new AuthorizationInterceptor.Verdict(PolicyEnum.ALLOW, new RuleImplOp("foo")); Verdict v = new AuthorizationInterceptor.Verdict(PolicyEnum.ALLOW, new RuleImplOp("foo"));
v.toString(); v.toString();

View File

@ -54,6 +54,10 @@
A ConcurrentModificationException was sometimes thrown when performing a cascading delete. A ConcurrentModificationException was sometimes thrown when performing a cascading delete.
This has been corrected. This has been corrected.
</action> </action>
<action type="fix" issue="1624">
The constructor for Verdict.java was inadvertantly made private, preventing custom
rules from being written. Thanks to Jafer Khan for the pull request!
</action>
</release> </release>
<release version="4.1.0" date="2019-11-13" description="Jitterbug"> <release version="4.1.0" date="2019-11-13" description="Jitterbug">
<action type="add"> <action type="add">